aws / copilot-cli

The AWS Copilot CLI is a tool for developers to build, release and operate production ready containerized applications on AWS App Runner or Amazon ECS on AWS Fargate.
https://aws.github.io/copilot-cli/
Apache License 2.0
3.48k stars 400 forks source link

unmarshal "variables": cannot unmarshal field to a string or into a map #5288

Closed dickensdjj closed 1 year ago

dickensdjj commented 1 year ago

Context

Repo: BitBucket Secrets: AWS Secret Manager CICD Pipeline: BitBucket Pipeline Local: MacOS Local Copilot Version(copilot-darwin): 1.28.0 Bitbucket Runner: atlassian/default-image (Ubuntu 22.0.4) Runner Copilot Version(copilot-linux): 1.30.1

I am deploying a Load Balanced Web Service to the ECS cluster with Fargate via AWS copilot CLI. I am NOT using the AWS Copilot Pipeline as my CICD Pipeline because I would like to manage it via BitBucket.

Issue

The BitBucket pipeline cannot deploy the svc due to the error shown below Error: unmarshal service xxx manifest: unmarshal manifest for Load Balanced Web Service: unmarshal "variables": cannot unmarshal field to a string or into a map

This is my manifest.yml

type: Load Balanced Web Service

# ALB configuration
http:
  path: '/'
  healthcheck:
    path: '/cicd_healthcheck'
    success_codes: '200'
    healthy_threshold: 3
    unhealthy_threshold: 2
    grace_period: 120s

image:
  build: app/Dockerfile
  port: 80

cpu: 2048
memory: 4096
exec: true
count: 1
deployment:
  rolling: 'default'
network:
  connect: true

variables:
  GC_EMAIL_SUBJECT: "xxx"
  GC_EMAIL_FROM_NAME: "xxx"
  GC_EMAIL_FROM_EMAIL: "xxx"

  ALERT_EMAIL_FROM_NAME: "xxx"
  ALERT_EMAIL_FROM_EMAIL: "xxx"
  PORT: "xxx"

This is my bitbucket.yml

image: atlassian/default-image:latest
options:
  docker: true

pipelines:
  branches:
    develop:
      - step:
          name: project image build, publish and deploy
          deployment: Staging
          size: 4x
          runs-on:
            - self.hosted
            - linux
          script:
            - echo "🚀🚀🚀Deploying to Staging ECS Cluster..."
            - curl -Lo aws-copilot https://github.com/aws/copilot-cli/releases/latest/download/copilot-linux
            - chmod +x aws-copilot
            - ./aws-copilot -v
            - ./aws-copilot svc deploy --app xxx --env staging --name xxx

Reference:

  1. bitbucket pipeline failed Screenshot 2023-09-07 at 2 17 51 pm
iamhopaul123 commented 1 year ago

Hello @dickensdjj. I am not able to reproduce the problem. If you upgrade your local Copilot version to v1.30.1 can you deploy successfully? My guess is the CICD for some reason picked up a different manifest (maybe you have different manifests in different branches?) 🤔

dickensdjj commented 1 year ago

Issue found. There is one variable that I am using and this is working perfectly in my local environment, which is MacOS "[\"test1@test.com\",\"test2@test.com\"]"

When the pipeline picks up the manifest.yml by using the Atlassian/default-image:latest, this ☝️ value will not be parsed by the YAML reader. Instead, I have to use this "['test1@test.com','test1@test.com']"

Not sure if @iamhopaul123 can reproduce this but it looks like it is the platform compatibility issue from my guess.