Relative Content

Tag Archive for amazon-web-servicesaws-cloudformation

AWS Cloudformation Template – How to Import Values and Sub for ALB Target Group

I am creating an ALB via Cloudformation Template. One of the resources being created is a target group that will use EC2 instance ID’s that were exported during a previous job. I need to import the values and sub the import name to reflect different environment deployments. Running the cfn-lint tool, this is a correct template:

AWS Cloudfromation Fn::ForEach does not accept values from Mappings

Below is my Resources Section in CFN template. I want to create AWS Route53 Record Sets but the problem is that I need to hard code the number for iterations for the forEach as can be seen below under RecordSetLogicalId. I want those to come from the Mappings section of the CFN template so that I can create unequal number of record sets in different AWS Accounts. For example 3 in Dev and 5 in Prod. When I try to use FindInMap or Split functions, I get a cfn linting error ‘[cfn-lint] E0001: Error transforming template: Fn::ForEach values must be a list of 3 elements’