Created
May 13, 2017 04:42
-
-
Save ks888/fb07b474fad5d034a46e0a3b8d10e44f to your computer and use it in GitHub Desktop.
CloudFormation Custom Resource Experiments
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
--- | |
AWSTemplateFormatVersion: 2010-09-09 | |
Parameters: | |
Param: | |
Type: String | |
Default: v1 | |
Resources: | |
MyCustomResource: | |
Type: Custom::MyResouce | |
Properties: | |
ServiceToken: !Sub |- | |
${MyLambdaFunction.Arn} | |
Param: !Sub |- | |
${Param} | |
MyLambdaFunction: | |
Type: AWS::Lambda::Function | |
Properties: | |
Code: | |
ZipFile: > | |
var response = require('cfn-response'); | |
exports.handler = function(event, context) { | |
response.send(event, context, response.SUCCESS, {}); | |
}; | |
Handler: index.handler | |
Role: !Sub |- | |
${MyRole.Arn} | |
Runtime: nodejs4.3 | |
MyRole: | |
Type: AWS::IAM::Role | |
Properties: | |
AssumeRolePolicyDocument: | |
Statement: | |
- Effect: Allow | |
Principal: | |
Service: | |
- lambda.amazonaws.com | |
Action: | |
- sts:AssumeRole | |
Policies: | |
- PolicyName: CloudWatchLogs | |
PolicyDocument: | |
Statement: | |
- Action: | |
- logs:CreateLogGroup | |
- logs:CreateLogStream | |
- logs:PutLogEvents | |
Effect: Allow | |
Resource: arn:aws:logs:*:*:* |
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
--- | |
AWSTemplateFormatVersion: 2010-09-09 | |
Parameters: | |
Param: | |
Type: String | |
Default: v1 | |
Resources: | |
MyCustomResource: | |
Type: Custom::MyResouce | |
Properties: | |
ServiceToken: !Sub |- | |
${MyLambdaFunction.Arn} | |
Param: !Sub |- | |
${Param} | |
MyLambdaFunction: | |
Type: AWS::Lambda::Function | |
Properties: | |
Code: | |
ZipFile: > | |
var response = require('cfn-response'); | |
exports.handler = function(event, context) { | |
response.send(event, context, response.SUCCESS, {}, 'PhysicalResourceID'); | |
}; | |
Handler: index.handler | |
Role: !Sub |- | |
${MyRole.Arn} | |
Runtime: nodejs4.3 | |
MyRole: | |
Type: AWS::IAM::Role | |
Properties: | |
AssumeRolePolicyDocument: | |
Statement: | |
- Effect: Allow | |
Principal: | |
Service: | |
- lambda.amazonaws.com | |
Action: | |
- sts:AssumeRole | |
Policies: | |
- PolicyName: CloudWatchLogs | |
PolicyDocument: | |
Statement: | |
- Action: | |
- logs:CreateLogGroup | |
- logs:CreateLogStream | |
- logs:PutLogEvents | |
Effect: Allow | |
Resource: arn:aws:logs:*:*:* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment