Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import of aws_vpc_dhcp_options_association fails in v3.73.0 #22716

Closed
kanor1306 opened this issue Jan 21, 2022 · 5 comments · Fixed by #22722
Closed

Import of aws_vpc_dhcp_options_association fails in v3.73.0 #22716

kanor1306 opened this issue Jan 21, 2022 · 5 comments · Fixed by #22722
Labels
bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/ec2 Issues and PRs that pertain to the ec2 service.
Milestone

Comments

@kanor1306
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

aws_provider: v3.73.0
terraform: v1.1.4

Affected Resource(s)

  • aws_vpc_dhcp_options_association

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

The actual issue is while importing resources:

terraform import module.vpc.aws_vpc_dhcp_options_association.dns_resolver <vpc-id>

Below manifest could create the needed resources for this import.

data "aws_region" "current" {}

resource "aws_vpc" "customer_vpc" {
  cidr_block           = "10.43.4.0/22"
  enable_dns_hostnames = true
  enable_dns_support   = true
}

resource "aws_vpc_dhcp_options" "default_dhcp_options" {
  domain_name         = format("%s%s", data.aws_region.current.name, ".compute.internal")
  domain_name_servers = ["AmazonProvidedDNS"]
}

resource "aws_vpc_dhcp_options_association" "dns_resolver" {
  vpc_id          = aws_vpc.customer_vpc.id
  dhcp_options_id = aws_vpc_dhcp_options.default_dhcp_options.id
}

Debug Output

Panic Output

Expected Behavior

After executing terraform import module.vpc.aws_vpc_dhcp_options_association.dns_resolver <vpc-id> the resource should be imported.

Actual Behavior

After executing terraform import module.vpc.aws_vpc_dhcp_options_association.dns_resolver <vpc-id> this error is received:

Error: unexpected format for ID (default-vpc-0466d39c84de5c49b), expected DHCPOptionsID-VPCID

Verified that it does work in v3.72.0 of the provider

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/ec2 Issues and PRs that pertain to the ec2 service. labels Jan 21, 2022
@ewbankkit ewbankkit added bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. and removed needs-triage Waiting for first response or review from a maintainer. labels Jan 21, 2022
@ewbankkit
Copy link
Contributor

@kanor1306 Thanks for raising this issue.

The bug is here:

// DHCP Options ID and VPC ID themselves contain '-'.
if len(parts) == 4 && parts[0] != "" && parts[1] != "" && parts[2] != "" && parts[3] != "" {
return strings.Join([]string{parts[0], parts[1]}, vpcDHCPOptionsAssociationResourceIDSeparator), strings.Join([]string{parts[2], parts[3]}, vpcDHCPOptionsAssociationResourceIDSeparator), nil
}
return "", "", fmt.Errorf("unexpected format for ID (%[1]s), expected DHCPOptionsID%[2]sVPCID", id, vpcDHCPOptionsAssociationResourceIDSeparator)

If the DHCP Options ID is default (which is a valid Options ID) then there are only 3 parts when splitting by -.
The previous version of the code used vpc_id directly:

vpc, err = FindVPCByID(conn, d.Get("vpc_id").(string))

This is a regression and I will fix it ASAP.

@kanor1306
Copy link
Author

Great! Thanks for the quick action @ewbankkit

@github-actions
Copy link

This functionality has been released in v3.74.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@ryanhestin
Copy link

@ewbankkit I am experiencing this bug on 3.75.1 during an upgrade from ~> 2.0 on 0.12.31.

If I pin the provider to 3.72.0, it passes a plan fine. On everything higher, it fails:

Error: unexpected format for ID (dopt-5159a234), expected DHCPOptionsID-VPCID

@github-actions
Copy link

github-actions bot commented May 7, 2022

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants