AWS CICD PIPELINE

RMAG news

Setting Up a GitHub Repository for Your Python Application

If you don’t already have a GitHub repository, follow these steps to create one:

Sign In to GitHub:

Go to github.com and log into your account.

Create a New Repository:

Click the “+” button in the top-right corner.
Select “New repository.”

Configure the Repository:

Name: Enter a name for your repository.

Description: (Optional) Add a description for your repository.

Visibility: Choose between public or private based on your preference.

Initialize: Select “Initialize this repository with a README.”

Create the Repository:

Click the “Create repository” button.

Download all the files from https://github.com/SUBHAM-NANDI/Project2-AWS-END-TO-END-CICD on local machine and upload it to the new repository.

Configuring AWS CodeBuild for Your Python Application

In this step, we will configure AWS CodeBuild to build and package our Python application for deployment. Follow these steps:

Navigate to AWS CodeBuild:

Go to the AWS Management Console.
Search for and select “CodeBuild.”

Create a New Build Project:

Click on the “Create build project” button.
Enter a name for your build project.

Configure the Source Provider:

For the source provider, choose “AWS CodePipeline.”
Select the pipeline you created in the previous step.

Configure the Build Environment:

Select the operating system (e.g., Ubuntu).
Choose the runtime (e.g., Python 3.8).
Configure the compute resources required for your Python application (e.g., Standard, Medium).

Specify Build Commands:

version: 0.2

env:
parameter-store:
DOCKER_REGISTRY_USERNAME: /myapp/docker-credentials/username #this consists the username of Docker Hub
DOCKER_REGISTRY_PASSWORD: /myapp/docker-credentials/password #this consists the password of Docker Hub
DOCKER_REGISTRY_URL: /myapp/docker-registry/url #this consists the location/url(docker.io) of Docker Hub
phases:
install:
runtime-versions:
python: 3.12
pre_build:
commands:
– echo “Installing dependencies…”
– pip install -r simple-python-app/requirements.txt
build:
commands:
– echo “Running tests…”
– cd simple-python-app/
– echo “Building Docker image…”
– echo “$DOCKER_REGISTRY_PASSWORD” | docker login -u “$DOCKER_REGISTRY_USERNAME” –password-stdin “$DOCKER_REGISTRY_URL”
– docker build -t “$DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_USERNAME/simple-python-flask-app:latest” .
– docker push “$DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_USERNAME/simple-python-flask-app:latest”
post_build:
commands:
– echo “Build completed successfully!”

Configure Artifacts:

Set up the artifacts configuration to specify the build output required for deployment.

For example, you might specify an S3 bucket to store the build output.

Review and Create the Build Project:

Review all the build project settings.
Click on the “Create build project” button.

Your AWS CodeBuild project is now configured to build and package your Python application based on the specifications you defined.

Setting Up an AWS CodePipeline for Your Python Application

In this step, we will create an AWS CodePipeline to automate the continuous integration process for our Python application. AWS CodePipeline will manage the flow of changes from our GitHub repository to the deployment of our application. Here’s how to set it up:

Navigate to AWS CodePipeline:

Go to the AWS Management Console.
Search for and select “CodePipeline.”

Create a New Pipeline:

Click on the “Create pipeline” button.
Enter a name for your pipeline.
Click the “Next” button.

Configure the Source Stage:

Select “GitHub” as the source provider.
Connect your GitHub account to AWS CodePipeline.
Select your repository and choose the branch you want to use for your pipeline.

Configure the Build Stage:

Select “AWS CodeBuild” as the build provider.
Click on the “Create project” button to create a new CodeBuild project.
Configure the CodeBuild project:

Set the build environment, such as the runtime (Python).
Define the build commands.
Specify the build artifacts.

Save and Return to CodePipeline:

Save the CodeBuild project settings.
Return to the CodePipeline configuration.

Configure the Deployment Stage:

Choose your deployment option (e.g., AWS Elastic Beanstalk).
Configure the deployment settings as needed.

Review and Create the Pipeline:

Review the pipeline configuration.
Click the “Create pipeline” button to finalize the setup.

Please follow and like us:
Pin Share