Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Quick links: redhat.com, Customer Portal, Red Hat's developer site, Red Hat's partner site.

  • You are here

    Red Hat

    Learn about our open source products, services, and company.

  • You are here

    Red Hat Customer Portal

    Get product support and knowledge from the open source experts.

  • You are here

    Red Hat Developer

    Read developer tutorials and download Red Hat software for cloud application development.

  • You are here

    Red Hat Partner Connect

    Get training, subscriptions, certifications, and more for partners to build, sell, and support customer solutions.

Products & tools

  • Ansible.com

    Learn about and try our IT automation product.
  • Red Hat Ecosystem Catalog

    Find hardware, software, and cloud providers―and download container images―certified to perform with Red Hat technologies.

Try, buy, & sell

  • Red Hat Hybrid Cloud Console

    Access technical how-tos, tutorials, and learning paths focused on Red Hat’s hybrid cloud managed services.
  • Red Hat Store

    Buy select Red Hat products and services online.
  • Red Hat Marketplace

    Try, buy, sell, and manage certified enterprise software for container-based environments.

Events

  • Red Hat Summit and AnsibleFest

    Register for and learn about our annual open source IT industry event.

How to create an EC2 instance in AWS using Ansible workflow

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

Share:

Share on twitter Share on facebook Share on linkedin Share with email
  • How to create a job template
  • Ansible Automation Platform offers more

In our previous article, we demonstrated how to automate the process of creating an EC2 instance on AWS using the Red Hat Ansible Automation Platform. We demonstrated how Ansible Automation Platform can streamline the process of deploying virtual machines (VMs) in AWS, making it more efficient and less error-prone. In this final installment, we will take things a step further by exploring how to simplify the process of creating EC2 instances in AWS using workflow templates.

Workflow templates can help standardize the process of creating instances and reduce the amount of manual intervention. In this article, we will dive into the details of how to use a workflow template to further optimize our infrastructure management in AWS.

If you are following along with our series, you may recall that we previously discussed the importance of an execution environment and setting up credentials. These are essential steps to complete before deploying a workflow template. In case you missed the previous articles, we recommend you to check them out to ensure you are ready to move forward with the next steps.

Follow the series:

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

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

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

How to create a job template

How to create a job template

We will assume that you have already set up your execution environment and credentials using our previous blogs. Now, we will focus on how to deploy a workflow template in AWS using Ansible Automation Platform.

Create and configure the project

  • Log in to the Ansible Automation Platform portal in the browser.
  • Navigate to the Projects tab under Resources and click Add.
  • Enter your project name.
  • Choose Git as the source control type.
  • Enter this source control URL: https://github.com/redhat-developer-demos/ansible-automation-platform-cloud-solutions. If you're interested in checking out the playbooks, you can find them on GitHub.
  • Save your changes and wait for the operation to complete successfully. When selecting Git as your source control type, the platform pulls down the latest versions of your files for use in Ansible Automation Platform jobs and workflows. This makes it easy to manage changes, collaborate with others, and track configuration history over time.

Create and configure the job templates

  • Go to the Templates tab and click Add.
  • Select Job template.
  • Name your job and select the default or Demo-Inventory under Inventory.
  • Under Project, select the project name you created earlier and choose the AWS/Workflow/VPC_01.yml playbook file.
  • Choose the credentials (Figure 1).
Figure 1: Selecting pre-configured AWS credentials for secure authentication
Figure 3: Selecting pre-configured AWS credentials for secure authentication.
Figure 1: Enter the AWS credentials.
  • Select Default execution environment for the execution environment, as shown in Figure 2.
A screenshot of where to Select the default execution environment in Ansible.
Figure 4: Selecting the default execution environment.
Figure 2: Select the pre-configured default execution environment.
  • Repeat the previous steps for any other playbooks in the AWS/Workflow/ directory.

Create and configure the workflow templates

  • To start, create a workflow template and assign a name to it, as shown in Figure 3.
    Figure 3: Create a workflow template
    Figure 3: Create a workflow template.
  • In 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
Copy snippet
  • Save the workflow before proceeding and visualize the workflow when prompted, as shown in Figure 4.
A screenshot of the form for selecting the job templates as nodes in Ansible workflow.
Figure 4: Selecting the job templates as nodes in workflow.
Figure 4: Selecting the job templates as nodes in workflow.
  • Once you have confirmed the workflow, add each job template to its respective node.
  • After all job templates have been added, launch the workflow to execute it, as shown in Figure 5.
    A screenshot of the final workflow visualizer nodes.
    Figure 5: Final workflow visualizer nodes.
    Figure 5: Final workflow visualizer nodes

Once the workflow is executed, the VM will be up and running, ready for you to use as illustrated in Figure 6. This streamlined process ensures that the VM is created quickly and efficiently, saving you valuable time and effort while helping different teams analyze the possible points of failure.

Figure 6: EC2 Instance in AWS
Figure 1: The EC2 instance in AWS.
Figure 6: The EC2 instance in AWS.
Ansible Automation Platform offers more

Ansible Automation Platform offers more

We demonstrated how Ansible Automation Platform streamlines the process of deploying virtual machines in AWS. By automating repetitive tasks, you can reduce manual intervention and avoid human error, leading to faster, more consistent deployments and improved reliability.

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.

We hope this article series has provided you with a solid foundation to explore the potential of Ansible Automation Platform in your own environment. As you continue to learn and experiment with cloud infrastructure management, remember to stay up to date with the latest trends and techniques by exploring blogs and interactive labs for free at Red Hat Developer.

Last updated: January 11, 2024

Related Posts

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

  • Git best practices: Workflows for GitOps deployments

  • What’s new in Ansible Automation Platform 2.2

  • Using OpenShift with AWS Services and Features

  • Developer Sandbox for Red Hat OpenShift now available on AWS

Recent Posts

  • LLM Compressor: Optimize LLMs for low-latency deployments

  • How to set up NVIDIA NIM on Red Hat OpenShift AI

  • Leveraging Ansible Event-Driven Automation for Automatic CPU Scaling in OpenShift Virtualization

  • Python packaging for RHEL 9 & 10 using pyproject RPM macros

  • Kafka Monthly Digest: April 2025

What’s up next?

Learn how to deploy an application on a cluster using Red Hat OpenShift Service on AWS. This learning path uses a pre-built application to allow you to become more familiar with OpenShift and Kubernetes features.

Start learning
Red Hat Developers logo LinkedIn YouTube Twitter Facebook

Products

  • Red Hat Enterprise Linux
  • Red Hat OpenShift
  • Red Hat Ansible Automation Platform

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

Red Hat legal and privacy links

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

Report a website issue