Welcome back, cloud adventurers! Today's foray into AWS is all about automating our setup. Why spend time on manual tasks when we have automation magic at our fingertips? Let's dive into automating EC2 instance setups and understanding the depths of IAM! π€π
AWS: Your Cloud Playground π‘
Amazon Web Services offers a versatile platform with a generous free tier, perfect for students and cloud enthusiasts to get hands-on experience.
- Start Exploring: Sign up for a free AWS account and begin your cloud journey.
User Data: The Automation Wizardry in EC2 π§ββοΈ
User data scripts in EC2 are like your personal house-elves, performing setup tasks diligently as soon as your instance comes to life.
What's User Data?: It's a set of commands that run the moment your instance starts, automating tasks like installing software.
Types of User Data: You can use shell scripts or cloud-init directives.
How to Pass User Data: Input it as plain text, upload a file in the launch wizard, or encode it in base64 for API calls.
Learn More: Get all the details about EC2 user data.
IAM: The Sentinel of AWS Resources π‘οΈ
AWS Identity and Access Management (IAM) ensures that only authorized eyes gaze upon your AWS treasures.
IAM Insights: Centralize your AWS permissions management with IAM. Control who gets the keys to your kingdom.
Deep Dive into IAM: To truly master IAM, swim in the knowledge pool.
Task 1: Launching an EC2 Instance with Jenkins π
Step 1: Navigate to the EC2 dashboard and click 'Launch Instance'.
Step 2: Choose an Amazon Machine Image (AMI) that suits your Jenkins requirements.
Step 3: Select the instance type and then head to the 'Configure Instance' section.
Step 4: In the 'Advanced Details' section, paste your Jenkins installation script into the User Data field.
#!/bin/bash
sudo apt update
sudo apt install fontconfig openjdk-17-jre -y
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian-stable
binary/ | sudo tee \ /etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins -y
Step 5: Proceed to launch the instance.
Step 6: SSH into Your Instance:
- Use SSH to log into your EC2 instance with the appropriate credentials (key-pair file).
Step 7: Find the InitialAdminPassword:
Retrieve the automatically generated administrator password from your Jenkins installation.
Copy the password displayed on the terminal. This is required for the initial setup of Jenkins.
Step 8: Access Jenkins in a Web Browser:
Open your web browser and navigate to your EC2 instance's public IP address followed by
:8080
(e.g.,http://ec2-instance-public-ip:8080
).This will bring you to the Jenkins unlock screen.
Step 9: Unlock Jenkins:
Paste the copied password into the "Administrator password" field.
Click "Continue".
Step 10: Install Suggested Plugins:
You will be prompted to install plugins. Choose "Install suggested plugins", which includes commonly used plugins that are helpful for most projects.
Jenkins will begin installing the plugins. This process may take a few minutes.
Step 11: Create Admin User:
After the plugins are installed, you'll be prompted to create a user with admin privileges.
Fill in the username, password, full name, and email address fields.
Click "Save and Continue".
Step 12: Instance Configuration:
Jenkins will ask for the URL of the instance which will be pre-filled with your instance's public IP and port. You can simply confirm by clicking "Save and Finish".
Ready to Use:
Click "Start using Jenkins" to go to the Jenkins dashboard.
Task 2: IAM Roles Deciphered and Created π
Understanding IAM Roles: Think of IAM roles as costumes that AWS services can don to gain specific powers needed for their tasks.
IAM Users vs. Groups vs. Roles:
IAM Users: Individual identities with a set of credentials.
IAM Groups: Collections of users under a shared set of permissions.
IAM Roles: A set of permissions that can be assumed by any entity, whether it's a user, an AWS service, or an application.
Creating IAM Roles for the DevOps Avengers π¦Έ
Step 1: Open the IAM dashboard within your AWS console.
Step 2: Click on 'Roles' then 'Create role'.
Step 3: Select the type of trusted entity. For instance, choose 'AWS service' for roles that AWS services will assume.
Step 4: Attach permissions policies that align with the responsibilities of the role. For example:
DevOps-User: Policies that provide access to CI/CD tools, monitoring, and logging services.
Test-User: Policies that allow viewing and interacting with development and staging environments.
Admin: Full access policies, perhaps with administrative privileges across AWS services.
Step 5: Review, name your role (e.g., 'DevOps-User'), and create it.
Step 6: Repeat for 'Test-User' and 'Admin' roles.
Verifying Your Roles π΅οΈββοΈ
Once created, navigate to each role and review the permissions summary to ensure they have the intended access.
Document the policies attached to each role and understand the level of access provided.
Wrapping Up Day 22 π
With Jenkins automation and IAM roles under our belt, our AWS journey is becoming more thrilling. Automation saves us precious time, and IAM roles ensure that this power is wielded wisely.
Keep soaring through the clouds, and rememberβautomation is the future, and with AWS, we're building it one script at a time. #Day22 #AWSAutomation #IAMRoles #DevOpsAvengers #CloudSecurity
Thank you for reading this Blog. Hope you learned something new today! If you found this blog helpful, please like, share, and follow me for more blog posts like this in the future.
You can connect with me at: https://www.linkedin.com/in/davendersingh/