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

VPN Client Endpoint Route Creation #7831

Closed
dimisjim opened this issue Mar 6, 2019 · 9 comments
Closed

VPN Client Endpoint Route Creation #7831

dimisjim opened this issue Mar 6, 2019 · 9 comments
Labels
enhancement Requests to existing resources that expand the functionality or scope. new-resource Introduces a new resource. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@dimisjim
Copy link
Contributor

dimisjim commented Mar 6, 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

Description

As of now, there is a lack of a route creation resource to accompany the ones currently available that do the initial tasks of endpoint creation:

There is currently an open pull request (#7564) to rework the initial resource to include the authorization ingress, but not the route creation. Relevant developer: @slapula

New or Affected Resource(s)

  • aws_ec2_client_vpn_endpoint
  • aws_ec2_client_vpn_network_association

References

@dimisjim dimisjim added the enhancement Requests to existing resources that expand the functionality or scope. label Mar 6, 2019
@bflad bflad added the service/ec2 Issues and PRs that pertain to the ec2 service. label Mar 6, 2019
@IOficient

This comment has been minimized.

@thrixton
Copy link

As a workaround, it is possible to automate this via the CLI until this is implemented

resource "null_resource" "client_vpn_route_internet" {
  provisioner "local-exec" {
    when    = "create"
    command = "aws ec2 create-client-vpn-route --client-vpn-endpoint-id ${aws_ec2_client_vpn_endpoint.client_vpn.id} --destination-cidr-block 0.0.0.0/0 --target-vpc-subnet-id ${aws_subnet.subnet_az1.id} --profile ${var.profile}"
  }

  provisioner "local-exec" {
    when    = "destroy"
    command = "aws ec2 delete-client-vpn-route --client-vpn-endpoint-id ${aws_ec2_client_vpn_endpoint.client_vpn.id} --destination-cidr-block 0.0.0.0/0 --target-vpc-subnet-id ${aws_subnet.subnet_az1.id} --profile ${var.profile}"
  }
}

@jrosen
Copy link

jrosen commented Nov 12, 2019

You can also use a cloudformation stack resource :

resource "aws_cloudformation_stack" "public_route" {
  name = "PublicRoute"
  parameters = {
    TargetCidr = "0.0.0.0/0"
    SubnetId = "${var.subnet_id}"
    Description = "Route for vpn to go to outside world"
    ClientVpnEndpointId = "${aws_ec2_client_vpn_endpoint.client_vpn.id}"
  }

  template_body = <<STACK
Parameters:
  TargetCidr:
    Type: String
  SubnetId:
    Type: String
  Description:
    Type: String
  ClientVpnEndpointId: 
    Type: String
Resources:
  Route:
    Type: AWS::EC2::ClientVpnRoute
    Properties: 
      ClientVpnEndpointId: !Ref ClientVpnEndpointId
      Description: !Ref Description
      DestinationCidrBlock: !Ref TargetCidr
      TargetVpcSubnetId: !Ref SubnetId
STACK
}

@syquus
Copy link

syquus commented Dec 16, 2019

As a workaround, it is possible to automate this via the CLI until this is implemented

resource "null_resource" "client_vpn_route_internet" {
  provisioner "local-exec" {
    when    = "create"
    command = "aws ec2 create-client-vpn-route --client-vpn-endpoint-id ${aws_ec2_client_vpn_endpoint.client_vpn.id} --destination-cidr-block 0.0.0.0/0 --target-vpc-subnet-id ${aws_subnet.subnet_az1.id} --profile ${var.profile}"
  }

  provisioner "local-exec" {
    when    = "destroy"
    command = "aws ec2 delete-client-vpn-route --client-vpn-endpoint-id ${aws_ec2_client_vpn_endpoint.client_vpn.id} --destination-cidr-block 0.0.0.0/0 --target-vpc-subnet-id ${aws_subnet.subnet_az1.id} --profile ${var.profile}"
  }
}

This solution will become sooner or later strictly invalid. As latest versions of Terraform show, they are gliding more into invalidate references to other resources during the destroy phase, as they can "cause dependency cycles and interact poorly with create_before_destroy".

My latest runs are showing:

Warning: External references from destroy provisioners are deprecated

Destroy-time provisioners and their connection configurations may only
reference attributes of the related resource, via 'self', 'count.index', or
'each.key'.

References to other resources during the destroy phase can cause dependency
cycles and interact poorly with create_before_destroy.

@woz5999
Copy link
Contributor

woz5999 commented May 15, 2020

Does anyone know the best way to get the submitted PR reviewed?

The null_resource workaround will cease to work in terraform 0.13 when specifying non-self var references in destroy provisioners will be treated as an error.

@angelabad
Copy link
Contributor

Hi, I dont know why my PR isnt reviewed :-(

@woz5999
Copy link
Contributor

woz5999 commented May 21, 2020

@bflad @gdavison
can you provide some guidance to help get this reviewed and merged? this is a pretty painful shortcoming and as mentioned above, the current workarounds will break with the next release of terraform. Thanks.

@gdavison gdavison added the new-resource Introduces a new resource. label Jun 12, 2020
@breathingdust
Copy link
Member

This has been released in version 2.70.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 for triage. Thanks!

@ghost
Copy link

ghost commented Aug 10, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Aug 10, 2020
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. new-resource Introduces a new resource. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
10 participants