Study guide

8.4 Third-Party Automation with Terraform & Git Workflows

AWS Certified CloudOps Engineer – Associate SOA-C03

Track your progress as you read

Finished sections get a check mark.

1 Chapter 1: Monitoring & Observability Infrastructure

1.1 Configuring Workload Observability 1.2 CloudWatch Agent Architecture & Deployment 1.3 Metric Alarms, Anomaly Detection & Composite Alarms

2 Chapter 2: Alarms, Dashboards & Event-Driven Remediation

2.1 CloudWatch Dashboards & Multi-Account Visibility 2.2 Notification Architecture & Alarm Invocation 2.3 Amazon EventBridge Rules, Event Buses & Troubleshooting 2.4 Automated Remediation with Systems Manager & Lambda

3 Chapter 3: Performance Optimization for Compute, Storage & Databases

3.1 EC2 & Compute Performance Optimization 3.2 Amazon EBS Performance Metrics & Volume Tuning 3.3 S3 Performance Strategies & Data Transfer 3.4 Shared Storage (EFS/FSx) & Database Performance

4 Chapter 4: Compute & Database Scalability and Elasticity

4.1 EC2 Auto Scaling Policies & Elasticity 4.2 Auto Scaling Advanced Operations: Warm Pools & Lifecycle Hooks 4.3 Dynamic Scalability Through Caching 4.4 Managed Database Scaling: RDS, Aurora & DynamoDB

5 Chapter 5: High Availability, Fault Tolerance & Load Balancing

5.1 Elastic Load Balancing (ALB/NLB) Configuration & Troubleshooting 5.2 Route 53 Health Checks & DNS Failover 5.3 Multi-AZ Architecture & Fault-Tolerant Deployments

6 Chapter 6: Backup, Data Protection & Disaster Recovery

6.1 Centralized Backup Automation & AWS Backup 6.2 Database Restore Strategies & RTO/RPO Management 6.3 Storage Versioning, Replication & Immutability 6.4 Disaster Recovery Patterns & Multi-Region Resilience

7 Chapter 7: Infrastructure as Code with CloudFormation & AWS CDK

7.1 CloudFormation Foundations & Resource Modeling 7.2 Managing Stacks, Drift Detection & Change Sets 7.3 Infrastructure as Code with AWS CDK 7.4 Identifying & Remediating Deployment Failures

8 Chapter 8: Multi-Account Provisioning, Containers & Third-Party IaC

8.1 Golden Images with EC2 Image Builder & Amazon ECR 8.2 Multi-Account & Multi-Region Resource Sharing 8.3 Deployment Strategies & Container Deployments 8.4 Third-Party Automation with Terraform & Git Workflows

9 Chapter 9: Systems Manager & Event-Driven Operations Automation

9.1 AWS Systems Manager Core Management & Run Command 9.2 Systems Manager Patch Manager & Session Manager 9.3 Event-Driven Operations Automation

10 Chapter 10: Identity, Access Management & Governance

10.1 Advanced IAM Policies, Roles & Policy Conditions 10.2 Auditing Access with CloudTrail Lake & IAM Access Analyzer 10.3 Multi-Account Security: Organizations, SCPs & Identity Center 10.4 Compliance Enforcement with AWS Config & Conformance Packs

11 Chapter 11: Data Security, Encryption & Vulnerability Management

11.1 Data Classification & Amazon S3 Security 11.2 Encryption at Rest with AWS Key Management Service (KMS) 11.3 Encryption in Transit with AWS Certificate Manager (ACM) 11.4 Secrets Management & Centralized Security Findings

12 Chapter 12: VPC Architecture, Endpoints & Network Protection

12.1 VPC Core Architecture, Subnetting & High Availability NAT 12.2 Private Network Connectivity: VPC Endpoints & Peering 12.3 Network Protection & Edge Security Auditing

13 Chapter 13: DNS, Route 53 Routing & Content Delivery

