AWS- Amazon Web Services
3 min read
Amazon Web Services is one of the most popular Cloud Providers that have a free tier too for students and Cloud enthusiasts for their Hands-on while learning
Task1:
Create an IAM user with the username of your own wish and grant EC2 Access. Launch your Linux instance through the IAM user that you created now and install Jenkins and Docker on your machine via a single Shell Script.
- go to the AWS website and create an account. Then, go to the EC2 instance and launch the instance.
- Name the server.
- Select the appropriate machine, and select free tier services
- Choose a free tier instance. generate a key pair (it helps to connect the server with the SSH client). It will download
- Launch instance
- The server is created.
Connect with SSH client. click on Connect and copy the ssh command. cd to Download and paste the ssh command.
create a file.sh and copy the command list in the file and save it:
#!/bin/bash # Update the system sudo apt update sudo apt upgrade -y # Install Jenkins sudo apt install openjdk-11-jdk -y wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add - sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' sudo apt update sudo apt install jenkins -y # Install Docker sudo apt-get update sudo apt-get install docker.io # Add user to the docker group (optional) sudo usermod -aG docker $USER # Restart Jenkins and Docker services sudo systemctl restart jenkins sudo systemctl restart docker
chmod +x file.sh
run the command to make the file.sh executablerun
./file.sh
congratulation!! docker and Jenkins be installed in the ec2 instance.
Task 2
To create three IAM users for the DevOps team of Avengers and assign them to a DevOps group with an IAM policy, you can follow these steps:
Log in to the AWS Management Console and navigate to the IAM service.
Create a new group for the DevOps team:
Click on "Groups" in the left navigation pane.
Click on the "Create New Group" button.
Provide a name for the group, such as "DevOpsGroup", and click "Next Step".
Attach the necessary policies related to DevOps, such as AWSCodeCommitFullAccess, AWSCodeDeployFullAccess, AWSCodePipelineFullAccess, and any other relevant policies.
Click "Create Group" to finish creating the group.
Create three IAM users for the DevOps team:
Click on "Users" in the left navigation pane.
Click on the "Add user" button.
Provide a name for the user, such as "IronMan", and select "Programmatic access" as the access type.
Click "Next: Permissions".
Choose "Add user to group" and select the "DevOpsGroup" you created earlier.
Click "Next: Tags" (optional) and add any relevant tags.
Click "Next: Review".
Review the user details and click "Create user".
Repeat these steps to create two more users.
Once you have created the IAM users and assigned them to the DevOps group, you can create an IAM policy to provide specific permissions to the group. Here's an example IAM policy that allows the DevOps group to manage EC2 instances:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DevOpsGroupEC2Permissions",
"Effect": "Allow",
"Action": [
"ec2:Describe*",
"ec2:RunInstances",
"ec2:StartInstances",
"ec2:StopInstances",
"ec2:TerminateInstances"
],
"Resource": "*"
}
]
}
You can create this policy by following these steps:
Go to the IAM service in the AWS Management Console.
Click on "Policies" in the left navigation pane.
Click on the "Create policy" button.
Select the "JSON" tab and paste the above policy.
Click on "Review policy".
Provide a name for the policy, such as "DevOpsEC2Policy", and optionally add a description.
Click on "Create policy".
Finally, attach the "DevOpsEC2Policy" to the "DevOpsGroup" by editing the group's permissions and attaching the policy.