-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from Bahmni/BAH-4126
BAH-4126 | Add. Wokflows to start and stop EC2 instances of Bahmni Demo Environments
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Start EC2 Instances | ||
|
||
on: | ||
schedule: | ||
# Runs "At 06:00 AM IST on Moday-Friday. Below time is mentioned in UTC time zone" (see https://crontab.guru) | ||
- cron: '30 00 * * 1-5' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
start-instances: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
instance: ['bahmni-standard-docker'] | ||
steps: | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
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 Environments | ||
run: | | ||
INSTANCE_ID=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${{ matrix.instance }}" --query "Reservations[].Instances[].InstanceId" --output text) | ||
aws ec2 start-instances --instance-ids ${INSTANCE_ID} > /dev/null 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Stop EC2 Instances | ||
|
||
on: | ||
schedule: | ||
# Runs "At 09:00 PM IST on Moday-Friday. Below time is mentioned in UTC time zone" (see https://crontab.guru) | ||
- cron: '30 15 * * 1-5' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
stop-instances: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
instance: ['bahmni-standard-docker'] | ||
steps: | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
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: Stop Environments | ||
run: | | ||
INSTANCE_ID=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=${{ matrix.instance }}" --query "Reservations[].Instances[].InstanceId" --output text) | ||
aws ec2 stop-instances --instance-ids ${INSTANCE_ID} > /dev/null 2>&1 |