Atlantis is a powerful automation tool designed to streamline collaboration and code review workflows for Terraform infrastructure as code (IaC). It acts as a bridge between version control systems (VCS) like Git and Terraform, facilitating a smooth and efficient process for managing infrastructure changes
On this case, we deployed the Atlantis on Ubuntu VM
Install Terraform
wget https://releases.hashicorp.com/terraform/1.4.4/terraform_1.4.4_linux_amd64.zipunzip terraform_1.4.4_linux_amd64.zipsudo mv terraform /usr/local/bin/terraform
Install Atlantis
sudo apt install git -ywget https://github.com/runatlantis/atlantis/releases/download/v0.23.3/atlantis_linux_amd64.zipunzip atlantis_linux_amd64.zipsudo cp atlantis /usr/local/bin/
Create Personal Token


Create Service Account

Run the gcloud config command inside the Atlantis VM to set credential with service account
cloud_sandboxgcp_gmail_com@vm-atlantis-staging-1:~$ gcloud config set account 501066779977-compute@developer.gserviceaccount.comUpdated property [core/account].
Create Altantis directory to store the Atlantis configurations
mkdir -p /opt/terraform/atlantis-workdi
Create repos.yaml on /opt/terraform/atlantis-workdir
repos:# Allow a specific repo to override.- id: github.com/rohmattriindra/tf-infra-gcpallowed_overrides: [apply_requirements, workflow]allow_custom_workflows: trueapply_requirements: [approved]
Run the Atlantis server
atlantis server --atlantis-url=http://34.126.185.33 --gh-user=rohmattriindra --gh-token=ghp_VcOefm8MUwuoz3JU356yQtVDummy --gh-webhook-secret="0uNbW5pOBQfQvDummyDummyF" --repo-whitelist=github.com/rohmattriindra/tf-infra-gcp --data-dir=/opt/terraform/atlantis-workdir --repo-config=/opt/terraform/atlantis-workdir/repos.yaml
Create Atlantis.yml on the root directory, you can find sample on this repo https://github.com/rohmattriindra/tf-infra-gcp/blob/master/atlantis.yaml
version: 3automerge: trueprojects:# staging-networks- name: staging-networkdir: infrastructure/environments/staging/networkautoplan:enabled: truewhen_modified: ["../../../stack/network/*.tf*", "terraform.tfvars"]workspace: stagingworkflow: terraformapply_requirements: [mergeable]. # without this command when we puworkflows:terraform:plan:steps:- env:name: PROJECT_DIRcommand: echo $PROJECT_NAME | cut -d- -f2- run: |rm -rf .terraformterraform -chdir="../../../stacks/$PROJECT_DIR/" init -backend-config=prefix="$WORKSPACE/$PROJECT_DIR" --reconfigureterraform -chdir="../../../stacks/$PROJECT_DIR/" plan -var-file="../../environments/$WORKSPACE/$PROJECT_DIR/terraform.tfvars"apply:steps:- env:name: PROJECT_DIRcommand: echo $PROJECT_NAME | cut -d- -f2- run: |terraform -chdir="../../../stacks/$PROJECT_DIR/" init -backend-config=prefix="$WORKSPACE/$PROJECT_DIR" --reconfigureterraform -chdir="../../../stacks/$PROJECT_DIR/" apply --auto-approve -var-file="../../environments/$WORKSPACE/$PROJECT_DIR/terraform.tfvars"
This is a sample result of the change in firewall resources

