How to set AWS_REGION with orbs?

I am trying to use orbs for the first time. I’m trying to use the circleci aws-ecr and aws-ecs to build a docker image, upload it to ECR then deploy it to ECS.

I’ve reduced my config.yml to that ORB example for “build_and_push_image”. When I run it, the first thing it does is try to set the region with “aws configure”. Where in the circle-ci can I define the region?

Can I define it in the workflow? Can I make a job or executor and define it there? I’m guessing I can assign it in the project settings but I’d like to keep it as a variable.

I can’t find a working example of using the aws-ecr orb.

Any pointers?

Hi @luckyvalentine! In looking at the aws-ecr orb’s source:

region:
        default: AWS_REGION
        description: |
          Name of env var storing your AWS region information, defaults to AWS_REGION
        type: env_var_name

By default, CircleCI will use the credentials saved within the project environment variables or contexts settings. You can find AWS Orb examples here: https://circleci.com/docs/2.0/deployment-integrations/#aws-orb-examples.

You can then set the default region in your config.yml as follows:

workflows:
  build_and_push_image:
    jobs:
      - aws-ecr/build_and_push_image:
          account-url: AWS_ECR_ACCOUNT_URL_ENV_VAR_NAME
          aws-access-key-id: ACCESS_KEY_ID_ENV_VAR_NAME
          aws-secret-access-key: SECRET_ACCESS_KEY_ENV_VAR_NAME
          context: myContext #if you are using contexts
          region: AWS_REGION_ENV_VAR_NAME 
1 Like