In this post, we'll explore how to utilise AWS Session Manager to access an EC2 instance without the need for a PEM file.
Create IAM Role
Before diving into the creation of an EC2 instance, it's essential to set up an IAM (Identity and Access Management) role. IAM roles help in securely granting permissions that your EC2 instance will need.
- Navigate to the IAM dashboard in your AWS console.
- Create a new role and attach the
AWSSSMManagedInstanceCore
policy to it.
Important: Select the correct service use case. Choosing the wrong service will prevent this role from appearing when setting up your EC2 instance.
Create EC2 Instance
Now, let's create our EC2 instance
- Head over to the EC2 dashboard and click the
Launch instance
button.
- In the network settings, ensure
Auto-assign Public IP
is enabled. Select your desired security group.
- Under
Advanced Details
, choose the IAM role you created earlier.
- Review your settings in the Summary section and then launch the instance.
- A popup will appear since we haven't created a new key pair (PEM file). As we're using Session Manager, click on the
Proceed without key pair
option.
Access an EC2 Instance via AWS Console
Once your EC2 instance is up and running,
- Click on the instance ID in the EC2 dashboard.
- Hit the
Connect
button.
- You can now access the EC2 instance through AWS Session Manager.
Note: In this tutorial, we've created an EC2 instance within the default VPC and assigned a public IP to it. Depending on your VPC settings, the 'Connect' button might be disabled. Make sure to verify your VPC settings if you encounter this issue.
You've successfully accessed an EC2 instance without a PEM file using AWS Session Manager!
Don't forget to terminate your EC2 instance once you're done.😉
Top comments (0)