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::ForEach Issue - Unable to reference resources with logical IDs generated using the &{} syntax #162

Open
miguel-aws opened this issue Jan 6, 2025 · 0 comments

Comments

@miguel-aws
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Tell us about the bug

If you reference a resource that was created with the &{} syntax, the stack will fail with unresolved resource dependencies template format error:

Template format error: Unresolved resource dependencies [SNS&{TopicId}] in the Resources block of the template

Expected behavior

ForEach transform resolves the generated resource.

Observed behavior

ForEach transform does not resolve the referenced generated resource.

Test cases

Transform: 'AWS::LanguageExtensions'
Parameters:
  TopicIds:
    Type: CommaDelimitedList
    Default: us.anthropic.claude-3-5-sonnet-20241022-v2:0
Resources:
  'Fn::ForEach::Topics':
    - TopicId
    - !Ref TopicIds
    - 'SNS&{TopicId}':
        Type: "AWS::SNS::Topic"

      'ALARM&{TopicId}':
        Type: AWS::CloudWatch::Alarm
        Properties:
          ActionsEnabled: true
          OKActions:
            - !Ref
              'Fn::Sub': "SNS&{TopicId}"
          AlarmActions: 
            - !Ref
                'Fn::Sub': "SNS&{TopicId}"
          InsufficientDataActions: []
          MetricName: ModelMetric
          Namespace: CustomNamespace
          Statistic: Sum
          Dimensions:
            - Name: TopicId
              Value: !Ref TopicId
          Period: 10
          EvaluationPeriods: 1
          DatapointsToAlarm: 1
          Threshold: 0  
          ComparisonOperator: GreaterThanOrEqualToThreshold
          TreatMissingData: notBreaching

Additional context

Only workaround is not to use the &{} syntax and provide only alphanumeric identifiers:

Transform: 'AWS::LanguageExtensions'
Parameters:
  TopicIds:
    Type: CommaDelimitedList
    Default: usanthropicclaude353sonnet20241022v20
Resources:
  'Fn::ForEach::Topics':
    - TopicId
    - !Ref TopicIds
    - 'SNS${TopicId}':
        Type: "AWS::SNS::Topic"

      'ALARM${TopicId}':
        Type: AWS::CloudWatch::Alarm
        Properties:
          ActionsEnabled: true
          OKActions:
            - !Ref
              'Fn::Sub': "SNS${TopicId}"
          AlarmActions: 
            - !Ref
                'Fn::Sub': "SNS${TopicId}"
          InsufficientDataActions: []
          MetricName: ModelMetric
          Namespace: CustomNamespace
          Statistic: Sum
          Dimensions:
            - Name: TopicId
              Value: !Ref TopicId
          Period: 10
          EvaluationPeriods: 1
          DatapointsToAlarm: 1
          Threshold: 0  
          ComparisonOperator: GreaterThanOrEqualToThreshold
          TreatMissingData: notBreaching
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant