hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.79k stars 9.14k forks source link

[Bug]: Route53 alias for S3 website throws error #27379

Open apmovamo opened 1 year ago

apmovamo commented 1 year ago

Terraform Core Version

1.3.3

AWS Provider Version

v4.36.0

Affected Resource(s)

aws_route53_record

Expected Behavior

It should configure the Alias of Route53 for the AWS S3 Bucket

Actual Behavior

Throws the mentioned Snippet Error

Relevant Error/Panic Output Snippet

╷
│ Error: Provider produced inconsistent final plan
│
│ When expanding the plan for module.main.module.lacta-2022.aws_route53_record.lacta_2022_bucket to include new
│ values learned so far during apply, provider "registry.terraform.io/hashicorp/aws" produced an invalid new value for
│ .alias: planned set element cty.ObjectVal(map[string]cty.Value{"evaluate_target_health":cty.False,
│ "name":cty.StringVal("s3-website.eu-central-1.amazonaws.com"), "zone_id":cty.StringVal("Z04888888TTT88A88TTT8")}) does not
│ correlate with any element in actual.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Terraform Configuration Files

resource "aws_s3_bucket" "lacta_2022_bucket" {
  bucket         = "lacta-2022.p.domain.de"
  hosted_zone_id = data.aws_route53_zone.route53_zone.zone_id
}

data "aws_iam_policy_document" "lacta_2022_bucket_policy" {
  statement {
    sid    = "AllowPublicRead"
    effect = "Allow"
    actions = [
      "s3:GetObject"
    ]
    principals {
      identifiers = ["*"]
      type = "AWS"
    }
    resources = [
      "arn:aws:s3:::lacta-2022.p.domain.de",
      "arn:aws:s3:::lacta-2022.p.domain.de/*"
    ]
  }
}

resource "aws_s3_bucket_policy" "lacta_2022_bucket_policy" {
  bucket = aws_s3_bucket.lacta_2022_bucket.id
  policy = data.aws_iam_policy_document.lacta_2022_bucket_policy.json
}

resource "aws_s3_bucket_website_configuration" "clacta_2022_bucket_website" {
  bucket = aws_s3_bucket.lacta_2022_bucket.bucket

  index_document {
    suffix = "index.html"
  }

  error_document {
    key = "index.html"
  }
}

resource "aws_s3_bucket_acl" "lacta_2022_bucket_acl" {
  bucket = aws_s3_bucket.lacta_2022_bucket.id
  acl    = "public-read"
}

data "aws_route53_zone" "route53_zone" {
  name = "p.domain.de."
}

resource "aws_route53_record" "lacta_2022_bucket" {
  zone_id = data.aws_route53_zone.route53_zone.zone_id
  name    = "lacta-2022"
  type    = "A"

  alias {
    name                   = aws_s3_bucket_website_configuration.lacta_2022_bucket_website.website_domain
    zone_id                = aws_s3_bucket.lacta_2022_bucket.hosted_zone_id
    evaluate_target_health = false
  }
}

Steps to Reproduce

  1. terraform init
  2. terraform apply -> yes

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

No response

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

apmovamo commented 1 year ago

I am not sure why but it seems that this is resolved. I think is resolved because of this https://github.com/hashicorp/terraform-provider-aws/pull/27597