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

vpc_endpoint creation should enable Private DNS only after endpoint creation #7148

Closed
craiglink opened this issue Jan 15, 2019 · 6 comments · Fixed by #37628
Closed

vpc_endpoint creation should enable Private DNS only after endpoint creation #7148

craiglink opened this issue Jan 15, 2019 · 6 comments · Fixed by #37628
Assignees
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.
Milestone

Comments

@craiglink
Copy link

craiglink commented Jan 15, 2019

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 "me too" comments, 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 Version

Terraform v0.11.11
provider.aws: version = "~> 1.55"

Affected Resource(s)

  • resource aws_vpc_endpoint

Terraform Configuration Files

resource "aws_vpc_endpoint" "ec2" {
  vpc_id            = "${aws_vpc.main.id}"
  service_name      = "com.amazonaws.us-west-2.ec2"
  vpc_endpoint_type = "Interface"

  security_group_ids = [
    "${aws_security_group.sg1.id}",
  ]

  private_dns_enabled = true
}

Behavior

When the resource creates the vpc endpoint and enables private DNS, it creates short service outage because the DNS record becomes available before the endpoint is actually available. Because terraform is declarative, there is not a way to define a two-stage object creation, thus this behavior needs to be fixed in the provider or AWS SDK or service ( a feature request has been openned with AWS too )

To solve this via terraform, the provider could create the vpc endpoint without the Private DNS enable and then upon successful creation of the endpoint, modify it to enable Private DNS ( provided private_dns_enabled was set to true )

@bflad bflad added the service/ec2 Issues and PRs that pertain to the ec2 service. label Jan 16, 2019
@aeschright aeschright added the needs-triage Waiting for first response or review from a maintainer. label Jun 24, 2019
@aeschright aeschright added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 20, 2019
@ewbankkit
Copy link
Contributor

@craiglink Terraform will wait until the VPC endpoint has available status before declaring the resource successfully created. Is there any way you can avoid using the newly resolving DNS record until the Terraform resource is created?

@rmlsun
Copy link

rmlsun commented Feb 4, 2022

@ewbankkit It makes more sense to me to break out this private dns enablement attribute into a separate terraform resource. Below is my reasoning. (use VPCE for VPC endpoint for brevity)

It's more than the service consumer's need to wait for the available endpoint status. Rather, it's about one of Terraform's key values: auto detection and management of the order/sequence of resource provisioning with dependency among multiple discrete terraform resources.

Due the lifecycle of AWS interface VPCE, an interface VPCE initially will be always in a pending state. If the endpoint service provider chooses to not turn on auto-acceptance of interface VPCE connection request from a service consumer, an extra accept request action is needed before the interface VPCE state can transition to available.

Now this extra accept request action could be automated via terraform as well (and in our case, the vendor does have custom terraform provider for us (as service consumer) to trigger this accept request action with proper authN/Z).

So for the whole flow to work in terraform with the proper dependency chain, there needs to be 3 discrete terraform resource:
1). interface VPCE provision
2). accept endpoint connection request (via service provider terraform provider and in turn their API, probably with authN/Z)
3). interface VPCE private DNS enablement

With the current VPCE resource design bundling 1) and 3) into one single TF resource, it's impossible to properly automate the whole flow via terraform (unless the service provider turn on VPCE auto-accept).

@sqlbot
Copy link

sqlbot commented Sep 1, 2022

A much more severe manifestation of this issue arises when attempting to use aws_vpc_endpoint to create an endpoint for a non-AWS service created elsewhere with aws_vpc_endpoint_service using acceptance_required = true. It's not possible.

| Error: creating EC2 VPC Endpoint (com.amazonaws.vpce.us-gov-east-1.vpce-svc-xxxx): InvalidParameter: Private DNS can only be enabled after the endpoint connection is accepted by the owner of com.amazonaws.vpce.us-gov-east-1.vpce-svc-xxxx.
│       status code: 400, request id: 8f53996a-6968-4164-9003-xxxxxxxxxxxx
│
│   with aws_vpc_endpoint.this,
│   on main.tf line 28, in resource "aws_vpc_endpoint" "this":
│   28: resource "aws_vpc_endpoint" "this" {

The provider is attempting an action that the underlying API will always deny on a service that requires acceptance. There is no opportunity to use aws_vpc_endpoint_connection_accepter because the Terraform aws_vpc_endpoint resource has not been and cannot be created.

The only workaround appears to be to set private_dns_enabled = false inside aws_vpc_endpoint, then terraform apply, then change to private_dns_enabled = true and terraform apply again.

This is definitely not viable. The provider almost certainly needs to wait for available before ever attempting to set the value to true.

Terraform v1.2.1 on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v4.28.0

@jar-b jar-b self-assigned this Apr 26, 2024
@terraform-aws-provider terraform-aws-provider bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Apr 26, 2024
Copy link

Warning

This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

@github-actions github-actions bot added this to the v5.51.0 milestone May 23, 2024
@github-actions github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label May 24, 2024
Copy link

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

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 Jun 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants