Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

How to create an EC2 instance in AWS using Ansible automation

June 5, 2023
Deepankar Jain
Related topics:
Automation and management
Related products:
Red Hat Ansible Automation PlatformRed Hat Ansible Automation Platform from AWS

    In our previous article, we explored how to use the Red Hat Ansible Automation Platform CLI to create an Elastic Compute Cloud (EC2) in Amazon Web Services (AWS). This time, we will take things a step further and leverage the power of the Ansible Automation Platform to automate the process. Ansible Automation Platform is a powerful tool that enables you to manage your infrastructure more efficiently with less manual intervention.

    Follow the series:

    Part 1: How to create an EC2 instance on AWS using Ansible CLI

    Part 2: How to create an EC2 instance in AWS using Ansible Automation

    Part 3: How to create EC2 instance on AWS using Ansible workflow

    By using Ansible Automation Platform, we can create a streamlined process for deploying EC2s in AWS, reducing errors and saving time. In this article, we will dive into the details of how to use Ansible Automation Platform to create instances in AWS and explore the benefits of using this powerful automation tool.

    How to create credentials

    Follow these steps to create your credentials as referenced in Figure 1:

    • Navigate to the Credentials Tab under Resources in Ansible Automation Platform.
    • Select Amazon Web Services under Credential type.
    • Add your access key and secret key, then save it.
      A screenshot of the Ansible create AWS credentials page.
      Figure 1: The Ansible create credentials page.

    Creating and configuring the project

    Follow these steps to create and configure your project:

    • Install Ansible Automation Platform by following the instructions in the article How to install Red Hat Ansible Automation Platform on RHEL 9.
    • Log in to Ansible Automation Platform portal in the browser.
    • Navigate to the Projects tab under Resources in the left pane.
    • Click on the Add button to create a new project.
    • Enter a name for the project and choose Git as the source control type with the URL https://github.com/redhat-developer-demos/ansible-automation-platform-cloud-solutions in the Source Control URL field. (If you're interested in checking out the Ansible playbooks, you can find them on GitHub.)
    • Save the changes and wait for the operation to complete successfully, as shown in Figure 2.
    A screenshot of the form for configuring the project source control in Ansible.
    Figure 2: Configuring the project source control.

    Creating and configuring the job template

    Follow these steps to create and configure the job template:

    • Go to the Templates tab under Resources in the left pane.
    • Click on the Add button and select Job template from the options.
    • Enter a name for the job you want to create.
    • In the Inventory section, select the Demo-Inventory or Default inventory.
    • In the Project section, click on the project name you previously created and select the AWS/create_ec2instance.yml file.

    Configuring the variables and execution environment

    • Click on the Variables section.
    • Add the variables as follows:
    
    ---
    
    region: ap-south-1
    
    instance_type: t3.micro
    
    ami: ami-0f9d9a251c1a44858
    
    key_name: ansible-demo
    
    vpc_name: ansible-vpc-test
    
    cidr_block: "10.10.0.0/16"
    
    cidr: "10.10.0.0/24"
    • Select the credentials you previously created under the selected category, as shown in Figure 3.
    A screenshot of the form for AWS credentials secure authentication.
    Figure 3: Selecting pre-configured AWS credentials for secure authentication.
    • Select the default execution environment, as shown in Figure 4. 
    A screenshot of where to Select the default execution environment in Ansible.
    Figure 4: Selecting the default execution environment.
    • Save your changes by clicking the Save button.
    • Finally, launch the job by clicking on the Launch button.
    • Once the job is launched using Ansible Automation Platform, the system will generate an output that should be similar to Figure 5.
    A screenshot of the output from the job in Ansible.
    Figure 5: Output from the job.

    The output will display the status of the job and the progress of the instance creation process, as shown in Figure 6.

    A screenshot of the EC2 instance created in AWS.
    Figure 6: Showing the EC2 Instance in AWS.

    What’s next?

    In this article, we explored how to use Ansible Automation Platform to create an EC2 instance in Amazon Web Services. We demonstrated how Ansible Automation Platform can streamline the process of deploying EC2s in AWS, making it more efficient and less error-prone. By using the power of automation, we can save time and free up resources to focus on other important tasks.

    To explore more of what Ansible Automation Platform has to offer, visit the official website to download and get started. Additionally, there are various e-books available to help you explore the capabilities of Ansible Automation Platform such as:

    • Automation at the edge
    • Choosing an automation tool
    • An IT executive's guide to automation

    There is also a cheat sheet for WiFi automation with Ansible and SD that provides a quick reference for network automation tasks.

    In the final article of this series, we go even further by exploring how to simplify the process of creating an EC2 instance in AWS using workflow templates to optimize infrastructure management. Workflow templates standardize the process of creating instances and reduce the amount of manual intervention required. 

    Last updated: January 11, 2024

    Related Posts

    • How we automate everything at Red Hat Open Innovation Labs

    • How to install Red Hat Ansible Automation Platform on RHEL 9

    • How to install VMs and Ansible Automation Platform on Mac M1

    • Using OpenShift with AWS Services and Features

    Recent Posts

    • Every layer counts: Defense in depth for AI agents with Red Hat AI

    • Fun in the RUN instruction: Why container builds with distroless images can surprise you

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    What’s up next?

    Share Image

    This cheat sheet gets you started using Ansible to automate tasks on Cisco Meraki, an enterprise-cloud managed networking solution for managing access points, security appliances, L2 and L3 switches, and more.

    Get the cheat sheet
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.