gpt4 book ai didi

amazon-web-services - 使用 Terraform 在不同区域创建 AWS S3 存储桶

转载 作者:行者123 更新时间:2023-12-05 07:21:03 24 4
gpt4 key购买 nike

尝试在供应商声明中提到的区域以外的其他区域创建 S3 存储桶时出现以下错误。

Error: Error creating S3 bucket: IllegalLocationConstraintException: The eu-central-1 location constraint is incompatible for the region specific endpoint this request was sent to. status code: 400, request id: CDC41B1AC8DECE02, host id: rZq1QatrmMLJ4pKfM5Ry5vg2asFYOGTJJNVVquXgnr3L506hHpFZf67YOiatapSc3UGtYntQsbU=

解决方法:似乎根据 AWS 文档,https://docs.aws.amazon.com/cli/latest/reference/s3api/create-bucket.html ,还需要提及 LocationConstraint。

$ aws s3api create-bucket --bucket my-bucket --region eu-west-1 --create-bucket-configuration LocationConstraint=eu-west-1

但是,我在 Terraform 代码文档中没有看到等效的配置参数 https://www.terraform.io/docs/providers/aws/r/s3_bucket.html .我使用最新的 Terraform 版本:0.12.3

示例 Terraform 代码:​​

resource "aws_s3_bucket" "public-alb-logs-bucket" {
bucket = "alb-access-logs-prod"
region = "eu-central-1"
}

provider "aws" {
version = "~> 2.14.0"
region = "us-west-2"
}

如果两个区域相同,则相同的代码有效。 (在 S3 资源和提供者部分)。

任何帮助/想法将不胜感激。谢谢。如果有任何其他信息,也请告诉我。

最佳答案

我无法确认,但我认为问题在于您的区域不匹配:

resource "aws_s3_bucket" "public-alb-logs-bucket" {
bucket = "alb-access-logs-prod"
region = "eu-central-1" ### This region is different from the one below
}

provider "aws" {
version = "~> 2.14.0"
region = "us-west-2" ### This region is different from the one above
}

我目前处理不同地区的账户和在多个地区拥有资源的账户。但我从未尝试过使用与资源区域不匹配的提供者区域来部署资源。

所以我猜这就是问题所在??

关于amazon-web-services - 使用 Terraform 在不同区域创建 AWS S3 存储桶,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57146232/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com