Search code examples
amazon-web-servicestemplatesaws-cloudformationsam

The parameter is not applied in the sam template


First of all, I ask for your patience that I am not familiar with English.

I am trying to deploy a serverless app through AWS' Codepipiline feature. However, in the codebuild stage, the sam template does not work properly. Below are some of my templates.

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
  filename:
    Type: String
    Default: test
Description: !Ref filename

Obviously, despite the declaration of the filename parameter, I get the following error:

Template format error: Every Description member must be a string.

And the template applied to the stack is as follows.

Description:
  Fn::Ref: filename

But what I want is the following output.

Description: test

There is also a problem with the sam deploy parameter "--paramater-overrides", but this doesn't work, so there's no progress.


Solution

  • If you look at the AWS SAM Template Anatomy, you will find that:

    Description (optional) This section corresponds directly with the Description section of AWS CloudFormation templates.

    Parameters (optional) This section corresponds directly with the Parameters section of AWS CloudFormation templates.

    Subsequently, you can't reference a parameter in a Description. This is because:

    You can reference parameters from the Resources and Outputs sections of the same template.