Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.7K
Views
¿Cómo resolver el estado de carga de error: Acceso denegado: Código de estado de acceso denegado: 403 al intentar usar s3 para el backend de terraformación?

Mi archivo de terraformación simple es:

 provider "aws" { region = "region" access_key = "key" secret_key = "secret_key" } terraform { backend "s3" { # Replace this with your bucket name! bucket = "great-name-terraform-state-2" key = "global/s3/terraform.tfstate" region = "eu-central-1" # Replace this with your DynamoDB table name! dynamodb_table = "great-name-locks-2" encrypt = true } } resource "aws_s3_bucket" "terraform_state" { bucket = "great-name-terraform-state-2" # Enable versioning so we can see the full revision history of our # state files versioning { enabled = true } server_side_encryption_configuration { rule { apply_server_side_encryption_by_default { sse_algorithm = "AES256" } } } } resource "aws_dynamodb_table" "terraform_locks" { name = "great-name-locks-2" billing_mode = "PAY_PER_REQUEST" hash_key = "LockID" attribute { name = "LockID" type = "S" } }

Todo lo que estoy tratando de hacer es reemplazar mi backend local para almacenarlo en S3. Estoy haciendo lo siguiente:

  1. terraform init (cuando el bloque terrafrom{} es un comentario)

  2. terrafrom apply : puedo ver en mi AWS que se creó el depósito y la tabla Dynmpo también.

  3. ahora estoy dejando de comentar el bloque terrafrom y nuevamente terraform init y obtengo el siguiente error:

 Error loading state: AccessDenied: Access Denied status code: 403, request id: xxx, host id: xxxx

Mi IAM tiene acceso de administrador . Estoy usando Terraform v0.12.24 como se puede observar, estoy escribiendo directamente mi clave y secreto de AWS en el archivo.

¿Qué estoy haciendo mal?

Agradezco cualquier ayuda!

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Me encontré con esto antes. Los siguientes son los pasos que lo ayudarán a superar ese error:

  1. Eliminar el directorio .terraform
  2. Coloque access_key y secret_key debajo del bloque backend. como debajo del código dado
  3. Ejecutar inicio de terraformación
 backend "s3" { bucket = "great-name-terraform-state-2" key = "global/s3/terraform.tfstate" region = "eu-central-1" access_key = "<access-key>" secret_key = "<secret-key>" } }

El error debería desaparecer.

over 4 years ago · Santiago Trujillo Report

0

También me enfrenté al mismo problema. Luego elimino manualmente el archivo de estado de mi sistema local. Puede encontrar el archivo terraform.tfstate en el directorio .terraform/ y ejecutar init nuevamente. en caso de que tuviera varios perfiles configurados en aws cli. no mencionar el perfil en la configuración del proveedor de aws hará que terraform use el perfil predeterminado.

over 4 years ago · Santiago Trujillo Report

0

Para una mejor seguridad, puede usar shared_credentials_file y profile así;

 provider "aws" { region = "region" shared_credentials_file = "$HOME/.aws/credentials # default profile = "default" # you may change to desired profile } terraform { backend "s3" { profile = "default" # change to desired profile # Replace this with your bucket name! bucket = "great-name-terraform-state-2" key = "global/s3/terraform.tfstate" region = "eu-central-1" # Replace this with your DynamoDB table name! dynamodb_table = "great-name-locks-2" encrypt = true } }
  • sobre los perfiles con nombre de aws
  • acerca de cómo asegurar las configuraciones secretas del back-end de terraform
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!