Is it possible to get a resource's logical ID inside itself like we do with "Ref" : "logicalName"
. I just want to get the resource logical id (here Instance1) in its own properties section dynamically. Till now i have to hard code resource name.
{
"AWSTemplateFormatVersion": "2010-09-09",
"Mappings": {
"Para" : {
"Layer" : { "Instance1" : "Testing", "Instance2" : "Staging", "Instance3" : "Production" }
}
},
"Resources": {
"Instance1": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId": "ami-5fb8c835",
"Tags": [
{ "Key": "Name", "Value": { "Fn::FindInMap" : [ "Para", "Name", "Instance1" ]} }
]
}
},
"Instance2": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId": "ami-5fb8c835",
"Tags": [
{ "Key": "Name", "Value": { "Fn::FindInMap" : [ "Para", "Name", "Instance2" ]} }
]
}
}
}
I just want to get resource name (eg Instance1 or instance 2) in key, value tag lines.
It is not possible to retrieve the logical name itself within a custom tag, but CloudFormation does automatically tag every Instance with an aws:cloudformation:logical-id
tag.
In addition to any tags you define, AWS CloudFormation automatically creates the following stack-level tags with the prefix aws::
- aws:cloudformation:logical-id
- aws:cloudformation:stack-id
- aws:cloudformation:stack-name
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With