Skip to content

Cloudformation Fn::Each logic is throwing error: Fragment returned by transform AWS::LanguageExtensions is null

0

Below code throwing error Fragment returned by transform AWS::LanguageExtensions is null. Not sure what I'm missing.

AWSTemplateFormatVersion : '2010-09-09'
Transform: 'AWS::LanguageExtensions'

Parameters:
  ListOfNeptuneCluster:
    Type: CommaDelimitedList
    Default: cluster:test1,cluster:test2
Resources:
    Fn::ForEach::ScalableTargets:
    - NeptuneCluster
    - !Ref ListOfNeptuneCluster
    - ScalableTarget${NeptuneCluster}:
        Type: AWS::ApplicationAutoScaling::ScalableTarget
        Properties:
          MaxCapacity: 1
          MinCapacity: 1
          ResourceId: !Ref NeptuneCluster
          RoleARN: <role-arn>
          ScalableDimension: neptune:cluster:ReadReplicaCount
          ServiceNamespace: neptune

asked 2 years ago770 views

1 Answer
2

If you have colons : in the replacement value used as the logical ID of the resource, you should use the syntax &{variable} instead of ${variable} to reference it. That will deal properly with non-alphanumeric characters: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-foreach.html#intrinsic-function-reference-foreach-parameters

Resources:
  Fn::ForEach::ScalableTargets:
    - NeptuneCluster
    - !Ref ListOfNeptuneCluster
    - ScalableTarget&{NeptuneCluster}:
        Type: AWS::ApplicationAutoScaling::ScalableTarget
        Properties:
          MaxCapacity: 1
          MinCapacity: 1
          ResourceId: !Ref NeptuneCluster
          RoleARN: <role-arn>
          ScalableDimension: neptune:cluster:ReadReplicaCount
          ServiceNamespace: neptune
EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

  • This answer is super useful! Thank you Leo K

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.