Day 38 of 90 Days of DevOps Challenge: Getting Started with AWS Basics
Congratulations!!! 🎉 You've come a long way, and it's amazing to see your persistence! Let's not let excuses get in the way of maintaining that consistency. Today, we're kicking off our journey into AWS—one of the most powerful cloud platforms. By now, you might have created multiple EC2 instances. If not, don't worry—let's start fresh!
AWS: The Cloud Powerhouse ☁️
Amazon Web Services (AWS) is one of the leading cloud service providers. It offers a free tier that is great for students and cloud enthusiasts looking to get hands-on experience while learning. If you don't have an AWS account yet, create your free account here and start exploring the world of cloud computing!
IAM: Securely Manage Access 🔐
AWS Identity and Access Management (IAM) is a web service that allows you to securely manage who can access your AWS resources and what they can do with them. IAM enables you to control authentication (who can sign in) and authorization (what actions they can perform) on your AWS infrastructure.
With IAM, you can:
Create and manage users and groups
Assign granular permissions to control access to AWS resources
Securely manage credentials like passwords and access keys
Today's Tasks:
Task 1: Create an IAM User and Launch an EC2 Instance
Step 1: Create an IAM User with EC2 Access
Log in to your AWS Management Console.
Navigate to the IAM Dashboard.
In the left-hand menu, click on Users, then click Add users.
Enter a username of your choice (e.g.,
devops_user
).Under Select AWS access type, check the box for Programmatic access (for CLI and SDK) and AWS Management Console access.
Click Next: Permissions.
Choose Attach existing policies directly and search for AmazonEC2FullAccess to grant the new user full access to EC2.
Click Next: Tags, then Next: Review, and Create user.
Download the access keys provided or copy them (you’ll need them later for CLI access).
Step 2: Launch an EC2 Instance via IAM User
Log in as the IAM user you just created or configure the AWS CLI with the new IAM user’s access keys using:
aws configure
Enter the Access Key ID, Secret Access Key, region, and output format.
Launch a Linux EC2 instance:
aws ec2 run-instances --image-id <ami-id> --instance-type t2.micro --key-name <key-pair-name> --security-group-ids <security-group-id> --subnet-id <subnet-id>
Make sure to replace
<ami-id>
,<key-pair-name>
,<security-group-id>
, and<subnet-id>
with appropriate values.OR
Connect using ssh(what I did):
Step 3: Install Jenkins and Docker via Shell Script
Create a shell script to install Jenkins and Docker:
#!/bin/bash # Update the instance sudo apt update -y # Install Docker sudo apt install docker -y sudo service docker start sudo usermod -aG docker ec2-user # Install Jenkins sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key sudo apt install jenkins java-1.8.0-openjdk-devel -y sudo systemctl start jenkins sudo systemctl enable jenkins
Save this script as
install_jenkins_
docker.sh
and copy it to your instance.Run the script on the EC2 instance to install Jenkins and Docker:
bash install_jenkins_docker.sh
Task 2: Create a DevOps Team of Avengers with IAM Policy
Step 1: Create IAM Users
Go to the IAM Dashboard.
Click on Users > Add users.
Add 3 users (e.g.,
IronMan
,CaptainAmerica
,Thor
) and give them Programmatic access.Click Next: Permissions.
Step 2: Create a DevOps Group with IAM Policy
In the IAM Dashboard, click on User groups > Create group.
Name the group (e.g.,
DevOpsTeam
).Attach a policy, like
AdministratorAccess
, or create a custom policy with limited permissions for DevOps tasks (e.g., access to EC2, S3).Click Create group.
Step 3: Assign Users to the Group
Go to Users, click on each user (e.g.,
IronMan
,CaptainAmerica
,Thor
), and select Add user to group.Add them to the
DevOpsTeam
group.
Now you have your DevOps Avengers team set up with IAM policies!
By the end of today, you'll have a better understanding of how to use AWS IAM and EC2 to manage permissions and automate tasks. You're on your way to becoming a cloud expert!
Stay consistent, and keep learning! 🌟