Google Tag Manager Server Side (AWS — Terraform)

nhammad
Women in Technology
2 min readFeb 25, 2024

--

GTM

While we have plenty of tutorials guiding on how to deploy GTM server side, I didn’t come across any resources that also helped with the Terraform setup. Hence, I decided to compile a guide myself.

I followed the architecture proposed by AWS itself and translated it into Terraform code. The easiest way to setup GTM is to utilise an AWS ECS cluster with ECS services.

DNS Settings

The first step is to create 2 domain names (primary and preview). Then, we request an SSL certificate and add the CNAME name and value to the domain records. The settings here might differ depending on your current domain or hosted zones setup.

IAM Roles

AWS ECS task definitions use two roles: task role and execution task role. Here, we would require access permissions to ECS, SSM, and Cloudwatch.

--

--