Reputation: 241
I have terraform code , to create few aws resources. for example . i create a s3 bucket and create another resource based on or which depends on this s3 resource. I know terraform will figure out that this new object resource is dependent on the first s3 bucket resource, as i have passed this => aws_s3_bucket.s3.id , to the new resource. I'm not sure if this is a arn or bucket name or some intrinsic id that terraform maintains. but is it possible to add such dependency by passing in arn or something else?
so say , i had a bucket name that is already created somewhere else, and I can simply pass its arn in my example below , so instead of aws_s3_bucket.s3.id , i can pass bucket name , as var.bucket name will that work?
resource "aws_s3_bucket" "s3" {
bucket = "s3-bucket-name"
acl = "private"
...
}
resource "aws_s3_bucket_object" "init" {
bucket = aws_s3_bucket.s3.id
key = "bin.tar.gz"
....
}
I've tried passing this => aws_s3_bucket.s3.id, which works. but want to know if i can pass an arn
Upvotes: 3
Views: 171
Reputation: 1966
aws_s3_bucket.s3.id
is actually the bucket name;aws_s3_bucket_object.init.bucket
expects a bucket name, passing a bucket ARN will result in an error;aws_s3_bucket_object.init.bucket
expects a string, it doesn't matter how you pass it there, so var.bucket
will totally work as long as it's a valid string bucket name.Upvotes: 1