This Terraform script deploys the serverside Google Tag Manager on Cloud Run within the Google Cloud Platform with various extra features like automated updates and an alerting policy.
- Uptime Check with Notifications - You will be notified if there is an outage of your SGTM services
- Docker Image Auto Updates - The SGTM Docker image will be updated automatically once per week (default)
- Log Exculusion - Logs with the serverity default or notice will be excluded to reduce costs
- Optional basic load balancer setup enabled via setting use_load_balancer variable to true.
- The Load balancer contains the Geolocation headers described here and the additonal ones neccesary for sending geolocation data to GA4 described here All possible headers are listed here
- Clone this repository and make sure you have installed Terraform.
- Authenticate with Application Default Credentials - Setup Application Default Credentials.
- Change the variables inside terraform.tfvars.example to suit your needs and rename the file to terraform.tfvars. Make sure you have created the SGTM Container already to retrieve the container config.
- Run
terraform init
to initialize the repository andterraform apply
the infrastructure will be built on GCP
- Use This link to the Cloud Shell
- If you want the Cloud Shell Instance to not be persistant use this link: non-persistant Cloud Shell.
- Trust the Repo and Confirm when prompted.
- Wait till Cloud Shell has completed loading. You should see the terraform.tfvars File.
- Run
bash run_this.sh
- Click Authorize when asked to Authorize Cloud Shell.
- Hit
1
to initialize with new settings - Hit
1
to sign in or sign in manually to the Google Account you want to use. - Enter the project ID, create a new project or choose from the list of projects the one you want to use.
- Hit
y
to proceed. This Cloud Shell Instance is Ephemeral, it destroys itself after 20 Minutes of inactivity. - Click the Link that is shown, choose the desired Google Account, sign in to Google Auth Library and grant access.
- Click the
Copy
Button and paste to Google Cloud Shell. - You should now see something like this:
YOUR_NAME@cloudshell:~/cloudshell_open/terraform_cloud_run_sgtm (YOUR_PROJECT_ID)$
- Change the variables inside terraform.tfvars to suit your needs. Make sure you have created the SGTM Container already to retrieve the container config.
- Run
terraform apply
the infrastructure will be built on GCP.
Check this repo for detailed documentation about the sGTM updater Cloud Function repository.