This closes #1. Add per-region S3 buckets for the zip file

This commit is contained in:
Ryan Martin 2016-07-18 15:30:48 -04:00
parent 181bc2d10f
commit eb0109af63
2 changed files with 17 additions and 10 deletions

View file

@ -12,7 +12,7 @@ general manner - much the same way CloudFormation itself has permission to do al
## Usage ## Usage
1. Use https://s3.amazonaws.com/com.gilt.public.backoffice/cloudformation_templates/create_cloudformation_helper_functions.template 1. Use https://s3.amazonaws.com/com.gilt.public.backoffice.{your-region-here}/cloudformation_templates/create_cloudformation_helper_functions.template
to deploy a stack that creates the Lambda functions for you. Remember the stack name. to deploy a stack that creates the Lambda functions for you. Remember the stack name.
2. Include the following resources in your CloudFormation template. These will create a) a nested stack that 2. Include the following resources in your CloudFormation template. These will create a) a nested stack that
looks up the ARNs from the previous step and b) a custom resource that allows your template to read those ARNs. looks up the ARNs from the previous step and b) a custom resource that allows your template to read those ARNs.
@ -21,7 +21,7 @@ general manner - much the same way CloudFormation itself has permission to do al
"CFHelperStack": { "CFHelperStack": {
"Type": "AWS::CloudFormation::Stack", "Type": "AWS::CloudFormation::Stack",
"Properties": { "Properties": {
"TemplateURL": "https://s3.amazonaws.com/com.gilt.public.backoffice/cloudformation_templates/lookup_stack_outputs.template" "TemplateURL": { "Fn:Join": [ "", ["https://s3.amazonaws.com/com.gilt.public.backoffice", { "Ref": "AWS:Region" }, "/cloudformation_templates/lookup_stack_outputs.template" ] ] }
} }
}, },
"CFHelper": { "CFHelper": {
@ -76,6 +76,13 @@ the data, when you tear down client stacks, you may have to manually delete some
helpers. helpers.
## A note on AWS Regions
At times, AWS can be touchy when it comes to referencing resources across regions. With that in mind, this
project is replicated to all regions - so you simply need to reference the version that lives in the S3
bucket that corresponds to the region you're working in. If there is a new region that is not part of the
ring of replications, please create an [issue](https://github.com/gilt/cloudformation-helpers/issues).
## Steps for adding a new included function ## Steps for adding a new included function
1. Find the file to edit. 1. Find the file to edit.
@ -340,7 +347,7 @@ SesCreateReceiptRuleFunctionArn
## Deployment (contributors) ## Deployment (contributors)
After making changes (i.e. adding a new helper function), please do the following: After making changes (i.e. adding a new helper function), please do the following:
1. Upload this zipped repo to the com.gilt.public.backoffice/lambda_functions bucket. To produce the .zip file: 1. Upload this zipped repo to the com.gilt.public.backoffice.us-east-1/lambda_functions bucket. To produce the .zip file:
``` ```
zip -r cloudformation-helpers.zip . -x *.git* -x *cloudformation-helpers.zip* zip -r cloudformation-helpers.zip . -x *.git* -x *cloudformation-helpers.zip*
@ -349,7 +356,7 @@ After making changes (i.e. adding a new helper function), please do the followin
Unfortunately we can't use the Github .zip file directly, because it zips the code into a subdirectory named after Unfortunately we can't use the Github .zip file directly, because it zips the code into a subdirectory named after
the repo; AWS Lambda then can't find the .js file containing the helper functions because it is not on the top-level. the repo; AWS Lambda then can't find the .js file containing the helper functions because it is not on the top-level.
2. Upload the edited create_cloudformation_helper_functions.template to com.gilt.public.backoffice/cloudformation_templates 2. Upload the edited create_cloudformation_helper_functions.template to com.gilt.public.backoffice.us-east-1/cloudformation_templates
## License ## License

View file

@ -93,7 +93,7 @@
"Type": "AWS::Lambda::Function", "Type": "AWS::Lambda::Function",
"Properties": { "Properties": {
"Code": { "Code": {
"S3Bucket": "com.gilt.public.backoffice", "S3Bucket": { "Fn::Join": [ ".", [ "com.gilt.public.backoffice", { "Ref" : "AWS::Region" } ] ] },
"S3Key": "lambda_functions/cloudformation-helpers.zip" "S3Key": "lambda_functions/cloudformation-helpers.zip"
}, },
"Description": "Used to create a full API in Api Gateway.", "Description": "Used to create a full API in Api Gateway.",
@ -148,7 +148,7 @@
"Type": "AWS::Lambda::Function", "Type": "AWS::Lambda::Function",
"Properties": { "Properties": {
"Code": { "Code": {
"S3Bucket": "com.gilt.public.backoffice", "S3Bucket": { "Fn::Join": [ ".", [ "com.gilt.public.backoffice", { "Ref" : "AWS::Region" } ] ] },
"S3Key": "lambda_functions/cloudformation-helpers.zip" "S3Key": "lambda_functions/cloudformation-helpers.zip"
}, },
"Description": "Used to populate a DynamoDB database from CloudFormation", "Description": "Used to populate a DynamoDB database from CloudFormation",
@ -204,7 +204,7 @@
"Type": "AWS::Lambda::Function", "Type": "AWS::Lambda::Function",
"Properties": { "Properties": {
"Code": { "Code": {
"S3Bucket": "com.gilt.public.backoffice", "S3Bucket": { "Fn::Join": [ ".", [ "com.gilt.public.backoffice", { "Ref" : "AWS::Region" } ] ] },
"S3Key": "lambda_functions/cloudformation-helpers.zip" "S3Key": "lambda_functions/cloudformation-helpers.zip"
}, },
"Description": "Used to populate a DynamoDB database from CloudFormation", "Description": "Used to populate a DynamoDB database from CloudFormation",
@ -260,7 +260,7 @@
"Type": "AWS::Lambda::Function", "Type": "AWS::Lambda::Function",
"Properties": { "Properties": {
"Code": { "Code": {
"S3Bucket": "com.gilt.public.backoffice", "S3Bucket": { "Fn::Join": [ ".", [ "com.gilt.public.backoffice", { "Ref" : "AWS::Region" } ] ] },
"S3Key": "lambda_functions/cloudformation-helpers.zip" "S3Key": "lambda_functions/cloudformation-helpers.zip"
}, },
"Description": "Used to create a Kinesis stream", "Description": "Used to create a Kinesis stream",
@ -316,7 +316,7 @@
"Type": "AWS::Lambda::Function", "Type": "AWS::Lambda::Function",
"Properties": { "Properties": {
"Code": { "Code": {
"S3Bucket": "com.gilt.public.backoffice", "S3Bucket": { "Fn::Join": [ ".", [ "com.gilt.public.backoffice", { "Ref" : "AWS::Region" } ] ] },
"S3Key": "lambda_functions/cloudformation-helpers.zip" "S3Key": "lambda_functions/cloudformation-helpers.zip"
}, },
"Description": "Used to put objects into S3.", "Description": "Used to put objects into S3.",
@ -427,7 +427,7 @@
"Type": "AWS::Lambda::Function", "Type": "AWS::Lambda::Function",
"Properties": { "Properties": {
"Code": { "Code": {
"S3Bucket": "com.gilt.public.backoffice", "S3Bucket": { "Fn::Join": [ ".", [ "com.gilt.public.backoffice", { "Ref" : "AWS::Region" } ] ] },
"S3Key": "lambda_functions/cloudformation-helpers.zip" "S3Key": "lambda_functions/cloudformation-helpers.zip"
}, },
"Description": "Used to subscribe to existing SNS topics.", "Description": "Used to subscribe to existing SNS topics.",