Terraform: Bucket aws

Asked

Viewed 102 times

0

Hello I’m taking a terraform course and I came across a mistake I’m not getting through. I created a Docker container with terraform and it has the following main.Tf,ec2.Tf,output.Tf,variable.tf. I created an IAM no aws and gave Administratoraccess permission to it, inside the container export my key and secret key, also create a Bucket no aws e ta as I publish its permissions. When inside the container I’m giving the command terraform init Only he’s making that mistake:

Initializing the backend... Error Refreshing state: Allaccessdisabled: All access to this Object has been disabled status code: 403, request id: 63C2B2B19AFF684C, host id: N33/aFmFs5JfC3BZcWazaotlEjp+wKk5kfR3Pq1Kg7NG1soDv06wyJTK9JbxKWaJnD215PpKU50=

provider "aws" {
  region  = "us-east-2"
  version = "~> 2.0"
}

terraform {
  backend "s3" {
    # Lembre de trocar o bucket para o seu, não pode ser o mesmo nome
    bucket = "terraformgerson"
    key    = "terraform-test.tfstate"
    region = "us-east-2"
    encrypt = "true"
    dynamodb_table = "terraform-state-lock-dynamo"
  }
} 

the buccket I created in this aws with the name terraformgerson

  • This dynamodb table is created tbm? terraform-state-lock-Dynamo

2 answers

1

When you are inside the container you need to use the command below followed by your AWS credentials.

export AWS_ACCESS_KEY=AQUI_A_SUA_CHAVE_DE_ACESS0
export AWS_SECRET_ACCESS_KEY=AQUI_A_SUA_CHAVE_SECRETA_DE_ACESS0

Then just send the terrafom init

1

The Code is not wrong, the error message itself is very clear, unable to connect in Bucket for lack of permission...

may be misstating node "access_key and secret_key", where is Voce declaring? tries to do by environment variable (recommended form) than direct in the previous.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.