Search code examples
amazon-web-servicesaws-copilot

Template format error: YAML not well-formed when customizing parameters


I have a environments/addons/template.yml


Parameters:
  App:
    Type: String
    Description: Your application's name.
  Env:
    Type: String
    Description: The environment name your service, job, or workflow is being deployed to.
  VpcId:
    Type: String
    Description: The ID of a VPC.
  PublicSubnetOne:
    Type: String
    Description: Public Subnet 1.
  PublicSubnetTwo:
    Type: String
    Description: Public Subnet 2.
  PrivateSubnetOne:
    Type: String
    Description: Private Subnet 1.
  PrivateSubnetTwo:
    Type: String
    Description: Private Subnet 2.

Resources:
  SGPostgresDb:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupName: my-pgdb-sg
      GroupDescription: Allows only postgres traffic
      VpcId: !Ref VpcId
      SecurityGroupIngress:
        - IpProtocol: tcp
          FromPort: 5432
          ToPort: 5432
          CidrIp: 0.0.0.0/0

  MyDbSubnetGroup:
    Type: AWS::RDS::DBSubnetGroup
    Properties: 
      DBSubnetGroupDescription: Subnets for database
      DBSubnetGroupName: my-db-subnets
      SubnetIds: 
        - PublicSubnetOne
        - PublicSubnetTwo
        - PrivateSubnetOne
        - PrivateSubnetTwo

and environments/addons/addons.parameters.yml

Parameters:
    VpcId: !Ref VPC
    PublicSubnetOne: !Ref PublicSubnet1
    PublicSubnetTwo: !Ref PublicSubnet2
    PrivateSubnetOne: !Ref PrivateSubnet1
    PrivateSubnetTwo: !Ref PrivateSubnet2

Then I run copilot env deploy and get the following error message:

Only found one environment, defaulting to: staging
✔ Proposing infrastructure changes for the myapp-staging environment.
✘ deploy environment staging: check if changeset is empty: create change set copilot-b87ea44e-32ae-4742-99ac-e8d2c65dc597 for stack myapp-staging: ValidationError: Template format error: YAML not well-formed. (line 1079, column 18) ...

But when I run with a single parameter like:

Parameters:
    VpcId: !Ref VPC

it works well. Any idea how to fix the error?


Solution

  • Which line is 1079?

    What version of Copilot are you on? This related bug fix went out in v1.26.0: https://github.com/aws/copilot-cli/pull/4402.