Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fn::ImportValue] - [Enhancement] - Fn::ImportValue returns String when CommaDelimitedList needed for Fn::ForEach collection #2239

Open
LUKEALDRED opened this issue Jan 17, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@LUKEALDRED
Copy link

Name of the resource

Other

Resource name

Fn::ImportValue

Description

I've happened upon an issue where I need a collection for the Fn::ForEach function. I've attempted to use Fn::ImportValue to bring in a list of items for the collection but Fn::ImportValue is returning a String rather than a CommaDelimitedList.

A bit more detail:

I've got a CloudFormation stack that creates an ElastiCache Replication Group. The number of nodes created depends on the number of Availability Zones selected by the user. I have an Output that lists the reader endpoints. If the user selects 1 Availability Zone the output provides 1 reader endpoint. If the user selects 2 Availability Zones the output provides 2 reader endpoints and so on.

Example:
1 AZ
[test-001-replication-group-001.xxxxxx.0001.euw2.cache.amazonaws.com]

2 AZs
[prod-001-replication-group-001.xxxxxx.0001.euw2.cache.amazonaws.com, prod-001-replication-group-002.xxxxxx.0001.euw2.cache.amazonaws.com]

I was hoping to use this output from my ElastiCache CloudFormation stack so that I could the create a CloudWatch alarm for each node using Fn::ForEach. I couldn't work out why I kept getting 'Transform AWS::LanguageExtensions failed with: Could not find a collection or could not be resolved for Fn::ForEach'. AWS support were able to advise me that Fn::ImportValue is returning a String, not a list as I was hoping.

I'd like to be able to use a CloudFormation Output as a list. For now I'm just using a Parameter of type CommaDelimitedList in my CloudWatch CloudFormation template and providing a list of ElastiCache Reader Endpoints manually.

Other Details

I'm aware that when using Fn::GetAtt: ElastiCacheRedisReplicationGroup.ReadEndPoint.Addresses for the Output the value is enclosed in square brackets. I've been using a combination of Fn::Split and Fn::Select to get around this.

@LUKEALDRED LUKEALDRED added the enhancement New feature or request label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant