🎯 Goal: Stop guessing AMI IDs or subnet IDs β€” query AWS dynamically and build portable, environment-agnostic configs.

βœ… You’ll master:


🧠 Why Data Sources Matter

❌ Without data sources:

βœ… With data sources:

β†’ Infrastructure that self-discovers dependencies

β†’ Truly portable configs (dev β†’ staging β†’ prod)

β†’ Zero manual lookup β€” fully automated

πŸ’‘ Golden Rule:

β€œIf it already exists in AWS β€” data it. If you’re creating it β€” resource it.”


πŸ“¦ Data Source Cheat Sheet (AWS)

Data Source Use Case Key Filter Attributes
aws_ami Find OS images owners, name, virtualization_type, root_device_type
aws_vpc Reuse shared VPCs tags, cidr_block, default
aws_subnet Target specific subnets vpc_id, availability_zone, tags, cidr_block
aws_iam_role Attach to existing roles name
aws_ssm_parameter Read config from SSM name

🎯 Critical:


✏️ Hands-On: Data Sources in Action

πŸ”Ή Scenario: Deploy to Shared VPC & Subnets