Skip to content

uridium/terraform-aws-ec2-connect-endpoint

Repository files navigation

Terraform AWS EC2 Instance Connect Endpoint module

GitHub Actions GitHub Actions Latest tag

Terraform AWS module which manages an EC2 Instance Connect Endpoint.

EC2 Instance Connect Endpoint allows you to connect to an instance without requiring the instance to have a public IPv4 address. You can connect to any instances that support TCP.

Usage

module "ec2-connect-endpoint" {
  source = "git@github.com:uridium/terraform-aws-ec2-connect-endpoint.git"

  name               = "connect-endpoint"
  subnet_id          = "subnet-0123456789"
  security_group_ids = ["sg-0123456789"]
}

Notes

  • Only ports 22 and 3389 are supported.

  • EC2 Instance Connect Endpoint doesn't support connections to an instance using IPv6 addresses.

  • When client IP preservation is enabled, the instance to connect to must be in the same VPC as the EC2 Instance Connect Endpoint.

  • Client IP preservation is not supported when traffic is routed through an AWS Transit Gateway.

  • The following instance types do not support client IP preservation: C1, CG1, CG2, G1, G2, HI1, M1, M2, M3, and T1. If you are using these instance types, set the preserveClientIp parameter to false, otherwise attempting to connect to these instance types using EC2 Instance Connect Endpoint will fail.

For more information click here

Examples

Development

This module uses pre-commit hook to identify simple issues before pushing code to the remote repository, and to generate documentation.

Install pre-commit:

pip install pre-commit

Install the git hook scripts:

pre-commit install

Now pre-commit will run automatically on every git commit.

It's usually a good idea to run the hooks against all of the files when adding new hooks (usually pre-commit will only run on the changed files during git hooks):

pre-commit run -av

Requirements

Name Version
terraform >= 1.5.0
aws >= 5.0
tls >= 4.0

Providers

Name Version
aws 5.11.0

Modules

No modules.

Resources

Name Type
aws_ec2_instance_connect_endpoint.this resource

Inputs

Name Description Type Default Required
name Name to be used as a tag string n/a yes
preserve_client_ip Indicates whether your client's IP address is preserved as the source bool true no
security_group_ids One or more security groups to associate with the endpoint list(string) n/a yes
subnet_id The ID of the subnet in which to create the EC2 Instance Connect Endpoint string n/a yes

Outputs

Name Description
availability_zone The availability zone of the endpoint
id The ID of the EC2 Connect Endpoint
security_group_ids One or more security groups associated with the endpoint
subnet_id The ID of the endpoint subnet
vpc_id The VPC ID in which the endpoint is created