13.1 DNS Architecture & Route 53 Resolver for Hybrid Clouds 13.2 Route 53 Advanced Routing Policies & Query Logging 13.3 Global Content & Service Distribution: CloudFront & Global Accelerator

14 Chapter 14: Network Troubleshooting, Traffic Analysis & Hybrid Connectivity

14.1 VPC Configuration Troubleshooting & Analysis Tools 14.2 Network Traffic Analysis: VPC Flow Logs & Log Analytics 14.3 CloudFront Caching & Hybrid Connectivity Troubleshooting

8.4 Third-Party Automation with Terraform & Git Workflows

Key Takeaways Explain This Topic AI

HashiCorp Terraform provides declarative Infrastructure as Code using HCL across a core operational lifecycle: terraform init (backend and providers), terraform plan (dry run preview), terraform apply (provisioning), and terraform destroy (decommissioning).

Remote state management stores terraform.tfstate in an Amazon S3 bucket (with versioning, SSE-KMS encryption, and private bucket policies) combined with an Amazon DynamoDB table (LockID partition key) to provide distributed state locking and prevent concurrent state corruption.

State drift between deployed AWS infrastructure and the state file is identified and reconciled using terraform plan -refresh-only or terraform refresh, while terraform import adopts pre-existing unmanaged AWS resources into Terraform state.

Infrastructure GitOps workflows utilize automated Pull Request pipelines executing terraform fmt -check, terraform validate, security linters, and speculative terraform plan checks before merging to protected main branches.

Modern CI/CD pipelines authenticate to AWS using IAM OpenID Connect (OIDC) identity federation (sts:AssumeRoleWithWebIdentity), completely eliminating hardcoded, long-lived AWS IAM access keys and secret keys.

Last updated: September 2026

8.4 Third-Party Automation with Terraform & Git Workflows

CloudOps Blueprint Focus: While AWS CloudFormation provides native orchestration, modern enterprise environments heavily utilize third-party Infrastructure as Code (IaC) tools—predominantly HashiCorp Terraform. For the AWS Certified CloudOps Engineer – Associate (SOA-C03) exam, you must understand Terraform architecture on AWS, master remote state management and distributed state locking with Amazon S3 and DynamoDB, manage configuration drift, adopt existing cloud resources, and secure CI/CD deployment pipelines using IAM OpenID Connect (OIDC) federation.

Terraform Fundamentals in AWS CloudOps

HashiCorp Terraform enables cloud engineers to define infrastructure using HashiCorp Configuration Language (HCL) —a declarative language. Rather than executing procedural scripts, declarative IaC defines the target end state; Terraform builds an internal dependency graph and executes the precise AWS API calls required to reconcile live infrastructure against declared configurations.

  • An AWS Terraform implementation begins with provider configuration: terraform {
  • required_version = ">= 1.5.0"
  • required_providers {
  • aws = {
  • source = "hashicorp/aws"
  • version = "~> 5.0"
  • }
  • }
  • }
  • provider "aws" {
  • region = "us-east-1"
  • default_tags {
  • tags = {
  • Environment = "Production"
  • ManagedBy = "Terraform"
  • }
  • }
  • }

The default_tags block automatically attaches standardized organizational tags across all provisioned resources, enforcing tagging governance across the estate.

Core Terraform Operational Lifecycle Commands

The standard Terraform lifecycle follows four sequential CLI commands:

Command Operational Function CloudOps Best Practices & Safety Controls

terraform init Initializes the working directory, sets up the remote backend, and downloads provider plugins into .terraform/ . Must re-run when provider versions or backends change. Use -upgrade to update plugins.

terraform plan Performs a dry run. Compares live AWS resources against HCL, outputting proposed additions ( + ), changes ( ~ ), and destructions ( - ). In CI/CD pipelines, output plan artifacts using -out=tfplan to ensure reviewed changes match what is applied.

terraform apply Executes planned API calls against AWS and records resource metadata into the state file. Use -auto-approve strictly in unattended CI/CD pipelines post-merge; never in manual sessions.

