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::Map intrinsic function #41
Comments
Agree that map is the way to go over loops. You should be able to prototype this as a transform, correct? That way, you could validate the notation on concrete examples. Question: could it be possible to collect attributes from all mapped resources into a list? For example, the following YAML expression: !GetAttr EfsMountTarget.IpAddress.IpAddress would become [ !GetAttr EfsMountTarget.eu-west-1a.IpAddress.IpAddress, !GetAttr EfsMountTarget.IpAddress.eu-west-1b.IpAddress ] |
@bjorg as long as you still have the list of things you're mapping, that should be possible. Assuming the syntax of
you could write that as
sidenote
|
Sometimes you need to map over an array where each element has more than one value. Maybe you need to map over an array of subnets that contains subnet IDs and AZs together. Each map iteration may need both of these values for different properties of the resource. Do you have a good idea of how to accomplish this? |
The idea was that the second parameter to # with !Ref AZs being [a, b]
!Map:
- AZ: !Sub "${AWS::Region}${x} - ${y}"
- x: !Ref AZs
y: [ one, two ] would be equivalent to - !Sub "${AWS::Region}a - one"
- !Sub "${AWS::Region}b - two" |
My suggestion would be to make the multi-prop capability explicit in the GH issue summary. Maybe as simple as making the examples multi-prop would work. It’s obvious in hindsight, but wasn’t on my first read! |
Resource Name
No response
Details
A lot of complaints about CloudFormation verbosity are things like having to replicate subnets for each availability zone. An
Fn::Map
function, which allowed basic parameterization of resources or properties, would allow for concise, semantically-meaningful expression of duplication.A twitter thread on this topic
An example from here
This could be equivalent to
The above assumes that
Map
was a first-class property of resources, for convenience. The general-purpose intrinsic function could look like this, including the ability to zip multiple lists together:would be equivalent to
The text was updated successfully, but these errors were encountered: