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

Customize AWS cloud images with RHEL image builder and Packit

April 2, 2024
Maja Massarini
Related topics:
Automation and managementContainersLinux
Related products:
Red Hat Enterprise Linux

Share:

    Have you ever wanted to bring your pull request changes in a cloud image easily?

    Curious about how easy it can be? With Packit, it can be just a matter of commenting on your pull request with the following command:

    /packit vm-image-build

    With the above command, Packit automates all the manual steps needed to create an RPM package with your pull request changes and asks the Red Hat Enterprise Linux image builder (RHEL image builder) to install it inside a brand new cloud image.

    Let's have a look at the prerequisites for this.

    Join the Red Hat Developer program

    If you don't already have a business account, you can create a Red Hat Developer account at no cost.

    You need a subscription in order to use the RHEL image builder service and launch the builded images in the Amazon Web Services (AWS) management console.

    Prepare to upload the Amazon Machine Image

    Before uploading an Amazon Machine Image (AMI), you must configure the AWS system for receiving them.

    Prerequisites

    • You must have an access key ID configured in the AWS IAM account manager.
    • You must have a writable S3 bucket prepared.

    Procedure

    Follow these steps to satisfy the above prerequisites.

    The manual steps

    Are you wondering what are the manual steps for bringing your pull request changes in a cloud image and why you should automate them?

    There could be many ways to achieve this goal, but let's see together the closest to our automated solution. Below you can find a summary of all the needed manual steps; I am quite sure after reading them, you will want to automate them with Packit!

    Build an RPM package with your pull request changes through COPR.

    1. Install copr-cli.
    2. Create your account and service token.
    3. Add your token to ~/.config/copr.
    4. Create a new COPR project.
    5. Start a build with your local pull request changes using copr-cli.
    6. Wait for the build to finish.

    Create a new cloud image through the RHEL image builder console.

    1. Log in with your Red Hat Developer account.
    2. Click on the Create Image button. Choose the AWS image type and follow the wizard.
    3. Wait for the build to finish.
    4. Open the Launch link for the built image.

    Launch and access the AWS image through the AWS management console.

    1. The previous link will open an AWS console tab with the Launch an Instance wizard preset to use the builded image. You need to log in into the AWS management console using an AWS account ID allowed to access the AMI image you just created.
    2. Select a key pair (or create one if you don't have it already) to be able to ssh the image later.
    3. Click Launch Instance.
    4. Connect to instance using an ssh client.
    5. Add the previously created COPR repo to the list of available dnf repositories.
    6. Install the package you have created in step 4.
    7. Now you are ready to test your code in a real cloud image.

    For every new pull request you want to test directly in a cloud image you have to repeat steps 4-16, or automate them through Packit.

    Automate the steps

    Install Packit

    Installing Packit is pretty straightforward:

    1. Create a valid Fedora Account System (FAS) account (if you don't already have one). Why do you need this? After these few steps you will start building (and potentially shipping) Fedora packages through the COPR service, and we need you to agree with the Fedora license.
    2. Install our GitHub application on GitHub Marketplace, or configure a webhook on GitLab (depending on where your project lives).
    3. Make Packit approve your FAS username; on GitHub, the approval process is automated, and for GitLab, you have to contact us.

    Once installed, you are ready to automate the process as described below.

    Set up Packit

    Create a .packit.yaml configuration file in your pull request—but just the first time! After your pull request has been merged, Packit will take the .packit.yaml file from the target main branch.

    The configuration file will look like the following:

    ---
    
    jobs:
    - job: copr_build
      trigger: pull_request
      targets:
      - fedora-all
    
    - job: vm_image_build
      trigger: pull_request
      image_request:
        architecture: x86_64
        image_type: aws
        upload_request:
          type: aws
          options:
            share_with_accounts:
            - < shared-aws-account-id >
      image_distribution: fedora-39
      copr_chroot: fedora-39-x86_64
      image_customizations:
        packages: [hello-world]

    copr_build job

    The first job tells the Packit service to build an RPM package for the Fedora release you want—in this example all the active Fedora releases—and to add your pull request changes to the package.

    To further customize the COPR builds made by Packit, you might want to refer to this guide.

    vm_image_build job

    The second job tells Packit how to configure the RHEL image builder service.

    The first two lines of this job are still meant for Packit; they allow Packit to react to your pull request comment /packit vm-image-build. Packit does not build a VM image automatically, as it does when it builds a COPR package, to save you from unwanted costs.

    - job: vm_image_build
      trigger: pull_request
    

    The other lines are meant to customize the RHEL image builder behavior.

    You are asking to build an AWS image, with a fedora-39 distribution, for the x86_64 architecture and you want to share it with the listed AWS Account IDs.

      image_request:
        architecture: x86_64
        image_type: aws
        upload_request:
          type: aws
          options:
            share_with_accounts:
            - < shared-aws-account-id >
      image_distribution: fedora-39
    

    You don't want to manually install the COPR package into the image; for this reason, you'll ask RHEL image builder to install it (hello-world).

    You tell RHEL image builder to take it from the COPR chroot fedora-39-x86_64, and you don't need to create or specify a COPR project because Packit has automatically created it for you.

      copr_chroot: fedora-39-x86_64
      image_customizations:
        packages: [hello-world]
    

    Create, comment, and test a pull request

    Create a pull request; mine will show you the word world in green.

    All you need to do is comment your pull request with:

    /packit vm-image-build

    And the image will be built and customized for you.

    Look for the check named vm-image-build-fedora-39-x86_64 and wait for it to finish (Figure 1).

    Wait for check vm-image-build-fedora-39-x86_64 to finish
    Figure 1: The image is being built

    Open its details (Figure 2) and you will find the link to the AWS image.

    The check details have a link to the AWS image
    Figure 2: The AWS image link now appears in the sidebar.

    Open the AWS link (you will need to be logged in) and see the details of your image ready to be launched (Figure 3).

    The AWS image details
    Figure 3: The AMI details window.

    Launch your image instance and connect to it (Figure 4).

    Connect to instance details
    Figure 4: Connecting to the image instance.

    Test it, as shown in Figure 5.

    Test it!
    Figure 5: The word "world" now appears in green.

    Conclusions

    Packit can automate building RPM packages with changes taken from pull requests, creating cloud images, and installing packages into them so that they are ready to be manually tested.

    But this is not all—Packit can also help you automating tests or releases. Want to know more? Visit packit.dev.

    Related Posts

    • How RHEL image builder has improved security and function

    • How to trigger jobs manually in Packit

    • How to reduce Red Hat Fuse image size

    • How to set up Packit to simplify upstream project integration

    • Build smaller container images using S2I

    • How to improve Go FIPS test coverage with Packit

    Recent Posts

    • GuideLLM: Evaluate LLM deployments for real-world inference

    • Unleashing multimodal magic with RamaLama

    • Integrate Red Hat AI Inference Server & LangChain in agentic workflows

    • Streamline multi-cloud operations with Ansible and ServiceNow

    • Automate dynamic application security testing with RapiDAST

    What’s up next?

    Now that Windows developers can write code that runs on Red Hat Enterprise Linux (RHEL) with almost no learning curve, the app dev environment is changing—.NET developers can now move into microservices. Download the .NET on Red Hat Enterprise Linux cheat sheett and learn how to run your .NET code in a Linux container.

    Get the cheat sheet
    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