Skip to content

Create AWS access key and set it as ENV variable

With #263468 implemented.

I want GitLab to automatically create IAM user and create a new access key. Then I want GitLab to set CI/CD variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY with it. So my project is ready to work with AWS.

Basically I want GitLab to do steps 2-4 from https://gitlab.com/gitlab-org/gitlab/-/blob/02c62d898aa004951bae5ab0fba3f492266006cf/doc/ci/cloud_deployment/index.md#run-aws-commands-from-gitlab-cicd for me.

Proposal

Create a new docker file to be stored in https://gitlab.com/gitlab-org/cloud-deploy/-/tree/master/aws

The docker file should call upon the AWS CLI docker and from there run a script that does the following

  • Check the existence of an IAM user (We can also assume one exists based on environment variables, if it does not exist we can create a default IAM role)
  • If no IAM user exists create one by:

aws iam create-user --user-name Bob

Where Bob should be a variable. We should suggest a default value, if the user name is not given by the user for example gitlab_iam_user

Further details

Synopsis

 create-user
[--path <value>]
--user-name <value>
[--permissions-boundary <value>]
[--tags <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]

Links

Edited by Orit Golowinski