Skip to content

Internal transform failure for StageName defined by reference in a SAM template #19

Closed

Description

@dinvlad

Hi, I'm trying to create a simple stack for SAM that references a Swagger file using this configuration:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31

Parameters:
  APIStage:
    Default: dev
    Description: Name of the API stage to use for deployment
    Type: String
    AllowedPattern: '[A-Za-z0-9-]*'

Resources:
  Api:
    Type: AWS::Serverless::Api
    Properties:
      StageName: !Ref APIStage
      DefinitionUri: models.yaml

However,

aws cloudformation package --template-file sam.yaml --output-template-file deploy.yaml --s3-bucket backend-dev-xxxx
aws cloudformation deploy --template-file deploy.yaml --stack-name backend-dev --capabilities CAPABILITY_IAM --parameter-overrides APIStage=dev

leads to

Failed to create the changeset: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: Transform AWS::Serverless-2016-10-31 failed with: Internal transform failure.

When I remove the Parameters section and set StageName: dev explicitly, the stack is created successfully. So it seems like Transform fails because of the APIStage reference, even though the template is validated successfully before CloudFormation calls Transform.

Activity

  1. dinvlad commented on Nov 23, 2016

    @dinvlad
    Author

    Update: I got a bit confused but now it seems clear that this issue is specific to how Transform processes referenced StageName for AWS::Serverless::Api rather than being a generic issue with processing referenced variables. For example, the following template was adopted from the HelloWorld example and appears to work correctly:

    AWSTemplateFormatVersion : '2010-09-09'
    Transform: AWS::Serverless-2016-10-31
    
    Parameters:
      APIStage:
        Default: dev
        Description: Name of the API stage to use for deployment
        Type: String
        AllowedPattern: '[A-Za-z0-9-]*'
    
    Resources:
      HelloWorldFunction:
        Type: AWS::Serverless::Function
        Properties:
          Handler: index.handler
          Runtime: nodejs4.3
          Environment:
            Variables:
              APIStage: !Ref APIStage
    
  2. changed the title [-]Internal transform failure for parameters referenced in a SAM template[/-] [+]Internal transform failure for StageName defined by reference in a SAM template[/+] on Nov 23, 2016
  3. sanathkr commented on Nov 23, 2016

    @sanathkr

    See #22. We don't support !Ref on the StageName parameter yet.

  4. sanathkr commented on Nov 23, 2016

    @sanathkr

    I am closing this issue in favor of tracking the problems thru #22 and #20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions