-
Notifications
You must be signed in to change notification settings - Fork 33
How To Rotate Jenkins IAM Credentials
This runbook describes how to rotate the IAM access keys for the Jenkins mgmt service account.
This runbook is intended for use by team members that are both familiar with Terraform, Jenkins, and AWS CLI and have the appropriate permissions to perform the actions described below.
- CMS VPN access
- AWS CLI
- Terraform
- Jenkins admin privileges
-
Move to the
ops/terraform
directory in thebeneficiary-fhir-data
repository. -
Run
tfswitch
ortfenv
to ensure you are using the correct version of Terraform. -
Move to the
ops/terraform/env/mgmt
directory. -
Run
terraform init
to initialize the Terraform state if you have not already done so. -
Run
terraform plan
to ensure the state is clean and there are no changes to be applied. If the state is not clean, you may need to target the related resources (see example in step 7). -
Taint the access key resource so a new one will be created when the terraform is applied.
terraform taint aws_iam_access_key.jenkins_user
-
Apply the terraform:
# If the terraform state is clean terraform apply # If the terraform state is not clean, target the access key resource: terraform apply \ -target="aws_iam_access_key.jenkins_user_key" \ -target="aws_ssm_parameter.jenkins_user_key_id" \ -target="aws_ssm_parameter.jenkins_user_key_secret"
-
Once the terraform has been applied, you will need to manually update the credentials in jenkins. This can be done either via the AWS console or the AWS CLI (cli instructions below):
-
Open the jenkins credentials page and click 'Update' in the left sidebar.
-
Update the
Access Key ID
andSecret Access Key
fields with the new values. To copy (one at a time) the values to clipboard, run the following commands (macOS only, others should remove the| pbcopy
to print to stdout instead)# get the access key id aws ssm get-parameter --name /bfd/mgmt/common/sensitive/user/bfd-mgmt-jenkins/aws_access_id --with-decryption --query "Parameter.Value" --output text | pbcopy # get the access key secret aws ssm get-parameter --name /bfd/mgmt/common/sensitive/user/bfd-mgmt-jenkins/aws_secret_key --with-decryption --query "Parameter.Value" --output text | pbcopy
-
Click
Save
when done!
-
- Home
- For BFD Users
- Making Requests to BFD
- API Changelog
- Migrating to V2 FAQ
- Synthetic and Synthea Data
- BFD SAMHSA Filtering