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

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

Closed
dinvlad opened this issue Nov 23, 2016 · 3 comments

Comments

@dinvlad
Copy link

dinvlad commented Nov 23, 2016

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.

@dinvlad
Copy link
Author

dinvlad commented Nov 23, 2016

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

@dinvlad dinvlad 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 Nov 23, 2016
@sanathkr
Copy link
Contributor

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

@sanathkr
Copy link
Contributor

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants