
# =================Implicit Dependencies================================== | |
resource "aws_instance" "example" { | |
ami = "ami-b374d5a5" | |
instance_type = "t2.micro" | |
} | |
resource "aws_eip" "ip" { | |
vpc = true | |
instance = aws_instance.example.id | |
} | |
#=================Explicit Dependencies================================== | |
#Sometimes there are dependencies between resources that are not visible to Terraform. The depends_on argument is accepted by any resource and accepts a list of resources to create explicit dependencies for. | |
# New resource for the S3 bucket our application will use. | |
resource "aws_s3_bucket" "example" { | |
# NOTE: S3 bucket names must be unique across _all_ AWS accounts, so | |
# this name must be changed before applying this example to avoid naming | |
# conflicts. | |
bucket = "terraform-getting-started-guide" | |
acl = "private" | |
} | |
# Change the aws_instance we declared earlier to now include "depends_on" | |
resource "aws_instance" "example" { | |
ami = "ami-2757f631" | |
instance_type = "t2.micro" | |
# Tells Terraform that this EC2 instance must be created only after the | |
# S3 bucket has been created. | |
depends_on = [aws_s3_bucket.example] | |
} |










I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND