⚙️ Week 6: CI/CD + DevOps Lifecycle

Day 5: Automated Deployment to AWS

⏱ Duration: 5 Hours

📚 Learning Objectives

  • Set up AWS credentials in GitHub
  • Deploy Docker app to EC2
  • Implement automated deployment workflow
  • Handle rollbacks and monitoring

📖 AWS Deployment Workflow

name: Deploy to AWS EC2 on: push: branches: [main] jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-east-1 - name: Login to ECR run: | aws ecr get-login-password | docker login --username AWS --password-stdin $ECR_REGISTRY - name: Build and push run: | docker build -t myapp . docker tag myapp:latest $ECR_REGISTRY/myapp:latest docker push $ECR_REGISTRY/myapp:latest - name: Deploy to EC2 run: | aws ssm send-command \ --instance-ids ${{ secrets.EC2_INSTANCE_ID }} \ --document-name "AWS-RunShellScript" \ --parameters 'commands=["docker pull $ECR_REGISTRY/myapp:latest","docker stop myapp || true","docker run -d --name myapp -p 80:80 $ECR_REGISTRY/myapp:latest"]'

🎉 Week 6 Complete!

What you learned:

  • DevOps culture and lifecycle
  • CI/CD concepts and pipelines
  • GitHub Actions workflows
  • Automated AWS deployment