-
Notifications
You must be signed in to change notification settings - Fork 5
35 lines (32 loc) · 1.58 KB
/
Copy pathstopMachine.yml
File metadata and controls
35 lines (32 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# This is a basic workflow that is manually triggered
name: Stop Performance Test EC2 instance
# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
stop-performance-instance:
name: Stop Performance Instance
runs-on: ubuntu-latest
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: Stop Performance Test AWS EC2 instance
run: |
INSTANCE_ID=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=performance-instance" "Name=instance-state-name,Values=running" --query "Reservations[].Instances[].InstanceId" --output text)
if [ -z "$INSTANCE_ID" ]; then
echo "Performance Test EC2 instance is not available to stop"
else
aws ec2 stop-instances --instance-ids $(aws ec2 describe-instances --filters "Name=tag:Name,Values=performance-instance" --query "Reservations[].Instances[].InstanceId" --output text --region ap-south-1) --region ap-south-1
echo "Performance Test EC2 instance stopped"
fi