I'm trying to create a SecurityGroup which has a tag like Name: SG-StackName
. This code works perfect in json:
"Resources": {
"SecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
...
"Tags": [{
"Key": "Name",
"Value": {
"Fn::Join" : [ "", [
"SG-",
{ "Ref" : "AWS::StackName" }
]]
}
}
]
}
},
Now I'm trying to convert it to yaml:
Resources:
SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
...
Tags:
- Key: Name
- Value: !Join
- ''
- - 'SG-'
- Ref: AWS::StackName
The stack build fails with error "Key not found in Tags property". Where is the error in the template?
You have an extra '-' character in the Tags definition. It should look something like the snippet below (I'm not sure of the Join syntax, personally I use Sub normally):