Describe your question in as much detail as possible:
Hello, I am fairly new to CI/CD with gitlab and am having some trouble setting up multiple AWS Credentials (access keys) to be used in my pipelines. We have two AWS environments (prod, qa) with different access keys. We want to be able to use these two keys independent of each other depending on the current job that is running in the pipeline.
I am having a difficulty time finding a good resource to do just that; however, what I did find (and what I am going off of) is this
- What are you seeing, and how does that differ from what you expect to see?
What we get is an AWS error as shown below:
We are seeing this following error:
where it states it that “The config profile (qa) could not be found.”
We setup a CI/CD file variable within gitlab called AWS_SHARED_CREDENTIALS_FILE
This is what it looks like:
[production]
aws_access_key_id=prod_id
aws_secret_access_key=prod_key
aws_default_region=us-east-1
[qa]
aws_access_key_id=qa_id
aws_secret_access_key=qa_key
aws_default_region=us-east-1
Our gitlab-ci.yml file looks like this for qa publishing:
publish-job-qa:
stage: publish
only:
- develop
services:
- name: docker:dind
variables:
AWS_PROFILE: qa
before_script:
- apk add --no-cache curl jq python3 py3-pip
- pip install awscli
- aws ecr get-login-password | docker login --username AWS --password-stdin $DOCKER_REGISTRY_QA
- aws --version
- docker info
- docker --version
script:
- echo "Publishing to ECR $DOCKER_REGISTRY_QA"
- docker build -t $DOCKER_REGISTRY_QA:latest . -f Dockerfile
- docker push $DOCKER_REGISTRY_QA:latest
I have confirmed that the $DOCKER_REGISTRY_QA is correct
It would be great if I could get some insight on what I am doing wrong or any other tips on making this better (even if its not about my problem). Thanks!