Aws Ec2 Ci Cd With Github Action And Docker

Leo Migdal
-
aws ec2 ci cd with github action and docker

In this guide, we’ll create a fully automated CI/CD pipeline to deploy a Dockerized Hello World app. We’ll use GitHub Actions to build and push Docker images to AWS Elastic Container Registry (ECR) and deploy updates on an AWS EC2 instance through a Python webhook listener. Additionally, we’ll implement resource cleanup on both EC2 and ECR to maintain an efficient deployment system. Whether you’re a DevOps enthusiast or just starting, this walkthrough offers valuable insights into building an automated deployment pipeline. Let’s dive in! 🛠️

We’ll start by building a simple Python Flask app. This role will be assumed by GitHub actions, we need to create custom trust policy so this role can be assumed from our repository. A webhook secret ensures secure communication between GitHub Actions and the webhook listener. To generate a secret: Many Organizations adopt DevOps Practices to innovate faster by automating and streamlining the software development and infrastructure management processes. Beyond cultural adoption, DevOps also suggests following certain best practices and Continuous Integration and Continuous Delivery (CI/CD) is among the important ones to start with.

CI/CD practice reduces the time it takes to release new software updates by automating deployment activities. Many tools are available to implement this practice. Although AWS has a set of native tools to help achieve your CI/CD goals, it also offers flexibility and extensibility for integrating with numerous third party tools. In this post, you will use GitHub Actions to create a CI/CD workflow and AWS CodeDeploy to deploy a sample Java SpringBoot application to Amazon Elastic Compute Cloud (Amazon EC2) instances in an Autoscaling... GitHub Actions is a feature on GitHub’s popular development platform that helps you automate your software development workflows in the same place that you store code and collaborate on pull requests and issues. You can write individual tasks called actions, and then combine them to create a custom workflow.

Workflows are custom automated processes that you can set up in your repository to build, test, package, release, or deploy any code project on GitHub. AWS CodeDeploy is a deployment service that automates application deployments to Amazon EC2 instances, on-premises instances, serverless AWS Lambda functions, or Amazon Elastic Container Service (Amazon ECS) services. The solution utilizes the following services: Learn through the super-clean Baeldung Pro experience: No ads, dark-mode and 6 months free of IntelliJ Idea Ultimate to start with. Modern software architecture is often broken.

Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive. Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more. With Orkes Conductor managed through Orkes Cloud, developers can focus on building mission critical applications without worrying about infrastructure maintenance to meet goals and, simply put, taking new products live faster and reducing total... I will guide you in this project how to build a secure CI/CD pipeline on AWS that detects code on a Github repository, runs static code analysis on sonar cloud, builds a docker image,... Each time a developer commits code to GitHub, it triggers GitHub actions to run static code analysis. The static code analysis consists of maven tests, checkstyle tests, junit, jacoco and quality gates.

These static test will ensure that code works as expected, checks for adherence to a set of defined coding conventions, provide annotations to define test methods, assertions to test expected results and runners to... The next step is to build a docker image, the steps involved are declared in the Dockerfile which will be in the code repository, after building the image, it will be safe to run... The image is then Pushed to ECR, AWS' image repository from where we can easily pull to deploy on ECS Login to your github account, open gitbash terminal on your local machine and clone the code Make a new folder and copy the files to it, initialize git and open VS Code with the following commands: TL-DR; Integrating and Delivering a new version of the product through a series of automated steps.

Manually updating the version of any application is time consuming and error prone and thus the need for automation arised. Do not open ports to the internet. For my current setup only port 80 is limited to CloudFront, and rest are opened to only my IP. Are you wondering how I'm able to deploy from the Github Runner if it cannot access the EC2? Let's see the pipeline. Let's see the yaml code that make the ci/cd pipeline allowing build, test and deploy dockerized apps.

