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

[Bug]: aws_lightsail_domain_entry panics on importing assignment #29884

Closed
pludi opened this issue Mar 9, 2023 · 5 comments · Fixed by #30056
Closed

[Bug]: aws_lightsail_domain_entry panics on importing assignment #29884

pludi opened this issue Mar 9, 2023 · 5 comments · Fixed by #30056
Labels
bug Addresses a defect in current functionality. service/lightsail Issues and PRs that pertain to the lightsail service.
Milestone

Comments

@pludi
Copy link

pludi commented Mar 9, 2023

Terraform Core Version

1.4.0

AWS Provider Version

4.57.1

Affected Resource(s)

aws_lightsail_domain_entry

Expected Behavior

Running terraform import aws_lightsail_domain_entry.example_domain_entry container.example.com should import the existing DNS assignment created through the Lightsail web console.

Actual Behavior

Provider panics

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

terraform {
  required_version = ">= 1.2.0"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 4.0"
    }
  }
}

provider "aws" {
  alias = "dns"
  region = "us-east-1"
  access_key = var.access_key
  secret_key = var.secret_key
}

resource "aws_lightsail_domain" "example_domain" {
  provider = aws.dns
  domain_name = var.domainname
}

resource "aws_lightsail_domain_entry" "example_domain_entry" {
  provider = aws.dns
  domain_name = var.domainname
  name        = "${var.container}"
  type        = "CNAME"
  target      = "test.example.com."
}

variable "domainname" {
  description = "Domain used"
  type = string
}

variable "container" {
  description = "Name of the container"
  type = string
}

variable "access_key" {
  description = "AWS access key"
  type = string
}

variable "secret_key" {
  description = "AWS secret key"
  type = string
}

variable "region" {
  description = "AWS Region"
  type = string
  default = "eu-central-1"
}

variable "zone" {
  description = "AWS Zone"
  type = string
  default = "eu-central-1a"
}

Steps to Reproduce

  1. Run terraform apply -target aws_lightsail_domain.example_domain to create the domain
  2. Create a container instance
  3. Add a DNS assignment through the Lightsail console
  4. Attempt to import the assignment by running terraform import terraform import aws_lightsail_domain_entry.example_domain_entry …

Debug Output

No response

Panic Output

goroutine 347 [running]:
github.com/hashicorp/terraform-provider-aws/internal/service/lightsail.FindDomainEntryById({0xe62f4c0, 0xc003caf5f0}, 0x0?, {0xc0055dc0f0?, 0xe6597b8?})
	github.com/hashicorp/terraform-provider-aws/internal/service/lightsail/find.go:178 +0x548
github.com/hashicorp/terraform-provider-aws/internal/service/lightsail.resourceDomainEntryRead({0xe62f4c0, 0xc003caf5f0}, 0xc0055f0b80, {0xd16ac40?, 0xc000337400?})
	github.com/hashicorp/terraform-provider-aws/internal/service/lightsail/domain_entry.go:114 +0x13f
github.com/hashicorp/terraform-provider-aws/internal/provider.wrappedReadContextFunc.func1({0xe62f4c0?, 0xc003caf5f0?}, 0x0?, {0xd16ac40?, 0xc000337400?})
	github.com/hashicorp/terraform-provider-aws/internal/provider/provider.go:806 +0x3e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xe62f4c0?, {0xe62f4c0?, 0xc003caf5f0?}, 0xd?, {0xd16ac40?, 0xc000337400?})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/resource.go:719 +0x87
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc001560460, {0xe62f4c0, 0xc003caf5f0}, 0xc0055f4ea0, {0xd16ac40, 0xc000337400})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/resource.go:1015 +0x585
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc000011e00, {0xe62f4c0?, 0xc003caedb0?}, 0xc00222f540)
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.25.0/helper/schema/grpc_provider.go:613 +0x4a5
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.muxServer.ReadResource({0xc0031c0060, 0xc0031c00c0, {0xc004893ba0, 0x2, 0x2}, {0x0, 0x0, 0x0}, {0x0, 0x0, ...}, ...}, ...)
	github.com/hashicorp/terraform-plugin-mux@v0.9.0/tf5muxserver/mux_server_ReadResource.go:26 +0x102
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc001ec1860, {0xe62f4c0?, 0xc003c9b5c0?}, 0xc0055de420)
	github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/tf5server/server.go:748 +0x4b1
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0xce7e9a0?, 0xc001ec1860}, {0xe62f4c0, 0xc003c9b5c0}, 0xc00226c310, 0x0)
	github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0041d14a0, {0xe63e4e0, 0xc0023741a0}, 0xc0044f9d40, 0xc0049b2d50, 0x14d6a910, 0x0)
	google.golang.org/grpc@v1.53.0/server.go:1336 +0xd23
google.golang.org/grpc.(*Server).handleStream(0xc0041d14a0, {0xe63e4e0, 0xc0023741a0}, 0xc0044f9d40, 0x0)
	google.golang.org/grpc@v1.53.0/server.go:1704 +0xa2f
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	google.golang.org/grpc@v1.53.0/server.go:965 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/grpc@v1.53.0/server.go:963 +0x28a

Important Factoids

No response

References

No response

Would you like to implement a fix?

No

@pludi pludi added bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels Mar 9, 2023
@github-actions
Copy link

github-actions bot commented Mar 9, 2023

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • 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.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the service/lightsail Issues and PRs that pertain to the lightsail service. label Mar 9, 2023
@justinretzolk
Copy link
Member

Hey @pludi 👋 Based on the import documentation for the aws_lightsail_domain_entry resource, the correct syntax for the identifier (the last bit of the import call, after the resource name in the Terraform configuration) is name _ domain_name _ type _ target (without the spaces between the underlines, GitHub flavored markdown is not liking that 😅). Based on a resource with the following definition:

resource "aws_lightsail_domain_entry" "example" {
  domain_name = "mydomain.com"
  name        = "www"
  type        = "A"
  target      = "127.0.0.1"
}

...the import would look like:

terraform import aws_lightsail_domain_entry.example www_mydomain.com_A_127.0.0.1

Can you test with this formatting and verify that the import is successful?

@justinretzolk justinretzolk added waiting-response Maintainers are waiting on response from community or contributor. and removed bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels Mar 9, 2023
@pludi
Copy link
Author

pludi commented Mar 10, 2023

Yes, that works. Still wouldn't expect a panic if the ID is off.

@github-actions github-actions bot removed the waiting-response Maintainers are waiting on response from community or contributor. label Mar 10, 2023
@brittandeyoung brittandeyoung added the bug Addresses a defect in current functionality. label Mar 16, 2023
@github-actions github-actions bot added this to the v4.59.0 milestone Mar 16, 2023
@github-actions
Copy link

This functionality has been released in v4.59.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!

@github-actions
Copy link

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 Apr 16, 2023
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. service/lightsail Issues and PRs that pertain to the lightsail service.
Projects
None yet
3 participants