Reputation: 4843
Trying to deploy a nested Cloudformation stack. Works fine if I hardcode the TemplateURL
as follows -
AWSTemplateFormatVersion: '2010-09-09'
Resources:
MyStack:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: https://s3.eu-west-1.amazonaws.com/my-bucket/my-template.yml
but as soon as I start to do any string substitution within TemplateURL
eg
AWSTemplateFormatVersion: '2010-09-09'
Resources:
MyStack:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub "https://s3.#{AWS::Region}.amazonaws.com/my-bucket/my-template.yml"
then on deployment I get -
AWS::CloudFormation::Stack | CREATE_FAILED | TemplateURL must be an Amazon S3 URL.
I have tried different flavours of !Sub
and Fn::Sub
, and with using custom defined variables rather than AWS::Region
, but always the same result :-/
What am I doing wrong here ?? TIA.
Upvotes: 1
Views: 1035
Reputation: 4482
You should use ${AWS::Region}
instead of #{AWS::Region}
(dollar sign instead of hashtag)
A string with variables that AWS CloudFormation substitutes with their associated values at runtime. Write variables as ${MyVarName} [...]
Source: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html
Upvotes: 5