Create a terraform environment environment for db-benchmarking

Steps taken from: https://ops.gitlab.net/gitlab-com/gitlab-com-infrastructure#creating-a-new-environment

Part of https://gitlab.com/gitlab-com/gl-infra/infrastructure/-/issues/12113

  • Follow the instructions in environments/env-projects/README.md to create or import a GCP project: https://ops.gitlab.net/gitlab-com/gitlab-com-infrastructure/-/merge_requests/2245

  • In the production GitLab AWS account, create a new IAM user terraform-$ENV with programmatic access. Direct attach a new custom policy (named the same as the user) modeled on the existing terraform-$ENV users (basically s3:ListBucket for the gitlab-com-infrastructure bucket, and s3:* for gitlab-com-infrastructure/terraform/$ENV, but it is best to copy/paste/edit one of the existing policies, changing the path in the second stanza

  • Create a 1password entry "terraform-private/env_vars/$ENV.env" in the production vault. It should contain AWS IAM env var declarations for the credentials generated in the previous step.

  • In gitlab-com-infrastructure, run tf-get-secrets (it's in ./bin, which is always on $PATH in order to properly interact with this repo). The new env file should be downloaded. You should now be able to run tf init -upgrade in environments/$ENV and plan/apply.

  • Create CI env vars for the new environment:

    • Entries for each var in the private/env-vars file, including the AWS credentials.
    • A file entry with key GCLOUD_TERRAFORM_PRIVATE_KEY_JSON whose value is the contents of the private key file created for the terraform-ci user previously.
  • Add a section to .gitlab-ci.yml for the new environment. Look to existing entries for inspiration: https://ops.gitlab.net/gitlab-com/gitlab-com-infrastructure/-/merge_requests/2246

  • CI should now plan (and eventually apply) plans for the new environment.

Edited by Alejandro Rodríguez