← Terraform & Infrastructure as Code learning pathTerraform & Infrastructure as Code · Module 5 of 10
Resources, data sources and dependencies
Connect resources and read existing data.
📖 Key ideas
- Reference attributes: aws_instance.web.public_ip.
- Terraform builds a dependency graph automatically from references.
- depends_on forces explicit ordering when needed.
- Data sources read existing info: data "aws_ami" "ubuntu" { ... }.
- 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