Simplify and Secure Your Connections with AWS EC2 Instance Connect (EIC) Endpoint

Muhammad Bilal
6 min readJul 7, 2023

--

Table of Contents

  1. Introduction
  2. The Challenges of Traditional Connectivity
  3. Introducing Amazon EC2 Instance Connect (EIC) Endpoint
  4. How EIC Endpoint Works
  5. Benefits of Using EIC Endpoint
  6. Getting Started with EIC Endpoint
  7. Conclusion
  8. FAQs

1. Introduction

Connecting to your Amazon EC2 instances within your Amazon VPC over the Internet can be a complex process. However, with the introduction of Amazon EC2 Instance Connect (EIC) Endpoint, connecting securely has become much simpler. In this article, we will explore the features and benefits of EIC Endpoint and how it improves your connectivity experience.

2. The Challenges of Traditional Connectivity

In the traditional approach, connecting to EC2 instances within an Amazon VPC required a bastion host and configuring port forwarding. This setup added complexity and increased the operational burden for administrators. Managing and maintaining bastion hosts also raised security concerns.

3. Introducing Amazon EC2 Instance Connect (EIC) Endpoint

Amazon EC2 Instance Connect (EIC) Endpoint is a new feature that provides a secure and streamlined method to connect to your EC2 instances and other VPC resources from the Internet. With EIC Endpoint, you no longer need an Internet Gateway, public IP addresses, bastion hosts, or additional agents to establish connectivity. EIC Endpoint combines identity-based and network-based access controls to ensure secure connections.

4. How EIC Endpoint Works

EIC Endpoint acts as an identity-aware TCP proxy and offers two modes of connectivity:

  • AWS CLI Client Mode: In this mode, you create a secure WebSocket tunnel from your workstation to the EIC Endpoint using your AWS Identity and Access Management (IAM) credentials. Once the tunnel is established, you can connect to your EC2 instances by pointing your preferred client to the loopback address (127.0.0.1 or localhost).
  • Console Mode: When not using the AWS CLI, the Console provides a secure and seamless access to resources within your VPC. Authentication and authorization are evaluated before the traffic reaches the VPC, ensuring a secure connection.

5. Benefits of Using EIC Endpoint

Amazon EC2 Instance Connect (EIC) Endpoint offers several benefits that simplify and enhance your connectivity:

  • Simplified Connectivity: EIC Endpoint eliminates the need for an Internet Gateway, public IP addresses, and bastion hosts. This simplifies the connectivity process and reduces configuration complexity.
  • Enhanced Security: EIC Endpoint combines identity-based access controls and network-based controls, ensuring secure and isolated connections. It provides the necessary logging and control to meet your organization’s security requirements.
  • Operational Efficiency: With EIC Endpoint, administrators are relieved from the operational burden of managing and patching bastion hosts. This allows them to focus on other critical tasks and improves overall operational efficiency.
  • Flexibility with Tools: EIC Endpoint seamlessly integrates with the AWS Management Console and AWS Command Line Interface (CLI). It also allows you to continue using your favorite tools, such as PuTTY and OpenSSH, ensuring a smooth transition to the new connectivity method.

6. Getting Started with EIC Endpoint

To start using EIC Endpoint and establish a secure connection, follow these steps:

Step 1: Creating your EIC Endpoint

  • IAM Permissions and Security Groups: Before creating an EIC Endpoint, ensure that the user has the required IAM permissions. Additionally, any security groups associated with your VPC resources must have a rule to allow connectivity. Refer to the AWS documentation for detailed instructions on configuring security groups and sample IAM permissions.
  • Using the AWS CLI: The AWS CLI or Console can be used to create an EIC Endpoint. In this article, we will demonstrate the process using the AWS CLI. If you prefer using the Console, refer to the official documentation.
  • Creating an EIC Endpoint with the AWS CLI: Run the following command with your subnet ID ([SUBNET]) and security group ID ([SG-ID]) to create an EIC Endpoint using the AWS CLI:
aws ec2 create-instance-connect-endpoint \
--subnet-id [SUBNET] \
--security-group-id [SG-ID]

Once you have created the EIC Endpoint and granted the user IAM permission to create a tunnel, you can establish a connection to your Linux instances using SSH. There are two methods to connect:

  1. One-click command: To simplify the process of creating and rotating SSH keys, you can use the ec2-instance-connect ssh command from the AWS CLI. This command generates ephemeral keys for you to connect to your instance. Follow these steps:

Configure the AWS CLI with the necessary IAM permissions. Refer to the documentation for detailed instructions.

Once configured, run the following AWS CLI command to connect to your instance:

aws ec2-instance-connect ssh --instance-id [INSTANCE]

Upon running the command, you will be prompted to connect and can access your instance. The AWS CLI view will indicate a successful SSH connection.

2. Open-tunnel command: Another method to connect using SSH is through standard tooling or using the proxy command. Follow these steps:

To establish a private tunnel (TCP proxy) to the instance, run the following AWS CLI command:

ssh ec2-user@[INSTANCE] \
-i [SSH-KEY] \
-o ProxyCommand='aws ec2-instance-connect open-tunnel \
--instance-id %h'

Replace [INSTANCE] with the instance ID of your EC2 instance and [SSH-KEY] with the location and name of your SSH key. Make sure to refer to the documentation for guidance on using SSH keys.

Once the EIC Endpoint is configured, you can easily SSH into your EC2 instances without the need for a public IP or IGW using the AWS CLI.

7. Conclusion

Amazon EC2 Instance Connect (EIC) Endpoint provides a secure and simplified solution for connecting to your EC2 instances within your Amazon VPC. With EIC Endpoint, you can eliminate the complexities of traditional connectivity methods and enjoy enhanced security controls. By following the steps outlined in this article, you can create your EIC Endpoint, establish secure connections, and improve operational efficiency. Embrace the power of EIC Endpoint and streamline your connectivity experience.

8. FAQs

Q1: Can I create multiple EIC Endpoints in a single VPC?

No, only one EIC Endpoint is required per VPC. It provides connectivity to multiple instances within the VPC.

Q2: Do I need a public IP address for my EC2 instance to use EIC Endpoint?

No, EIC Endpoint eliminates the need for a public IP address on your EC2 instances. It allows you to securely connect to private instances within your VPC.

Q3: Can I still use long-lived SSH credentials with EIC Endpoint?

Yes, you can still use long-lived SSH credentials if you prefer to maintain existing workflows. However, it is recommended to utilize the ephemeral keys generated by EIC Endpoint for improved security.

Q4: Can I connect to instances via RDP using EIC Endpoint?

Yes, EIC Endpoint supports connectivity to instances via RDP as well. You can use the OpenTunnel API to establish the connection.

Q5: Can I control access to EIC Endpoint and monitor its activity?

Yes, IAM authorization is required to create and control EIC Endpoints. All API calls related to EIC Endpoint configuration and connections are recorded in AWS CloudTrail, providing centralized logging and monitoring capabilities.

--

--

Muhammad Bilal

I am an aspiring DevOps Guy. Learning new things related to AWS and Devops