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

224
Views
¿Cómo evitar el error de ciclo al configurar una política de depósito S3 con una plantilla que depende del nombre del depósito?

Tengo un archivo de terraform que falla cuando ejecuto el terraform plan y aparece el error:

 Error: Cycle: module.hosting.data.template_file.bucket_policy, module.hosting.aws_s3_bucket.website

Tiene sentido ya que el cubo se refiere a la política y viceversa:

 data "template_file" "bucket_policy" { template = file("${path.module}/policy.json") vars = { bucket = aws_s3_bucket.website.arn } } resource "aws_s3_bucket" "website" { bucket = "xxx-website" website { index_document = "index.html" } policy = data.template_file.bucket_policy.rendered }

¿Cómo puedo evitar esta referencia bidireccional?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Puede utilizar el recurso aws_s3_bucket_policy . Esto le permite crear los recursos sin una dependencia circular.

De esta forma, Terraform puede:

  1. Crear el cubo
  2. Cree el archivo de plantilla con el ARN del depósito.
  3. Cree la política, consulte el archivo de plantilla y adjúntelo al depósito.

El código sería algo como esto:

 data "template_file" "bucket_policy" { template = file("${path.module}/policy.json") vars = { bucket = aws_s3_bucket.website.arn } } resource "aws_s3_bucket" "website" { bucket = "xxx-website" website { index_document = "index.html" } } resource "aws_s3_bucket_policy" "b" { bucket = "${aws_s3_bucket.website.id}" policy = data.template_file.bucket_policy.rendered }
over 4 years ago · Santiago Trujillo Report

0

Podrías construir el ARN del depósito tú mismo:

 locals { bucket_name = "example" bucket_arn = "arn:aws:s3:::${local.bucket_name}" } data "template_file" "bucket_policy" { template = file("${path.module}/policy.json") vars = { bucket = local.bucket_arn } } resource "aws_s3_bucket" "website" { bucket = local.bucket_name website { index_document = "index.html" } policy = data.template_file.bucket_policy.rendered }
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!