Skip to content

Start EKS Node Group & RDS in AWS #791

Start EKS Node Group & RDS in AWS

Start EKS Node Group & RDS in AWS #791

name: Start EKS Node Group & RDS in AWS
on:
workflow_dispatch:
schedule:
# Runs "At 06:00 AM on every day. Below time is mentioned in UTC time zone" (see https://crontab.guru)
- cron: '30 00 * * *'
jobs:
start-rds:
name: Start RDS
runs-on: ubuntu-latest
env:
RDS_NAME: bahmni-rds-nonprod
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.BAHMNI_AWS_ID }}
aws-secret-access-key: ${{ secrets.BAHMNI_AWS_SECRET }}
aws-region: ap-south-1
role-to-assume: ${{ secrets.BAHMNI_INFRA_ADMIN_ROLE }}
role-duration-seconds: 1200 # 20 mins
role-session-name: BahmniInfraAdminSession
- name: Start ${{ env.RDS_NAME }} RDS Instance
run: |
aws rds start-db-instance --db-instance-identifier ${{ env.RDS_NAME }} > /dev/null 2>&1
- name: Wait 5 mins for RDS to start
run: sleep 300s
shell: bash
start-nodegroups:
name: Start Node Group
runs-on: ubuntu-latest
needs: start-rds
strategy:
matrix:
nodegroup: [
{ name: 'nonprod',minSize: 1,maxSize: 2,desiredSize: 1 },
{ name: 'performance',minSize: 0,maxSize: 1,desiredSize: 0 }
]
env:
CLUSTER_NAME: bahmni-cluster-nonprod
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.BAHMNI_AWS_ID }}
aws-secret-access-key: ${{ secrets.BAHMNI_AWS_SECRET }}
aws-region: ap-south-1
role-to-assume: ${{ secrets.BAHMNI_INFRA_ADMIN_ROLE }}
role-duration-seconds: 1200 # 20 mins
role-session-name: BahmniInfraAdminSession
- name: Start ${{ matrix.nodegroup.name }} Node Group
run: |
aws eks update-nodegroup-config \
--cluster-name=${{ env.CLUSTER_NAME }} \
--nodegroup-name=${{ matrix.nodegroup.name }} \
--scaling-config minSize=${{ matrix.nodegroup.minSize }},maxSize=${{ matrix.nodegroup.maxSize }},desiredSize=${{ matrix.nodegroup.desiredSize }} > /dev/null 2>&1
post-notification:
name: Post Slack Notification
runs-on: ubuntu-latest
needs: start-nodegroups
steps:
- name: Post Deployment Status To Slack
run: |
curl -X POST -H 'Content-type: application/json' --data '{"text":":white_check_mark: Hello, EKS Node Groups & RDS Instance started & will be available in 5 minutes"}' ${{ secrets.SLACK_WEBHOOK_URL }}