I want to create CFT using terraform template_file by loping based on a list variable(email_addresses). Below are the variables and template I am trying to generate.
variables:-
emails_addresses = ["sample-1@gmail.com", "sample-2@gmail.com"]
sns_arn = "arn:aws:sns:us-east-1:xxxxxx:xxxx"
protocol = "email"
Expecting template:
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"sample-1": {
"Type": "AWS::SNS::Subscription",
"Properties": {
"Endpoint": "sample-1@gmail.com",
"Protocol": "email",
"TopicArn": "arn:aws:sns:us-east-1:xxxx:xxxxx"
}
},
"sample-2": {
"Type": "AWS::SNS::Subscription",
"Properties": {
"Endpoint": "sample-2@gmil.com",
"Protocol": "email",
"TopicArn": "arn:aws:sns:us-east-1:xxx:xxxx"
}
}
}
}
The resource name in CFT can be some random string but it should be the same per mail in case of multiple plans/apply.