diff --git a/README.md b/README.md index a55684e..38dae39 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ general manner - much the same way CloudFormation itself has permission to do al ## 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. 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. @@ -21,7 +21,7 @@ general manner - much the same way CloudFormation itself has permission to do al "CFHelperStack": { "Type": "AWS::CloudFormation::Stack", "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": { @@ -76,6 +76,13 @@ the data, when you tear down client stacks, you may have to manually delete some 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 1. Find the file to edit. @@ -340,7 +347,7 @@ SesCreateReceiptRuleFunctionArn ## Deployment (contributors) 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* @@ -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 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 diff --git a/create_cloudformation_helper_functions.template b/create_cloudformation_helper_functions.template index 018aa39..82fb4f5 100644 --- a/create_cloudformation_helper_functions.template +++ b/create_cloudformation_helper_functions.template @@ -93,7 +93,7 @@ "Type": "AWS::Lambda::Function", "Properties": { "Code": { - "S3Bucket": "com.gilt.public.backoffice", + "S3Bucket": { "Fn::Join": [ ".", [ "com.gilt.public.backoffice", { "Ref" : "AWS::Region" } ] ] }, "S3Key": "lambda_functions/cloudformation-helpers.zip" }, "Description": "Used to create a full API in Api Gateway.", @@ -148,7 +148,7 @@ "Type": "AWS::Lambda::Function", "Properties": { "Code": { - "S3Bucket": "com.gilt.public.backoffice", + "S3Bucket": { "Fn::Join": [ ".", [ "com.gilt.public.backoffice", { "Ref" : "AWS::Region" } ] ] }, "S3Key": "lambda_functions/cloudformation-helpers.zip" }, "Description": "Used to populate a DynamoDB database from CloudFormation", @@ -204,7 +204,7 @@ "Type": "AWS::Lambda::Function", "Properties": { "Code": { - "S3Bucket": "com.gilt.public.backoffice", + "S3Bucket": { "Fn::Join": [ ".", [ "com.gilt.public.backoffice", { "Ref" : "AWS::Region" } ] ] }, "S3Key": "lambda_functions/cloudformation-helpers.zip" }, "Description": "Used to populate a DynamoDB database from CloudFormation", @@ -260,7 +260,7 @@ "Type": "AWS::Lambda::Function", "Properties": { "Code": { - "S3Bucket": "com.gilt.public.backoffice", + "S3Bucket": { "Fn::Join": [ ".", [ "com.gilt.public.backoffice", { "Ref" : "AWS::Region" } ] ] }, "S3Key": "lambda_functions/cloudformation-helpers.zip" }, "Description": "Used to create a Kinesis stream", @@ -316,7 +316,7 @@ "Type": "AWS::Lambda::Function", "Properties": { "Code": { - "S3Bucket": "com.gilt.public.backoffice", + "S3Bucket": { "Fn::Join": [ ".", [ "com.gilt.public.backoffice", { "Ref" : "AWS::Region" } ] ] }, "S3Key": "lambda_functions/cloudformation-helpers.zip" }, "Description": "Used to put objects into S3.", @@ -427,7 +427,7 @@ "Type": "AWS::Lambda::Function", "Properties": { "Code": { - "S3Bucket": "com.gilt.public.backoffice", + "S3Bucket": { "Fn::Join": [ ".", [ "com.gilt.public.backoffice", { "Ref" : "AWS::Region" } ] ] }, "S3Key": "lambda_functions/cloudformation-helpers.zip" }, "Description": "Used to subscribe to existing SNS topics.",