POSTGRES_PASSWORD- Database password used in Postgres containerWEATHERDB__PASSWORD- Password used to authenticate with Postgres container, should be the same asPOSTGRES_PASSWORD
./batect build
./batect test
./batect start-integration-test-db
- Google Cloud CLI
- Pulumi CLI
PULUMI_ACCESS_TOKEN- Access token used to authenticate with PulumiPOSTGRES_PASSWORD- Password used for postgres integration test containerIAM_GOOGLE_CREDENTIALS- JSON credentials for IAM service accountCI_GOOGLE_CREDENTIALS- JSON credentials for CI service account
- Fork repository
- Create new Google Cloud Project
-
gcloud projects create [project-name] gcloud config set project [project-name] - Link the new project to a billing account in the Google Cloud Console
-
- Create IAM service account
gcloud iam service-accounts create iam-svc
- Assign required roles to IAM service account
-
gcloud projects add-iam-policy-binding [project-name] --member "serviceAccount:iam-svc@[project-name].iam.gserviceaccount.com" --role "roles/iam.securityAdmin" gcloud projects add-iam-policy-binding [project-name] --member "serviceAccount:iam-svc@[project-name].iam.gserviceaccount.com" --role "roles/iam.serviceAccountAdmin" gcloud projects add-iam-policy-binding [project-name] --member "serviceAccount:iam-svc@[project-name].iam.gserviceaccount.com" --role "roles/serviceusage.serviceUsageAdmin" gcloud projects add-iam-policy-binding [project-name] --member "serviceAccount:iam-svc@[project-name].iam.gserviceaccount.com" --role "roles/secretmanager.admin"
-
- Generate keyfile for IAM service account
gcloud iam service-accounts keys create keyfile.json --iam-account iam-svc@[project-name].iam.gserviceaccount.com
- Set GitHub Action secrets
PULUMI_ACCESS_TOKEN- Set to your access token for your Pulumi accountPOSTGRES_PASSWORD- Choose a random password for the integration test databaseIAM_GOOGLE_CREDENTIALS- Set to the contents of the keyfile generated in the previous step- Remove the generated keyfile
- Commit a change to update the environment variables in
.github/workflows/main.ymlto match new project details - Commit a change to update the files in infra folder to match new project details
- Commit a change to update the
src/WeatherApi/appsettings.dev.jsonto match the database details - Run the GitHub actions workflow - it should fail at the Deploy Infra step failing to authenticate the newly created CI account
- Generate keyfile for CI service account
gcloud iam service-accounts keys create keyfile.json --iam-account ci-svc@[project-name].iam.gserviceaccount.com
- Set GitHub Action secrets
CI_GOOGLE_CREDENTIALS- Set to the contents of the keyfile generated in the previous step- Remove the generated keyfile
- Run the GitHub actions workflow - it should fail at the Migrate Database step failing to authenticate the newly created database instance
- Create a secret in GCP secret manager to store the database password
gcloud secrets versions add weather-api-db-password --data-file="dbpass.txt"
- Create a database user with the database password stored in secret manager
gcloud sql users create weather-api-user --instance=weather-api-db --password $(cat dbpass.txt)
- Run the GitHub actions workflow - it should now succeed