bazaarvoice / cloudformation-ruby-dsl

Ruby DSL for creating Cloudformation templates
Apache License 2.0
210 stars 76 forks source link

Use AWS::Region to look up the stack's region. #119

Closed Noirbot closed 7 years ago

Noirbot commented 7 years ago

Description

The aws_region() function behaves differently than most of the other aws_ functions, in that it isn't a passthrough to a ref(AWS::KEY) CloudFormation variable, and instead uses the default region of the computer compiling the template.

This can cause unexpected behavior in circumstances when you want to deploy a template to a region other than the device's default. Using the AWS::Region value is more reliable, as it allows the region to be determined when the stack is deployed, instead of having to re-expand the template for each region.

Steps to Test or Reproduce

Expanding a template now will cause aws_region to substitute in with the value of the computer's default AWS Region. With this change, you should see it compile to a Ref to AWS::Region.

Deploy Notes

This is hypothetically a breaking change, but I'm not sure why someone would be relying on the current behavior to resolve aws_region to a different value than the value at deploy time in AWS::Region, so it should be fairly safe.

Related Issues and PRs

Todos

Request to Review

@jonaf/@temujin9

Noirbot commented 7 years ago

If anything, this brings aws_region in line with our documentation, and in line with how the cfntemplate-to-ruby script does things.

https://github.com/bazaarvoice/cloudformation-ruby-dsl/blob/master/bin/cfntemplate-to-ruby#L328

jonaf commented 7 years ago

Please see #20 for some background on why aws_region() behaves the way it does.