{"id":4118,"date":"2023-11-04T23:14:04","date_gmt":"2023-11-04T23:14:04","guid":{"rendered":"http:\/\/localhost:10003\/creating-custom-ami-using-ec2-image-builder\/"},"modified":"2023-11-05T05:47:59","modified_gmt":"2023-11-05T05:47:59","slug":"creating-custom-ami-using-ec2-image-builder","status":"publish","type":"post","link":"http:\/\/localhost:10003\/creating-custom-ami-using-ec2-image-builder\/","title":{"rendered":"Creating custom AMI using EC2 Image Builder"},"content":{"rendered":"
Amazon Machine Images (AMIs) are pre-configured virtual machines used to launch instances in Amazon Elastic Compute Cloud (EC2). An AMI includes an operating system, applications, libraries, and other dependencies needed to run an instance. Creating custom AMIs allows users to launch instances with the desired software stack installed. In this tutorial, we will walk through the process of creating a custom AMI using Amazon EC2 Image Builder.<\/p>\n
To follow along with this tutorial, you will need the following:<\/p>\n
To create a custom AMI, start by launching an EC2 instance with the desired operating system and software stack installed. For this tutorial, we will use an Ubuntu 20.04 LTS instance.<\/p>\n
After the EC2 instance is launched, connect to it using SSH and configure it to install the necessary software packages, libraries, and dependencies for your software stack. For this tutorial, we will install the Apache web server.<\/p>\n
sudo apt update\nsudo apt upgrade -y\n<\/code><\/pre>\n\n- Install the Apache web server by running the following command:<\/li>\n<\/ol>\n
sudo apt install apache2 -y\n<\/code><\/pre>\n\n- Verify that the Apache web server is running by navigating to the public IP address of the instance in a web browser. If Apache is installed correctly, you should see the default Apache web page.<\/li>\n<\/ol>\n
Step 3: Create an EC2 Image Builder recipe<\/h1>\n
After the EC2 instance is configured with the desired software stack, create an EC2 Image Builder recipe to automate the creation of a custom AMI.<\/p>\n
\n- Open the EC2 Image Builder console and select “Create Image Recipe”.<\/li>\n
- Choose a name and a description for the recipe.<\/li>\n
- For the “Base AMI” field, select the Ubuntu 20.04 LTS AMI that was used to launch the EC2 instance.<\/li>\n
- Under “Component Configuration”, select “Add Component” and choose “Shell Script”.<\/li>\n
- Enter a name and description for the script and add the following commands to install and configure Apache:<\/li>\n<\/ol>\n
#!\/bin\/bash\nsudo apt update\nsudo apt upgrade -y\nsudo apt install apache2 -y\nsudo systemctl enable apache2\n<\/code><\/pre>\n\n- Save the recipe.<\/li>\n<\/ol>\n
Step 4: Create an EC2 Image Builder pipeline<\/h1>\n
After the recipe is created, use it to create an EC2 Image Builder pipeline that will automate the process of creating custom AMIs.<\/p>\n
\n- Open the EC2 Image Builder console and select “Create Image Pipeline”.<\/li>\n
- Choose a name and description for the pipeline.<\/li>\n
- Under “Source”, select “EC2 Image Recipe” and choose the recipe that was created in Step 3.<\/li>\n
- Under “Distribution Configuration”, select “My Distribution Configuration” or choose an existing configuration that specifies the settings for the custom AMI.<\/li>\n
- Under “Setup”, specify the S3 bucket and IAM role that Image Builder will use to create and store the custom AMI.<\/li>\n
- Save the pipeline.<\/li>\n<\/ol>\n
Step 5: Build the custom AMI<\/h1>\n
After the pipeline is created, start the pipeline to build the custom AMI.<\/p>\n
\n- Open the EC2 Image Builder console, select the pipeline that was created in Step 4, and click on “Build Image”.<\/li>\n
- Choose a name and description for the custom AMI.<\/li>\n
- Wait for the pipeline to complete the image build process.<\/li>\n
- Verify that the custom AMI is available in the specified S3 bucket.<\/li>\n<\/ol>\n
Conclusion<\/h1>\n
Custom AMIs allow users to launch EC2 instances with the software stack and configurations that are required by their applications. With Amazon EC2 Image Builder, creating and managing custom AMIs becomes an automated and streamlined process. By following the steps outlined in this tutorial, users can create custom AMIs using EC2 Image Builder in an efficient and scalable manner.<\/p>\n","protected":false},"excerpt":{"rendered":"
Introduction Amazon Machine Images (AMIs) are pre-configured virtual machines used to launch instances in Amazon Elastic Compute Cloud (EC2). An AMI includes an operating system, applications, libraries, and other dependencies needed to run an instance. Creating custom AMIs allows users to launch instances with the desired software stack installed. In Continue Reading<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[1],"tags":[317,1352,30,1353,1351,1354,1355,1350],"yoast_head":"\nCreating custom AMI using EC2 Image Builder - Pantherax Blogs<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\t\n