EC2 Instance with an Admin Role
Ivy Jeptoo
Posted on July 18, 2023
Howdy!!!
Some time back we learnt how to create and EC2 Instance and we even connected to it, don't remember? Check it out here.
- Today we are going to create an Instance based on Amazon Linux AMI that will be connected via SSH. Using Security Groups, you will ensure that access to the instance is limited to your IP address only.
- The CLI will be pre-installed on the instance by default. This instance only needs permissions assigned. Once the instance is up and running, create an IAM role with admin access for your account. Add the role to your EC2 after that.
Table of Content
- Objectives
- Create a default Virtual Private Cloud
- Launch an EC2 instance
- Create an IAM Role
- Attach the Role to the EC2 Instance
- Connect to your EC2 instance
- Conclusion
Objectives
By the end of this article, you'll be able to:
- Launch a secure EC2 instance.
- Create IAM role with admin previleges
- Attach the IAM role to the your Instance.
- Connect to your EC2 instance via SSH
- Use CLI tool in the Instance.
Create a default Virtual Private Cloud
VPC is a private cloud computing environment contained within a public cloud and once can launch AWS resources in.
Check in your account if you already have a default VPC and if not, go to the VPC dashboard and create a default VPC.
Launch an EC2 instance
- I already have an article that covers launching EC2 but just to touch briefly on the steps:
- Under security limit access to your IP address only.
- If you do not have a SSH key be sure to download a new one.
N/B
This key-pair will allow you to log into your instance, using SSH, from your local machine. Save the key-pair carefully, because the same private key cannot be re-generated.
- Once you have launched your Instance, verify that it is running successfully.
Create an IAM Role
Identity and Access Management is used to specify who and what can access services and resources in AWS.
- On the IAM dashboard, select Roles
- Click on Create role button
- Select AWS service as the trusted entity and EC2 as the use case. This will allow the instance to whom the role will be attached to to be able to call any AWS service on your behalf.
- Under the permissions, search for AdministratorAccess in Filter policies textbox to apply to the role.
- Under the review section, provide a name to the new role.
Attach the Role to the EC2 Instance
- On the EC2 dashboard, check on the running instances and select the checkbox on the Instance we created earlier.
- Click the Actions button which will open a drop-down options, select the Security → Modify IAM role
- Select and apply the newly created role to your Instance
Connect to your EC2 instance
- We are going to connect to the EC2 instance using SSH, under Actions, click on Connect
- Follow the SSH steps to connect to the Instance.
- After connecting to the instance, you need to verify installation of AWS CLI
Conclusion
- This is a practical method for having a well configured, secure server that you can use for testing without worrying about credentials.
Happy cloud adventures!
Posted on July 18, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 29, 2024