This project provisions and deploys a complete AWS infrastructure for a simple web application using Terraform (IaC) and GitHub Actions (CI/CD). It includes a VPC with public and private subnets, an EC2 instance running Dockerized NGINX, an RDS instance, and an ECR registry to store Docker images. The application serves a basic “Hello World” webpage and showcases how to automate infrastructure deployment and application delivery using cloud-native tools. Configured via aws-actions/configure-aws-credentials. Push changes to main branch. Approve manually when prompted.

Visit the EC2 public IP in your browser to see the “Hello World” page. In the fast-paced world of software development, automation is the key to delivering high-quality applications quickly and reliably. One of the most powerful and accessible tools for implementing CI/CD workflows is GitHub Actions. In this 2025 guide, we’ll walk through creating a CI/CD pipeline with GitHub Actions and show you how to take it a step further by automatically deploying Docker images to AWS ECS (Elastic Container... Whether you’re deploying a personal project or managing a production-ready application in a corporate environment, this guide will help you streamline your DevOps workflow from end to end. GitHub Actions is a built-in automation service in GitHub that lets you define custom workflows triggered by events in your repository.

These workflows are written in YAML and can automate tasks such as building, testing, and deploying your applications. Before you begin, for creating CI/CD Pipeline with GitHub Actions you’ll need: Not every project needs the complexity of AWS. If you’re working on a personal or hobby project, you can still take full advantage of GitHub Actions for automated deployments. Join the DZone community and get the full member experience. GitHub Actions enables the CI/CD, short for continuous integration or continuous deployment, process to build, test, and deploy the code through the workflows within the same GitHub repository.

GitHub Actions builds images and pushes them to cloud providers such as AWS and Docker Hub. We can choose the different OS platforms, Windows or Linux, to run the workflows. In this article, we will demonstrate how we can streamline the build and deploy process to push Docker Images to AWS ECR, short for Elastic Container Repository, by using GitHub Actions. GitHub provides different official actions and also has the actions provided by the community, which allows for integration with the workflow quickly and easily than writing code from scratch. In this demo, we used the GitHub-verified official actions. You can also add or adjust any action provided by the community from the GitHub Marketplace as well.

Click the Actions and create a workflow YAML file. The workflow can be selected based on the requirement. GitHub has provided some recommendations: we can select from the below and click configure, and the set of built-in actions code will be written for us, which we can further tweak or adjust as... Here we wrote the workflow from scratch.

People Also Search

In This Guide, We’ll Create A Fully Automated CI/CD Pipeline

In this guide, we’ll create a fully automated CI/CD pipeline to deploy a Dockerized Hello World app. We’ll use GitHub Actions to build and push Docker images to AWS Elastic Container Registry (ECR) and deploy updates on an AWS EC2 instance through a Python webhook listener. Additionally, we’ll implement resource cleanup on both EC2 and ECR to maintain an efficient deployment system. Whether you’re...

We’ll Start By Building A Simple Python Flask App. This

We’ll start by building a simple Python Flask app. This role will be assumed by GitHub actions, we need to create custom trust policy so this role can be assumed from our repository. A webhook secret ensures secure communication between GitHub Actions and the webhook listener. To generate a secret: Many Organizations adopt DevOps Practices to innovate faster by automating and streamlining the soft...

CI/CD Practice Reduces The Time It Takes To Release New

CI/CD practice reduces the time it takes to release new software updates by automating deployment activities. Many tools are available to implement this practice. Although AWS has a set of native tools to help achieve your CI/CD goals, it also offers flexibility and extensibility for integrating with numerous third party tools. In this post, you will use GitHub Actions to create a CI/CD workflow a...

Workflows Are Custom Automated Processes That You Can Set Up

Workflows are custom automated processes that you can set up in your repository to build, test, package, release, or deploy any code project on GitHub. AWS CodeDeploy is a deployment service that automates application deployments to Amazon EC2 instances, on-premises instances, serverless AWS Lambda functions, or Amazon Elastic Container Service (Amazon ECS) services. The solution utilizes the foll...

Slow Delivery Leads To Missed Opportunities, Innovation Is Stalled Due

Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive. Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more. With Orkes Conductor managed through Orkes Cloud, developers can ...