Uploaded image for project: 'Bitbucket Cloud'
  1. Bitbucket Cloud
  2. BCLOUD-22913

atlassian/aws-ecs-deploy returns unbound variable error

XMLWordPrintable

      Issue Summary

      While using atlassian/aws-ecs-deploy in the Pipeline step with AWS_OIDC_ROLE_ARN and AWS_DEFAULT_REGION and without specifying the any value for the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY variables, it returns the following error:

      bash: <variable name>: unbound variable 

      Steps to Reproduce

      1. Define the following variables and assign values to them (Workspace/Repository/Deployment) in the Pipeline 
        1. AWS_DEFAULT_REGION
        2. AWS_OIDC_ROLE_ARN
      2. Use the following script in the Pipeline
        pipelines:
          default:
              - step:
                  name: Test
                  oidc: true
                  script:
                    - set -eou pipefail
                    - pipe: atlassian/aws-ecs-deploy:1.9.0
                      variables:
                       AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION}
                       AWS_OIDC_ROLE_ARN: ${AWS_ROLE_ARN}
                       CLUSTER_NAME: ${CLUSTER_NAME}
                       SERVICE_NAME: ${BITBUCKET_REPO_SLUG}
                       TASK_DEFINITION: scripts/ecs/${BITBUCKET_REPO_SLUG}-task-def.json
                       FORCE_NEW_DEPLOYMENT: 'true'
        
      3. Since the set -eou pipefail command has -u option set, it expects all the variables to have the default values

      Expected Results

      The Pipeline should be successful without any issues

      Actual Results

      Since the following variables doesn't have any default value set in the Pipeline, it return with the error:

      1. AWS_ACCESS_KEY_ID
      2. AWS_SECRET_ACCESS_KEY

      Workaround

      Specify empty as the default value for the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in the Pipe definition

      pipelines:
        default:
            - step:
                name: Test
                oidc: true
                script:
                  - set -eou pipefail
                  - pipe: atlassian/aws-ecs-deploy:1.9.0
                    variables:
                     AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION}
                     AWS_OIDC_ROLE_ARN: ${AWS_ROLE_ARN}
                     CLUSTER_NAME: ${CLUSTER_NAME}
                     SERVICE_NAME: ${BITBUCKET_REPO_SLUG}
                     TASK_DEFINITION: scripts/ecs/${BITBUCKET_REPO_SLUG}-task-def.json
                     FORCE_NEW_DEPLOYMENT: 'true'
                     AWS_ACCESS_KEY_ID: ''
                     AWS_SECRET_ACCESS_KEY: ''
      

              Unassigned Unassigned
              skhandelwal@atlassian.com Sandeep K
              Votes:
              7 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: