I am new to TF and I am trying to have a variable which will include all the regions for different S3 buckets.
variable.tf
variable "s3_bucket_arn" {
type = any
default = {
us-east-1 = "arn:aws:s3:::centralized-vpcflowlogs-logging-us"
us-east-2 = "arn:aws:s3:::centralized-vpcflowlogs-logging-us"
us-west-2 = "arn:aws:s3:::centralized-vpcflowlogs-logging-us"
us-west-1 = "arn:aws:s3:::centralized-vpcflowlogs-logging-us"
ap-southeast-2="arn:aws:s3:::centralized-vpcflowlogs-logging-aus"
}
}
below is VPC in main.tf
resource "aws_flow_log" "vpc_flow_log" {
log_destination = "${var.s3_bucket_arn}/${var.environment}/${data.aws_region.current.name}/${aws_vpc.network.id}"
log_destination_type = "s3"
traffic_type = "ALL"
vpc_id = aws_vpc.network.id
}
while running the terraform plan I am getting this error.
│ Error: Invalid template interpolation value
log_destination = "${var.s3_bucket_arn}/${var.environment}/${data.aws_region.current.name}/${aws_vpc.network.id}"
│ ├────────────────
│ │ var.s3_bucket_arn is object with 5 attributes
│
│ Cannot include the given value in a string template: string required.
Any idea why I am getting the error?