gpt4 book ai didi

amazon-s3 - Terraform 错误刷新状态访问被拒绝

转载 作者:行者123 更新时间:2023-12-02 23:02:51 24 4
gpt4 key购买 nike

我将 gitbucket 用于我的存储库和管道。我有一个配置了远程状态的 terraform 配置文件,它在我的本地计算机上运行良好,但在 gitbucket 中运行时失败。我不断收到访问被拒绝的错误。这是 main.tf:

terraform {
backend "s3" {
bucket = "zego-terraform-test"
key = "test/terraform.tfstate"
region = "eu-west-1"
}
}

data "terraform_remote_state" "remote_state" {
backend = "s3"

config {
bucket = "zego-terraform-test"
key = "test/terraform.tfstate"
region = "eu-west-1"
}
}

variable "region" {}

provider "aws" {
region = "${var.region}"
access_key = {}
secret_key = {}
token = {}
}

module "vpc" {
source = "./modules/vpc"
}

这是我的 gitbucket-pipelines.yml:

image: python:3.5.1
pipelines:
default:
- step:
caches:
- pip
script: # Modify the commands below to build your repository.
- apt-get update
- apt-get install unzip
- wget https://releases.hashicorp.com/terraform/0.11.7/terraform_0.11.7_linux_amd64.zip
- unzip terraform_0.11.7_linux_amd64.zip
- rm terraform_0.11.7_linux_amd64.zip
- export PATH="$PATH:${BITBUCKET_CLONE_DIR}"
- terraform init
-backend-config "access_key=$AWS_ACCESS_KEY"
-backend-config "secret_key=$AWS_SECRET_KEY"
-backend-config "token=$TOKEN"

当我在此管道中运行 .tf 文件时,出现此错误:

Successfully configured the backend "s3"! Terraform will automatically
use this backend unless the backend configuration changes.
Error refreshing state: AccessDenied: Access Denied
status code: 403

当我删除远程状态配置时,它运行正常。即使我在本地计算机和 gitbucket 环境中使用相同的凭据,为什么我仍会收到访问被拒绝错误?

最佳答案

遇到同样的错误。对于我们的用例,我们必须手动删除 .terraform/ 目录下的 terraform.tfstate 文件,然后再次运行 init

关于amazon-s3 - Terraform 错误刷新状态访问被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49816309/

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