Terraform init Error: Failed to get existing workspaces: S3 bucket does not exist
Terraform init Error: Failed to get existing workspaces: S3 bucket does not exist
您好,当我将 s3 存储桶指定为后端时,我遇到了 terraform 无法看到它的问题
aws --profile terraform s3api create-bucket --bucket "some_name_here" --region "eu-west-2" \
--create-bucket-configuration LocationConstraint="eu-west-2"
地形初始化
Initializing modules...
Initializing the backend...
Error: Failed to get existing workspaces: S3 bucket does not exist.
The referenced S3 bucket must have been previously created. If the S3 bucket
was created within the last minute, please wait for a minute or two and try
again.
Error: NoSuchBucket: The specified bucket does not exist
status code: 404, request id: QYJT8KP0W4TM986A, host id: a7R1EOOnIhP6YzDcKd66zdyCJ8wk6lVom/tohsc0ipUe5yEJK1/V4bLGX9khi4q4/J7d4BgYXCc=
backend.tf
terraform {
backend "s3" {
bucket = "some_name_here"
key = "networking/terraform.tfstate"
region = "eu-west-2"
}
}
provider.tf
provider "aws" {
region = "eu-west-2"
shared_credentials_file = "$HOME/.aws/credentials"
profile = "terraform"
}
我可以在仪表板中看到存储桶
您似乎在命令中使用配置文件来创建存储桶。因此,您可能需要在环境 运行 terraform 中导出变量才能使用相同的配置文件。我想象没有此配置文件或具有足够权限的另一个配置文件的 terraform 无法从存储桶中读取。
export AWS_PROFILE=terraform
terraform init
或者,您可以将 profile 传递到后端配置中,例如:
terraform {
backend "s3" {
bucket = "some_name_here"
key = "networking/terraform.tfstate"
profile = "terraform"
region = "eu-west-2"
}
}
总结一下,最简单的配置是:
terraform {
backend "s3" {
bucket = "some_name_here"
key = "networking/terraform.tfstate"
region = "eu-west-2"
}
}
provider "aws" {
region = "eu-west-2"
}
然后:
export AWS_PROFILE=terraform
aws s3api create-bucket --bucket "some_name_here" --region "eu-west-2" --create-bucket-configuration LocationConstraint="eu-west-2"
terraform init
您好,当我将 s3 存储桶指定为后端时,我遇到了 terraform 无法看到它的问题
aws --profile terraform s3api create-bucket --bucket "some_name_here" --region "eu-west-2" \
--create-bucket-configuration LocationConstraint="eu-west-2"
地形初始化
Initializing modules...
Initializing the backend...
Error: Failed to get existing workspaces: S3 bucket does not exist.
The referenced S3 bucket must have been previously created. If the S3 bucket
was created within the last minute, please wait for a minute or two and try
again.
Error: NoSuchBucket: The specified bucket does not exist
status code: 404, request id: QYJT8KP0W4TM986A, host id: a7R1EOOnIhP6YzDcKd66zdyCJ8wk6lVom/tohsc0ipUe5yEJK1/V4bLGX9khi4q4/J7d4BgYXCc=
backend.tf
terraform {
backend "s3" {
bucket = "some_name_here"
key = "networking/terraform.tfstate"
region = "eu-west-2"
}
}
provider.tf
provider "aws" {
region = "eu-west-2"
shared_credentials_file = "$HOME/.aws/credentials"
profile = "terraform"
}
我可以在仪表板中看到存储桶
您似乎在命令中使用配置文件来创建存储桶。因此,您可能需要在环境 运行 terraform 中导出变量才能使用相同的配置文件。我想象没有此配置文件或具有足够权限的另一个配置文件的 terraform 无法从存储桶中读取。
export AWS_PROFILE=terraform
terraform init
或者,您可以将 profile 传递到后端配置中,例如:
terraform {
backend "s3" {
bucket = "some_name_here"
key = "networking/terraform.tfstate"
profile = "terraform"
region = "eu-west-2"
}
}
总结一下,最简单的配置是:
terraform {
backend "s3" {
bucket = "some_name_here"
key = "networking/terraform.tfstate"
region = "eu-west-2"
}
}
provider "aws" {
region = "eu-west-2"
}
然后:
export AWS_PROFILE=terraform
aws s3api create-bucket --bucket "some_name_here" --region "eu-west-2" --create-bucket-configuration LocationConstraint="eu-west-2"
terraform init