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]: Create a new `aws_route53_vpc_association_authorization` for existing resource #39666

Open mohsenbarzegar opened 6 days ago

mohsenbarzegar commented 6 days ago

Terraform Core Version

1.5.7

AWS Provider Version

5.65.0

Affected Resource(s)

Expected Behavior

Terraform plan should report NOOP,

Actual Behavior

Terraform plan reports:

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+ create

Terraform will perform the following actions:

  # module.ops_dns.aws_route53_vpc_association_authorization.name will be created
+ resource "aws_route53_vpc_association_authorization" "name" {
      + id         = (known after apply)
      + vpc_id     = "vpc-1"
      + vpc_region = (known after apply)
      + zone_id    = "zone-1"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

By applying this plan, provider returns error: Error: reading Route53 VPC Association Authorization (zone-1:vpc-1): too many results: wanted 1, got 2

Relevant Error/Panic Output Snippet

Error: reading Route53 VPC Association Authorization (zone-1:vpc-1): too many results: wanted 1, got 2

  with module.ops_dns.aws_route53_vpc_association_authorization.main,
  on ../../../../../modules/aws/private-dns-authorization/main.tf line 14, in resource "aws_route53_vpc_association_authorization" "authorization":
  14: resource "aws_route53_vpc_association_authorization" "name" {

Terraform Configuration Files

resource "aws_route53_vpc_association_authorization" "authorization" {
  provider = aws.hosted_zone_provider

  vpc_id  = data.aws_vpc.cluster_vpc.id
  zone_id = data.aws_route53_zone.zone.zone_id

}

Steps to Reproduce

Upgrade aws provider version from5.38.0 to5.65.0

New provider version tries to create (NOT recreate) a new aws_route53_vpc_association_authorization for already exists association_authorization

Debug Output

No response

Panic Output

No response

Important Factoids

By fetching current terraform state, we can see the resource is already exist (I double checked with aws-cli and aws console): terraform state show module.ops_dns.aws_route53_vpc_association_authorization.name it returns the current state for the existing resource correctly:

# module.dns.aws_route53_vpc_association_authorization.name:
resource "aws_route53_vpc_association_authorization" "authorization" {
    id         = "zone-1:vpc-1"
    vpc_id     = "vpc-1"
    vpc_region = "eu-central-1"
    zone_id    = "zone-1"
}

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 6 days ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue