Skip to main content

Skill Guide

Hands-on scripting in Python and infrastructure-as-code (Terraform, CloudFormation)

The combined practice of using Python for automating operational tasks and logic, alongside declarative tools (Terraform, CloudFormation) to define, provision, and manage cloud infrastructure as version-controlled code.

This skill directly enables DevOps and Platform Engineering teams to achieve repeatable, auditable, and scalable infrastructure deployments, drastically reducing provisioning time and human error. It shifts infrastructure management from manual, ticket-based processes to automated pipelines, directly impacting system reliability and operational expenditure.
1 Careers
1 Categories
9.1 Avg Demand
15% Avg AI Risk

How to Learn Hands-on scripting in Python and infrastructure-as-code (Terraform, CloudFormation)

Focus on core Python syntax (variables, loops, functions, file I/O) and the fundamental concepts of Infrastructure as Code (idempotency, desired state, declarative vs. imperative). Begin with the AWS CLI and simple CloudFormation templates to provision a single S3 bucket, then refactor that template using Terraform. Build a basic habit of writing all commands and configurations in files rather than using ad-hoc CLI commands.
Move to practice by writing Python scripts that interact with cloud provider SDKs (boto3 for AWS) and by creating Terraform modules. Tackle scenarios like automating EBS snapshot cleanup with Python or deploying a multi-tier VPC with Terraform. Key mistakes to avoid include hardcoding credentials in scripts, not using state locking in Terraform, and writing monolithic CloudFormation templates without nested stacks or modules.
Mastery involves designing and implementing entire infrastructure platforms and deployment pipelines. This includes architecting multi-account/multi-region strategies using Terraform workspaces or CloudFormation StackSets, writing sophisticated Python-based custom Terraform providers or CloudFormation resource types, and building internal developer platforms (IDPs) with tools like Pulumi or CDK that leverage Python. At this level, you mentor teams on IaC patterns, enforce policies via tools like OPA/Sentinel, and align infrastructure strategy with business continuity and cost-optimization goals.

Practice Projects

Beginner
Project

Automated Static Website Hosting on AWS

Scenario

Provision and configure a secure, static website hosted on S3 with a CloudFront distribution, using both CloudFormation and Terraform to compare approaches.

How to Execute
1. Write a Python script to create and manage S3 bucket policies for public access. 2. Author a CloudFormation template (YAML) to define the S3 bucket, website configuration, and CloudFront distribution. 3. Recreate the same infrastructure using Terraform HCL in a separate directory, utilizing variables and outputs. 4. Use Git to version control both sets of configuration files, committing changes that illustrate state management differences (e.g., `terraform plan` vs. `aws cloudformation deploy`).
Intermediate
Project

Blue/Green Deployment Pipeline for a Web Application

Scenario

Create a fully automated deployment pipeline that provisions two identical production environments (Blue and Green) using IaC, deploys application code, and switches traffic.

How to Execute
1. Design Terraform modules for core infrastructure (VPC, ECS Cluster) and environment-specific resources (ECS Service, ALB Target Group). 2. Write a Python script using the `boto3` library to orchestrate the deployment: it will update the ECS service in the 'green' environment, run health checks, and then modify the ALB listener rule to shift traffic. 3. Integrate this Python script into a CI/CD pipeline (e.g., GitHub Actions, Jenkins) that is triggered on a Git tag. 4. Implement logging and rollback logic in the Python script, handling errors from the AWS API.
Advanced
Project

Multi-Account Landing Zone with Policy-as-Code

Scenario

Design and implement an AWS Organizations-based landing zone that provisions new developer accounts, applies baseline security and networking configurations via IaC, and enforces compliance rules.

How to Execute
1. Architect the account vending process using Terraform, creating an `aws_organizations_account` resource and a standardized module for account baseline (IAM roles, VPC, security groups). 2. Develop a Python-based custom Terraform provider or a Lambda function to handle complex, cross-account logic during provisioning. 3. Integrate Open Policy Agent (OPA) with your Terraform plan output in the CI/CD pipeline to validate configurations against security policies (e.g., 'no public S3 buckets'). 4. Write a Python script that uses AWS CloudTrail and Config APIs to generate compliance reports, feeding back into the IaC definitions for remediation.

Tools & Frameworks

Core IaC & Scripting Tools

TerraformAWS CloudFormationPython (with boto3)Pulumi / AWS CDK

Terraform is the industry-standard, cloud-agnostic declarative tool. CloudFormation is the native AWS equivalent. Python with boto3 is essential for imperative automation, glue logic, and interacting with APIs not covered by IaC tools. Pulumi and CDK allow defining infrastructure using Python, bridging scripting and IaC.

Testing & Validation Frameworks

Terraform Plan (`terraform plan`)cfn-lint / taskcatpytest with moto / localstackOPA / Sentinel

Use `terraform plan` as a dry-run for infrastructure changes. `cfn-lint` validates CloudFormation template syntax. `pytest` with `moto` mocks AWS services for unit testing Python scripts and IaC logic. OPA/Sentinel are policy-as-code frameworks to enforce organizational rules on IaC before apply.

Orchestration & State Management

Git / GitHub / GitLabCI/CD Pipelines (GitHub Actions, GitLab CI, Jenkins)Terraform Cloud/EnterpriseAWS S3 + DynamoDB (for Terraform state)

Git is non-negotiable for versioning all scripts and IaC. CI/CD pipelines automate testing, planning, and applying changes. Terraform Cloud provides remote state, collaboration, and policy enforcement. For self-managed, S3 with DynamoDB locking is the standard for secure, shared Terraform state.

Careers That Require Hands-on scripting in Python and infrastructure-as-code (Terraform, CloudFormation)

1 career found