我将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环境中使用相同的证书,我也会收到拒绝访问错误?
发布于 2019-08-22 05:41:02
也收到了同样的错误。对于我们的用例,我们必须手动删除.terraform/目录下的terraform.tfstate文件,然后再次运行init。
发布于 2018-04-14 03:03:23
乍一看,这似乎是合理的。你有没有试过把terraform init和-backend-config都放在一行上?我想知道开头的-是不是弄乱了yml格式?
发布于 2022-02-12 23:48:25
如果没有找到解决此问题的方法,您可以在terraform_remote_state节的配置部分使用"profile=“或"role_arn=”。AWS提供商和后端配置也是如此。
我今天一整天都在追踪这个问题,没有意识到terraform_backend_state数据源可以使用role_arn。
https://stackoverflow.com/questions/49816309
复制相似问题