Dear all,
I faced an issue with Terraform:
│ Error: Failed to get existing workspaces: Unable to list objects in S3 bucket "tf-state-project2" with prefix "env:/": operation error S3: ListObjectsV2, https response error StatusCode: 400, RequestID: cd9a80e3b46b271e, HostID: , api error BadRequest: 400 BadRequest
In the first project I had a s3 backend, like:
terraform {
backend "s3" {
endpoints = {
dynamodb = "<REDACTED>"
s3 = "<REDACTED>"
}
bucket = "tf-state-project1"
region = "<REDACTED>"
key = "state/infra.tfstate"
access_key = "<REDACTED>"
secret_key = "<REDACTED>"
dynamodb_table = "<REDACTED>"
}
}
I tried to cut out access_key
and secret_key
from file by moving AWS access_key / secret_key to the env vars (remove secrets from git):
export AWS_ACCESS_KEY_ID=$(vault kv get -field=AWS_ACCESS_KEY_ID <REDACTED>)
export AWS_SECRET_ACCESS_KEY=$(vault kv get -field=AWS_SECRET_ACCESS_KEY <REDACTED>)
In the first project, I am able to run terraform init -reconfigure
. Works perfect.
In the same shell, when I do the same thing in the project2:
terraform {
backend "s3" {
endpoints = {
dynamodb = "<REDACTED>"
s3 = "<REDACTED>"
}
bucket = "tf-state-project2"
region = "<REDACTED>"
key = "state/project2.tfstate"
access_key = "<REDACTED>"
secret_key = "<REDACTED>"
dynamodb_table = "<REDACTED>"
}
}
I’m facing the mentioned error:
│ Error: Failed to get existing workspaces: Unable to list objects in S3 bucket "tf-state-project2" with prefix "env:/": operation error S3: ListObjectsV2, https response error StatusCode: 400, RequestID: cd9a80e3b46b271e, HostID: , api error BadRequest: 400 BadRequest
I don’t use workspaces in any project.
My guess it occurs due to difference of s3 buckets I have, but this is a requirement.
It might be another way to manage AWS secrets, unfortunately I can’t use a CLI or any other tooling, I have only AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
as variables.
Please suggest.
Terraform v1.7.5
Thanks,
P.