Setup AWS service accounts for terraform CI
Overview
While setting up the CI pipeline in gitlab-com/gl-infra/gitter-infrastructure!94 we started receiving permissions errors during tf_plan jobs. The pipeline had been previously setup to use the packer service account, and permissions were temporarily added to enable access to the remote state resources for planning. Going forward, we need to configure at least four other service accounts, or two accounts with two roles each:
Remote-state
-
Create terraform-remote-state IAM account -
Add credentials to 1password -
Add CI variables -
Update .gitlab-ci.ymlwith credentials fortf_*_remote_statejobs -
Attach terraform-remote-state IAM policy for terraform plan(Copy privileges underDynamoDB,S3, andKMSservices fromPackerpolicy) -
Remove DynamoDB,S3, &KMSprivileges fromPackerIAM policy
Beta
-
Create terraform-beta IAM account -
Add credentials to 1password -
Add CI variables -
Update .gitlab-ci.ymlwithtf_*_betajobs and credentials -
Create terraform-beta-ro IAM role (read-only, for terraform plan), pass role ARN by variable -
Create terraform-beta-priv IAM role (admin privs, for terraform apply), pass role ARN by variable
Prod
-
Setup terraform-prod IAM account -
Add credentials to 1password -
Add CI variables -
Update .gitlab-ci.ymlwithtf_*_prodjobs and credentials -
Create terraform-prod-ro IAM role (read-only, for terraform plan), pass role ARN by variable -
Create terraform-prod-priv IAM role (admin privs, for terraform apply), pass role ARN by variable