Skip to content

Instantly share code, notes, and snippets.

@wjordan
Created January 13, 2017 01:56
Show Gist options
  • Save wjordan/8fde8bb25601c974872921196dea055a to your computer and use it in GitHub Desktop.
Save wjordan/8fde8bb25601c974872921196dea055a to your computer and use it in GitHub Desktop.
Nested stacks
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"LambdaStack": {
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"TemplateURL": "./Test1.json",
"TimeoutInMinutes": "60"
}
},
"PermissionsStack": {
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"TemplateURL": "./Test2.json",
"Parameters": {
"LambdaTest": {
"Fn::GetAtt": ["LambdaStack", "Outputs.LambdaTest"]
}
},
"TimeoutInMinutes": "60"
}
}
}
}
{
"Resources": {
"LambdaTestRes": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Description": "Testing AWS cloud formation",
"FunctionName": "LambdaTest",
"Handler": "lambda_handler.lambda_handler",
"MemorySize": 128,
"Role": "arn:aws:iam::[account]:role/[role]",
"Runtime": "python2.7",
"Timeout": 300,
"Code": {
"ZipFile": {
"Fn::Join": [
"\n",
[
"var response = require('cfn-response');",
"exports.handler = function(event, context) {",
" response.send(event, context, response.SUCCESS, {});",
"};"
]
]
}
}
}
}
},
"Outputs": {
"LambdaTest": {
"Value": {
"Fn::GetAtt": [
"LambdaTestRes",
"Arn"
]
}
}
}
}
{
"Parameters": {
"LambdaTest": {
"Type": "String"
}
},
"Resources": {
"LambdaPermissionLambdaTest": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:invokeFunction",
"FunctionName": {
"Ref": "LambdaTest"
},
"Principal": "apigateway.amazonaws.com",
"SourceArn": {
"Fn::Join": ["", ["arn:aws:execute-api:", {
"Ref": "AWS::Region"
}, ":", {
"Ref": "AWS::AccountId"
}, ":", "TestAPI", "/*"]]
}
}
}
}
}
@wjordan
Copy link
Author

wjordan commented Jan 13, 2017

fill in "arn:aws:iam::[account]:role/[role]" with a valid role in your account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment