← Terraform & Infrastructure as Code learning path
Terraform & Infrastructure as Code · Module 5 of 10

Resources, data sources and dependencies

Connect resources and read existing data.

📖 Key ideas

  1. Reference attributes: aws_instance.web.public_ip.
  2. Terraform builds a dependency graph automatically from references.
  3. depends_on forces explicit ordering when needed.
  4. Data sources read existing info: data "aws_ami" "ubuntu" { ... }.
  5. Lifecycle rules: prevent_destroy, create_before_destroy, ignore_changes.
💡 Real-life example: References are strings connecting puppets: move one and Terraform knows which others must move after.
Data sourceReads existing information
Dependency graphOrder of resource operations
depends_onExplicit dependency
prevent_destroyBlocks accidental deletion