Assuming Subnets
is equivalent to [ eu-west-1a, eu-west-1b]
Resources:
EfsMountTargets:
# this assigns each item from Subnets to x while iterating
Map: {x: !Ref Subnets}
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref EFSVolume
SecurityGroups:
- !Ref EFSSecurityGroup
SubnetId: !Ref x
Outputs:
EfsMountIpAddress:
Map: {x: !Ref Subnets}
Description: !Sub "Ip Address for ${x}"
# this might be better without the !Sub, assuming !GetAtt/Ref knows to resolve that in the Map
Value: !GetAtt !Sub "EfsMountTargets.${x}.IpAddress"
This could be equivalent to
Resources:
# the part after the . can be anything; as long as the same input keeps the same resource name
# using the value as-is might help with linking mapped resources (see outputs)?
EfsMountTarget.eu-west-1a:
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref EFSVolume
SecurityGroups:
- !Ref EFSSecurityGroup
SubnetId: eu-west-1a
EfsMountTarget.eu-west-1b:
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: !Ref EFSVolume
SecurityGroups:
- !Ref EFSSecurityGroup
SubnetId: eu-west-1a
Outputs:
EfsMountIpAddress.eu-west-1a:
Description: Ip Address for eu-west-1a
Value: !GetAtt EfsMountTargets.eu-west-1a.IpAddress
EfsMountIpAddress.eu-west-1b:
Description: Ip Address for eu-west-1b
Value: !GetAtt EfsMountTargets.eu-west-1b.IpAddress
Note: I think a simple Fn::Map function would still be usefull, for places where the Property expects a list. Eg:
# with !Ref AZs being [a, b]
!Map:
- AZ: !Sub "${AWS::Region}${x}"
- x: !Ref AZs
would be equivalent to
- !Sub "${AWS::Region}a"
- !Sub "${AWS::Region}b"
More notes: if the behaviour of different lengths is well defined, this could also be useful:
# 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"