serverless-application-model: LanguageExtensions and Serverless-2016-10-31 conflicts

Description

In my SAM template I’m deploying a dynamo table and api gateway mappings along with normal things like lambdas and the api gateway itself.

The AWS::ApiGateway::BasePathMapping depends on the resApiGatewayStage which is created during the transform. So by the end of the transform when it goes to validate the template it’s all good.

When I add in a DeletionPolicy on the AWS::DynamoDB::Table to set it to Retain for prod and add AWS::LanguageExtensions to the top of the transforms I get an error.

What I believe is happening is that after AWS::LanguageExtensions is done transforming things it validates the template but because I have a reference to resApiGatewayStage which doesn’t exist (yet) then it fails.

  resAPIBasePathMapping:
    Type: AWS::ApiGateway::BasePathMapping
    Condition: conditionBuildBasePath
    DependsOn: resApiGatewayStage
    Properties:
      BasePath: !If
        - conditionNotFeatureBranch
        - !Sub "${paramServiceName}"
        - !Sub "${paramServiceName}-${paramFeatureBranch}"
      DomainName:
        Fn::ImportValue: !Sub export-environment-domain-${paramEnvironment}
      RestApiId: !Ref resApiGateway
      Stage: !Ref paramEnvironment

Steps to reproduce

Have a template which has

  1. a resource with a deletion policy with an intrisnic function.
  2. a resource which depends on resources created during the SAM transformation.
Conditions:
  conditionIsProd: !Equals [!Ref paramEnvironment, prod]

  DynamoTable:
    Type: AWS::DynamoDB::Table
    # DeletionPolicy: "Retain"
    DeletionPolicy: !If
      - conditionIsProd
      - Retain
      - Delete

Observed result

Change set created fails with

Template format error: Unresolved resource dependencies [resApiGatewayStage] in the Resources block of the template

Expected result

Successful deployment

Additional environment details

WSL2, Ubuntu Ubuntu MacOSX

SAM CLI, version 1.66.0
  1. OS:
  2. If using the SAM CLI, sam --version:
  3. AWS region:

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (9 by maintainers)

Most upvoted comments

Hi there, thanks for reporting this issue. I’ll take a look at this problem and get back to you.