terraform destroy Deletes all infrastructure tracked in the state file. Guard critical stateful resources (RDS, S3) with lifecycle { prevent_destroy = true } .

Additional validation tools include terraform fmt -check (verifies canonical syntax and indentation in CI lint stages) and terraform validate (validates syntax and internal references without calling remote APIs).

Remote State Management & Distributed State Locking

Terraform records resource attributes in a state file ( terraform.tfstate ). In team environments, local state files are prohibited—they expose plain-text secrets and cause state divergence.

Amazon S3 and DynamoDB State Backend Architecture

The enterprise standard pairs Amazon S3 for remote storage with Amazon DynamoDB for distributed locking:

Amazon S3 Bucket Requirements:

Versioning: Retains complete revision history of state files, enabling immediate recovery if corruption occurs.

Encryption: Enforces SSE-KMS using a Customer Managed Key (CMK) to protect sensitive data stored in state.

Bucket Policy: Blocks public access, mandates TLS encryption ( aws:SecureTransport ), and restricts access to deployment IAM roles.

Amazon DynamoDB State Locking:

Configured with a primary partition key named LockID (String type).

During terraform plan or terraform apply , Terraform writes a lock item containing the transaction ID. If another runner attempts an execution concurrently, DynamoDB rejects the write, and Terraform halts with an Error acquiring the state lock message, preventing concurrent state corruption.

  • Upon completion, Terraform deletes the lock item. terraform {
  • backend "s3" {
  • bucket = "corp-terraform-state-111122223333"
  • key = "prod/vpc/terraform.tfstate"
  • region = "us-east-1"
  • encrypt = true
  • kms_key_id = "arn:aws:kms:us-east-1:111122223333:key/abc-123"
  • dynamodb_table = "corp-terraform-state-locks"
  • }
  • }
  • Managing State Drift & Resource Importation
  • Reconciling Configuration Drift

State Drift occurs when infrastructure is modified out-of-band directly through the AWS Console or CLI. The modern, safe workflow uses terraform plan -refresh-only (or terraform apply -refresh-only ). This queries live AWS APIs, identifies differences against state, and updates the state file to reflect reality without modifying or reverting cloud resources.

Adopting Unmanaged Infrastructure with Terraform Import

When adopting existing AWS resources into Terraform management without recreation, engineers use declarative import blocks : import {

  • to = aws_security_group.app_sg
  • id = "sg-0123456789abcdef0"
  • }

Running terraform plan -generate-config-out=generated.tf automatically generates HCL configuration for the imported resource, binding it into state.

GitOps CI/CD Pipelines & Validation Workflows

In GitOps architectures, infrastructure repositories are structured by blast radius (e.g., separating networking, databases, and compute into isolated directories and state files). Automated CI/CD pipelines enforce quality gates:

Pull Request Validation: Runs terraform fmt -check , static security scanners ( tfsec , checkov ), terraform validate , and terraform plan -out=tfplan , posting speculative diffs to PR comments for peer review.

Main Branch Merge & Deployment: Merging to the protected main branch triggers automated deployment, executing terraform apply -auto-approve against the reviewed plan.

Credential-Less CI/CD Authentication via IAM OIDC Federation

Storing static IAM user access keys in CI/CD secret stores creates credential leakage risks. The AWS standard uses IAM OpenID Connect (OIDC) Identity Federation :

An IAM OIDC Identity Provider is registered in AWS trusting the CI/CD platform (e.g., token.actions.githubusercontent.com ).

An IAM role is created with a trust policy allowing sts:AssumeRoleWithWebIdentity , strictly conditioned on repository claims ( token.actions.githubusercontent.com:sub matching repo:my-org/infra:ref:refs/heads/main ).

The CI/CD runner exchanges its short-lived OIDC JSON Web Token (JWT) with AWS STS to obtain temporary security credentials valid only for the pipeline run, eliminating persistent access keys entirely.