In the fast-paced world of software development, the ability to deliver high-quality code rapidly and reliably is paramount. This is where Continuous Integration (CI) and Continuous Delivery/Deployment (CD) come into play. In this blog post, we will explore how we can harness the power of Azure Repos and Amazon EC2 instances to establish an efficient CI/CD pipeline for deploying static pages. So, fasten your seatbelts, and let’s dive in!
Understanding CI/CD :
Before we proceed, let’s briefly understand the core concepts of CI and CD. Continuous Integration involves automatically building and testing code whenever changes are pushed to a central repository. It ensures that code integrations are seamless and conflicts are identified early. Continuous Delivery extends CI by automating the deployment of code to environments for thorough testing. Continuous Deployment, on the other hand, automates the process of releasing code to production after it has passed all tests.
Setting the Stage:
Our CI/CD journey begins with Azure Repos, a powerful source control platform offered by Microsoft Azure. Azure Repos allows us to securely manage our codebase and track changes over time. To leverage Azure Repos for our CI/CD process, we’ll be utilizing Azure Pipelines.
Building the Pipeline:
Azure Pipelines acts as the engine driving our CI/CD process. Once triggered by changes in Azure Repos, the pipeline kicks into action. It begins by building and testing the code, ensuring that everything is in order before proceeding with deployment.
Archiving and Deploying:
To prepare our code for deployment, we utilize the archives task in Azure Pipelines. This task generates ZIP files containing our static pages, encapsulating them in a portable format. These ZIP files are then uploaded to an S3 bucket on Amazon Web Services (AWS), providing a reliable storage solution for our deployment artifacts.
Leveraging Amazon EC2 and CodeDeploy:
Now that our code is securely stored in the S3 bucket, it’s time to unleash the power of Amazon EC2 instances. We utilize AWS CodeDeploy, a service that simplifies code deployments to EC2 instances. CodeDeploy intelligently manages the deployment process, ensuring minimal downtime and efficient resource utilization.
Testing and Approval Gates:
With our code deployed to the EC2 instances, it’s crucial to validate its functionality. We subject the deployed static pages to thorough testing within the EC2 environment, ensuring they meet our quality standards. To proceed with production deployment, an approval gate is triggered, allowing stakeholders to review and approve the changes.
Sealing the Deal:
Upon receiving the green light from the approval gate, our CI/CD pipeline confidently moves forward with the production deployment. The static pages are now available for users to experience, thanks to the seamless integration between Azure Repos and Amazon EC2.
Implementing an effective CI/CD process can be a game-changer for any software development project. By harnessing the power of Azure Repos and Amazon EC2 instances, we can establish a robust and automated deployment pipeline for static pages. Azure Pipelines orchestrates the process, while AWS CodeDeploy ensures smooth deployments to EC2 instances. Together, they enable rapid, reliable, and hassle-free delivery of high-quality code.
Using Azure Repos – Source Code is in GitHub azure365pro/AzureDevOps-S3-CodeDeploy-LoginPage (github.com)
Created Service Connections – Using AWS Security Credentials
Permissions for IAM User (Please note its not least privilege)
Using Azure Repos
Archive Files to ZIP
Use S3 Bucket and Upload to S3 Bucket
You can see ZIP getting uploaded to the S3 bucket
You need appsec.yml
version: 0.0 os: linux files: - source: /index.html destination: /var/www/html/ - source: /style.css destination: /var/www/html/ hooks: BeforeInstall: - location: scripts/install_dependencies timeout: 300 runas: root - location: scripts/start_server timeout: 300 runas: root ApplicationStop: - location: scripts/stop_server timeout: 300 runas: root
Deploy with Code Deploy
IAM Role Assigned over the EC2 Instance
Application is created
If repo is committed . Now EC2 is updated.