如何使用Terraform将S3 bucket区域名称发送到json文件



我正在使用Terraform创建一个S3 bucket,我需要将创建bucket的区域名称aws_s3_bucket.website_bucket.region发送到以下格式的json文件(root/region.json(中。

root/reregion.json

{
"region": "us-east-2"
}

root/s3.tf

resource "aws_s3_bucket" "website_bucket" {
bucket   = var.website_bucket_name
provider = aws.east
acl      = "public-read"
cors_rule {
allowed_headers = ["*"]
allowed_methods = ["PUT", "POST", "GET", "DELETE"]
allowed_origins = ["*"]
}
website {
index_document = "index.html"
}
}

以下内容应能完成任务:

resource "local_file" "region" {
filename = "root/region.json"
content  = jsonencode({
"region": aws_s3_bucket.website_bucket.region,
})
}

相关内容

  • 没有找到相关文章

最新更新