Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support AWS CLI profile name to override credentials #148

Closed
trevorr opened this issue May 7, 2022 · 1 comment
Closed

Support AWS CLI profile name to override credentials #148

trevorr opened this issue May 7, 2022 · 1 comment
Assignees

Comments

@trevorr
Copy link

trevorr commented May 7, 2022

Describe Request:

Add the ability to specify the AWS CLI profile name for each command, as is (mostly) done in the circleci/aws-ecr orb.

Background

Many projects start out with a single AWS account and put credentials for that account into AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in the CircleCI environment. In fact, many CircleCI examples assume this has been done. When it comes time to create separate AWS accounts (e.g. for development vs. staging vs. production), credentials for these accounts need to be added to the CircleCI environment. Typically, these credentials are selected in a given job using the setup command of the circleci/aws-cli orb, which creates a CLI profile. By default, the credentials go into the default profile, which the CLI will use automatically, but only if AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are not in the environment. Since removing those variables would break all existing workflows and jobs, having a way to explicitly specify the profile (even if it is "default") allows different credentials to be used alongside the original ones.

Examples:

jobs:
  deploy_service_update:
    description: Deploy service update to ECS
    parameters:
      aws-access-key-id:
        type: string
        default: STAGING_AWS_ACCESS_KEY_ID
      aws-secret-access-key:
        type: string
        default: STAGING_AWS_SECRET_ACCESS_KEY
      cluster-name:
        type: string
        default: staging-cluster
      image-tag:
        type: string
        default: ${CIRCLE_SHA1}
      service-name:
        type: string
    docker:
      - image: cimg/python:3.10.4
    steps:
      - aws-cli/setup:
          aws-access-key-id: << parameters.aws-access-key-id >>
          aws-secret-access-key: << parameters.aws-secret-access-key >>
          profile-name: default
      - aws-ecs/update-service:
          cluster-name: << parameters.cluster-name >>
          container-image-name-updates: container=<< pipeline.parameters.environment >>-<< parameters.service-name >>,tag=<< parameters.image-tag >>
          family: << pipeline.parameters.environment >>-<< parameters.service-name >>
          profile-name: default

Supporting Documentation Links:

@brivu
Copy link
Contributor

brivu commented May 20, 2022

This has been addressed in PR #153

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants