Skip to content Skip to footer

Gitlab to AWS

Been reviewing my gitlab notes. Just quick documentation blurb on interacting with AWS while using gitlab

There is a an AWS cli docker image at https://hub.docker.com/r/amazon/aws-cli

To use  just specify it as the image to use in the .gitlab-ci.yaml

				
					
deploy:
    stage: deploy
    image:
        name: amazon/aws-cli
        entrypoint: [""]

				
			

By clearing the entry point, you can use the image as a linux image with CLI installed 

And as usual you can store the access keys  via gitlab under the project settings under settings > CI/CD > Variables

And so you can use the cli in any task. With the finishing  job something like  below.

				
					
deploy:
  stage: deploy
  image:
    name: amazon/aws-cli
    entrypoint: [""]
  before_script:
    - yum -y install jq
  script:
    - aws configure set region ap-southeast-1
    - aws s3 cp ./build/libs/$ARTIFACT_NAME s3://$S3_BUCKET/$ARTIFACT_NAME

				
			

Hope This helps someone

Helping buidling!

Leave a comment