Skip to content
This repository has been archived by the owner on Jan 14, 2020. It is now read-only.

Commit

Permalink
Add AWS CloudFormation events support
Browse files Browse the repository at this point in the history
CAT: #feat #doc
REF: #1
  • Loading branch information
fsenart committed Jan 20, 2017
1 parent e94c916 commit 922848a
Show file tree
Hide file tree
Showing 13 changed files with 206 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ definitions and helpers to deal with [AWS Lambda event source mapping][aws-lambd
- [Amazon S3 Events][eawsy-s3evt]
- [Amazon Simple Email Service Events][eawsy-sesevt]
- [Amazon Simple Notification Service Events][eawsy-snsevt]
- [AWS CloudFormation Events][eawsy-cloudformationevt]

[<img src="_asset/misc_arrow-up.png" align="right">](#top)
## About
Expand Down Expand Up @@ -110,6 +111,7 @@ affiliates in the United States and/or other countries.
[eawsy-s3evt]: /service/lambda/runtime/event/s3evt
[eawsy-sesevt]: /service/lambda/runtime/event/sesevt
[eawsy-snsevt]: /service/lambda/runtime/event/snsevt
[eawsy-cloudformationevt]: /service/lambda/runtime/event/cloudformationevt

[aws-home]: https://aws.amazon.com/
[aws-lambda-home]: https://aws.amazon.com/lambda/
Expand Down
2 changes: 2 additions & 0 deletions service/lambda/runtime/event/apigatewayproxyevt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func Handle(evt *apigatewayproxyevt.Event, ctx *runtime.Context) (interface{}, e
- [Amazon S3 Events][eawsy-s3evt]
- [Amazon Simple Email Service Events][eawsy-sesevt]
- [Amazon Simple Notification Service Events][eawsy-snsevt]
- [AWS CloudFormation Events][eawsy-cloudformationevt]

[<img src="/_asset/misc_arrow-up.png" align="right">](#top)
## License
Expand All @@ -74,3 +75,4 @@ except in compliance with the License. See [LICENSE](/LICENSE) and [NOTICE](/NOT
[eawsy-s3evt]: /service/lambda/runtime/event/s3evt
[eawsy-sesevt]: /service/lambda/runtime/event/sesevt
[eawsy-snsevt]: /service/lambda/runtime/event/snsevt
[eawsy-cloudformationevt]: /service/lambda/runtime/event/cloudformationevt
78 changes: 78 additions & 0 deletions service/lambda/runtime/event/cloudformationevt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<a id="top" name="top"></a>

# AWS CloudFormation Events

[<img src="/_asset/misc_home.png" alt="Back to Home" align="right">](/)
[![Go Doc][badge-doc-go]][eawsy-doc]
[![AWS Doc][badge-doc-aws]][aws-doc]

This package allows you write AWS Lambda functions as the back end of your API
through the AWS Lambda proxy integration.

[<img src="/_asset/misc_arrow-up.png" align="right">](#top)
## Quick Hands-On

> For step by step instructions on how to author your AWS Lambda function code in Go, see
[eawsy/aws-lambda-go-shim][eawsy-runtime].

```sh
go get -u -d github.com/eawsy/aws-lambda-go-event/...
```

```go
package main

// /* Required, but no C code needed. */
import "C"

import (
"fmt"

"github.com/eawsy/aws-lambda-go-event/service/lambda/runtime/event/cloudformationevt"
"github.com/eawsy/aws-lambda-go-core/service/lambda/runtime"
)

func Handle(evt *cloudformationevt.Event, ctx *runtime.Context) (interface{}, error) {
fmt.Println(evt)
return nil, nil
}
```

[<img src="/_asset/misc_arrow-up.png" align="right">](#top)
## Supported Events

- [Amazon API Gateway Proxy Events][eawsy-apigatewayproxyevt]
- [Amazon CloudWatch Logs Events][eawsy-cloudwatchlogsevt]
- [Amazon CloudWatch Scheduled Events][eawsy-cloudwatchschedevt]
- [Amazon Cognito Sync Events][eawsy-cognitosyncevt]
- [Amazon DynamoDB Streams Events][eawsy-dynamodbstreamsevt]
- [Amazon Kinesis Streams Events][eawsy-kinesisstreamsevt]
- [Amazon S3 Events][eawsy-s3evt]
- [Amazon Simple Email Service Events][eawsy-sesevt]
- [Amazon Simple Notification Service Events][eawsy-snsevt]
- [AWS CloudFormation Events][eawsy-cloudformationevt]

[<img src="/_asset/misc_arrow-up.png" align="right">](#top)
## License

This product is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this product
except in compliance with the License. See [LICENSE](/LICENSE) and [NOTICE](/NOTICE) for more information.

[eawsy-runtime]: https://github.com/eawsy/aws-lambda-go-shim
[eawsy-doc]: https://godoc.org/github.com/eawsy/aws-lambda-go-event/service/lambda/runtime/event/cloudformationevt

[aws-doc]: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html

[badge-doc-go]: http://img.shields.io/badge/api-godoc-7986cb.svg?style=flat-square
[badge-doc-aws]: http://img.shields.io/badge/api-awsdoc-efaf27.svg?style=flat-square

[eawsy-apigatewayproxyevt]: /service/lambda/runtime/event/apigatewayproxyevt
[eawsy-cloudwatchlogsevt]: /service/lambda/runtime/event/cloudwatchlogsevt
[eawsy-cloudwatchschedevt]: /service/lambda/runtime/event/cloudwatchschedevt
[eawsy-cognitosyncevt]: /service/lambda/runtime/event/cognitosyncevt
[eawsy-dynamodbstreamsevt]: /service/lambda/runtime/event/dynamodbstreamsevt
[eawsy-kinesisstreamsevt]: /service/lambda/runtime/event/kinesisstreamsevt
[eawsy-s3evt]: /service/lambda/runtime/event/s3evt
[eawsy-sesevt]: /service/lambda/runtime/event/sesevt
[eawsy-snsevt]: /service/lambda/runtime/event/snsevt
[eawsy-cloudformationevt]: /service/lambda/runtime/event/cloudformationevt
86 changes: 86 additions & 0 deletions service/lambda/runtime/event/cloudformationevt/definition.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
//
// Copyright 2017 Alsanium, SAS. or its affiliates. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package cloudformationevt

import "encoding/json"

// Event represents an AWS CloudFormation event.
// See http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-requests.html
type Event struct {
// A unique ID for the request.
// Combining the StackID with the RequestID forms a value that can be used to
// uniquely identify a request on a particular custom resource.
RequestID string

// The ARN that identifies the stack containing the custom resource.
// Combining the StackID with the RequestID forms a value that can be used to
// uniquely identify a request on a particular custom resource.
StackID string

// The request type is set by the AWS CloudFormation stack operation
// (create-stack, update-stack, or delete-stack) that was initiated by the
// template developer for the stack that contains the custom resource.
// Must be one of: Create, Update, or Delete.
// See http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-requesttypes.html
RequestType string

// The template developer-chosen resource type of the custom resource in the
// AWS CloudFormation template.
// Custom resource type names can be up to 60 characters long and can include
// alphanumeric and the following characters: _@-.
ResourceType string

// The template developer-chosen name (logical ID) of the custom resource in
// the AWS CloudFormation template.
// This is provided to facilitate communication between the custom resource
// provider and the template developer.
LogicalResourceID string

// A required custom resource provider-defined physical ID that is unique for
// that provider.
// Always sent with Update and Delete requests; never sent with Create.
// See http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cfn-customresource.html#d0e41385
PhysicalResourceID string

// This field contains the contents of the Properties object sent by the
// template developer. Its contents are defined by the custom resource
// provider.
ResourceProperties json.RawMessage

// Used only for Update requests. Contains the resource properties that were
// declared previous to the update request.
OldResourceProperties json.RawMessage

// The response URL identifies a pre-signed Amazon S3 bucket that receives
// responses from the custom resource provider to AWS CloudFormation.
ResponseURL string

// The service token (AWS Lambda function ARN) that is obtained from the
// custom resource provider to access the service.
ServiceToken string
}

// String returns the string representation.
func (e *Event) String() string {
s, _ := json.MarshalIndent(e, "", " ")
return string(s)
}

// GoString returns the string representation.
func (e *Event) GoString() string {
return e.String()
}
22 changes: 22 additions & 0 deletions service/lambda/runtime/event/cloudformationevt/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// Copyright 2017 Alsanium, SAS. or its affiliates. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

/*
Package cloudformationevt allows you to write AWS Lambda functions to execute
custom commands whenever you create, update, or delete AWS CloudFormation
stacks.
*/
package cloudformationevt
2 changes: 2 additions & 0 deletions service/lambda/runtime/event/cloudwatchlogsevt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func Handle(evt *cloudwatchlogsevt.Event, ctx *runtime.Context) (interface{}, er
- [Amazon S3 Events][eawsy-s3evt]
- [Amazon Simple Email Service Events][eawsy-sesevt]
- [Amazon Simple Notification Service Events][eawsy-snsevt]
- [AWS CloudFormation Events][eawsy-cloudformationevt]

[<img src="/_asset/misc_arrow-up.png" align="right">](#top)
## License
Expand All @@ -76,3 +77,4 @@ except in compliance with the License. See [LICENSE](/LICENSE) and [NOTICE](/NOT
[eawsy-s3evt]: /service/lambda/runtime/event/s3evt
[eawsy-sesevt]: /service/lambda/runtime/event/sesevt
[eawsy-snsevt]: /service/lambda/runtime/event/snsevt
[eawsy-cloudformationevt]: /service/lambda/runtime/event/cloudformationevt
2 changes: 2 additions & 0 deletions service/lambda/runtime/event/cloudwatchschedevt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func Handle(evt *cloudwatchschedevt.Event, ctx *runtime.Context) (interface{}, e
- [Amazon S3 Events][eawsy-s3evt]
- [Amazon Simple Email Service Events][eawsy-sesevt]
- [Amazon Simple Notification Service Events][eawsy-snsevt]
- [AWS CloudFormation Events][eawsy-cloudformationevt]

[<img src="/_asset/misc_arrow-up.png" align="right">](#top)
## License
Expand All @@ -74,3 +75,4 @@ except in compliance with the License. See [LICENSE](/LICENSE) and [NOTICE](/NOT
[eawsy-s3evt]: /service/lambda/runtime/event/s3evt
[eawsy-sesevt]: /service/lambda/runtime/event/sesevt
[eawsy-snsevt]: /service/lambda/runtime/event/snsevt
[eawsy-cloudformationevt]: /service/lambda/runtime/event/cloudformationevt
2 changes: 2 additions & 0 deletions service/lambda/runtime/event/cognitosyncevt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func Handle(evt *cognitosyncevt.Event, ctx *runtime.Context) (interface{}, error
- [Amazon S3 Events][eawsy-s3evt]
- [Amazon Simple Email Service Events][eawsy-sesevt]
- [Amazon Simple Notification Service Events][eawsy-snsevt]
- [AWS CloudFormation Events][eawsy-cloudformationevt]

[<img src="/_asset/misc_arrow-up.png" align="right">](#top)
## License
Expand All @@ -74,3 +75,4 @@ except in compliance with the License. See [LICENSE](/LICENSE) and [NOTICE](/NOT
[eawsy-s3evt]: /service/lambda/runtime/event/s3evt
[eawsy-sesevt]: /service/lambda/runtime/event/sesevt
[eawsy-snsevt]: /service/lambda/runtime/event/snsevt
[eawsy-cloudformationevt]: /service/lambda/runtime/event/cloudformationevt
2 changes: 2 additions & 0 deletions service/lambda/runtime/event/dynamodbstreamsevt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func Handle(evt *dynamodbstreamsevt.Event, ctx *runtime.Context) (interface{}, e
- [Amazon S3 Events][eawsy-s3evt]
- [Amazon Simple Email Service Events][eawsy-sesevt]
- [Amazon Simple Notification Service Events][eawsy-snsevt]
- [AWS CloudFormation Events][eawsy-cloudformationevt]

[<img src="/_asset/misc_arrow-up.png" align="right">](#top)
## License
Expand All @@ -76,3 +77,4 @@ except in compliance with the License. See [LICENSE](/LICENSE) and [NOTICE](/NOT
[eawsy-s3evt]: /service/lambda/runtime/event/s3evt
[eawsy-sesevt]: /service/lambda/runtime/event/sesevt
[eawsy-snsevt]: /service/lambda/runtime/event/snsevt
[eawsy-cloudformationevt]: /service/lambda/runtime/event/cloudformationevt
2 changes: 2 additions & 0 deletions service/lambda/runtime/event/kinesisstreamsevt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func Handle(evt *kinesisstreamsevt.Event, ctx *runtime.Context) (interface{}, er
- [Amazon S3 Events][eawsy-s3evt]
- [Amazon Simple Email Service Events][eawsy-sesevt]
- [Amazon Simple Notification Service Events][eawsy-snsevt]
- [AWS CloudFormation Events][eawsy-cloudformationevt]

[<img src="/_asset/misc_arrow-up.png" align="right">](#top)
## License
Expand All @@ -76,3 +77,4 @@ except in compliance with the License. See [LICENSE](/LICENSE) and [NOTICE](/NOT
[eawsy-s3evt]: /service/lambda/runtime/event/s3evt
[eawsy-sesevt]: /service/lambda/runtime/event/sesevt
[eawsy-snsevt]: /service/lambda/runtime/event/snsevt
[eawsy-cloudformationevt]: /service/lambda/runtime/event/cloudformationevt
2 changes: 2 additions & 0 deletions service/lambda/runtime/event/s3evt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func Handle(evt *s3evt.Event, ctx *runtime.Context) (interface{}, error) {
- [Amazon S3 Events][eawsy-s3evt]
- [Amazon Simple Email Service Events][eawsy-sesevt]
- [Amazon Simple Notification Service Events][eawsy-snsevt]
- [AWS CloudFormation Events][eawsy-cloudformationevt]

[<img src="/_asset/misc_arrow-up.png" align="right">](#top)
## License
Expand All @@ -76,3 +77,4 @@ except in compliance with the License. See [LICENSE](/LICENSE) and [NOTICE](/NOT
[eawsy-s3evt]: /service/lambda/runtime/event/s3evt
[eawsy-sesevt]: /service/lambda/runtime/event/sesevt
[eawsy-snsevt]: /service/lambda/runtime/event/snsevt
[eawsy-cloudformationevt]: /service/lambda/runtime/event/cloudformationevt
2 changes: 2 additions & 0 deletions service/lambda/runtime/event/sesevt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func Handle(evt *sesevt.Event, ctx *runtime.Context) (interface{}, error) {
- [Amazon S3 Events][eawsy-s3evt]
- [Amazon Simple Email Service Events][eawsy-sesevt]
- [Amazon Simple Notification Service Events][eawsy-snsevt]
- [AWS CloudFormation Events][eawsy-cloudformationevt]

[<img src="/_asset/misc_arrow-up.png" align="right">](#top)
## License
Expand All @@ -76,3 +77,4 @@ except in compliance with the License. See [LICENSE](/LICENSE) and [NOTICE](/NOT
[eawsy-s3evt]: /service/lambda/runtime/event/s3evt
[eawsy-sesevt]: /service/lambda/runtime/event/sesevt
[eawsy-snsevt]: /service/lambda/runtime/event/snsevt
[eawsy-cloudformationevt]: /service/lambda/runtime/event/cloudformationevt
3 changes: 2 additions & 1 deletion service/lambda/runtime/event/snsevt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func Handle(evt *snsevt.Event, ctx *runtime.Context) (interface{}, error) {
- [Amazon S3 Events][eawsy-s3evt]
- [Amazon Simple Email Service Events][eawsy-sesevt]
- [Amazon Simple Notification Service Events][eawsy-snsevt]
- [AWS CloudFormation Events][eawsy-cloudformationevt]

[<img src="/_asset/misc_arrow-up.png" align="right">](#top)
## License
Expand All @@ -76,4 +77,4 @@ except in compliance with the License. See [LICENSE](/LICENSE) and [NOTICE](/NOT
[eawsy-s3evt]: /service/lambda/runtime/event/s3evt
[eawsy-sesevt]: /service/lambda/runtime/event/sesevt
[eawsy-snsevt]: /service/lambda/runtime/event/snsevt

[eawsy-cloudformationevt]: /service/lambda/runtime/event/cloudformationevt

0 comments on commit 922848a

Please sign in to comment.