DevOps Project 7 - Automating Portfolio Deployment on AWS S3 using GitHub Actions
Day 86 of #90dayssofdevops challenge
Project Description
In this project, our main objective is to deploy a Portfolio app on AWS S3, a powerful and scalable storage service provided by Amazon Web Services. Leveraging GitHub Actions, we'll automate the entire process of building and deploying our Portfolio to AWS S3. With this automation, any changes we make to our GitHub repository will trigger automatic updates to our live website, making deployment a breeze.
Hands-on Project: Automating Portfolio Deployment on AWS S3 using GitHub Actions
Step 1: Get the Portfolio Application from GitHub
To begin, let's obtain the Portfolio application from the GitHub repository. Clone the repository to your local development environment or directly to your AWS server, where we'll configure AWS S3 and set up the GitHub Actions Workflow.
Now, Create an S3 Bucket - "tws-portfolio-bucket1":
Configure Bucket Policy for Public Access:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadForGetBucketObjects",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::tws-portfolio-bucket/*"
}
]
}
Create an IAM User and Generate Security Credentials:
Set Up GitHub Secrets for AWS Credentials:
Click on "Secrets and Variables" in the Actions menu.
Add the following secrets:
AWS_S3_BUCKET
- Your S3 bucket nameAWS_ACCESS_KEY_ID
- AWS CLI Access Key IDAWS_SECRET_ACCESS_KEY
- AWS CLI Secret Access Key
Now Create the GitHub Actions Workflow:
Next, navigate to the project code repository on GitHub and choose the "Actions" option from the menu. Set up a new workflow for your Portfolio app by creating a YAML file that defines the necessary steps for the deployment process.
name: my-portfolio-deployment # Name of the deployment
on:
push: # Trigger the workflow when changes are pushed
branches:
- main
jobs: # Any name can be provided
build-and-deploy:
runs-on: ubuntu-latest # Latest version of Ubuntu
steps:
- name: Checkout # Check out the repository's code into the workflow's execution environment.
uses: actions/checkout@v1 # Script actions
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_ID }}
aws-region: ap-south-1
- name: Deploy static site to S3 bucket
run: aws s3 sync . s3://tws-portfolio-bucket1 --delete # Change bucket name
Enable Static Website Hosting for the S3 Bucket:
Access Your Portfolio Website:
Congratulations on completing Day 86 of the #90DaysOfDevOps Challenge. By automating the deployment of your Portfolio app on AWS S3 using GitHub Actions, you've gained valuable insights into streamlining CI/CD and efficiently managing your application's deployment. Stay tuned for tomorrow's challenge, where we'll dive into another exciting DevOps project!
"Thank you for enjoying my DevOps blog! Your positive response fuels my passion to dive deeper into technology and innovation.
Stay tuned for more captivating DevOps articles, where we'll explore this dynamic field together. Follow me on Hashnode and connect on LinkedIn (linkedin.com/in/som-shanker-pandey) for the latest updates and discussions.