This repository has been archived by the owner on Jan 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AWS CloudFormation events support
CAT: #feat #doc REF: #1
- Loading branch information
Showing
13 changed files
with
206 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
86
service/lambda/runtime/event/cloudformationevt/definition.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters