Skip to content

Commit 40a1dbe

Browse files
authored
Resize Deployment Server (#106)
1 parent eaf3673 commit 40a1dbe

File tree

2 files changed

+137
-0
lines changed

2 files changed

+137
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Resize (Reduce) Deployment Server
2+
3+
# Reduce the size of the release-tools deployment server
4+
#
5+
# The other workflow file increases the instance size during
6+
# releases.
7+
#
8+
# This one reduces it again, each Sunday.
9+
#
10+
11+
on:
12+
workflow_dispatch:
13+
schedule:
14+
- cron: "0 1 * * 0"
15+
16+
jobs:
17+
scale-deploy-server:
18+
runs-on: ubuntu-latest
19+
container: amazon/aws-cli:2.32.19
20+
name: Scale
21+
env:
22+
AWS_ACCESS_KEY_ID: ${{ secrets.DEPLOY_AWS_ACCESS_KEY_ID }}
23+
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEPLOY_AWS_SECRET_ACCESS_KEY }}
24+
if: github.repository == 'boostorg/release-tools'
25+
steps:
26+
- name: Debug
27+
run: |
28+
set -xe
29+
pwd
30+
whoami
31+
aws --version
32+
echo "github.event_name is ${{ github.event_name }}"
33+
34+
- name: Resize Instance
35+
run: |
36+
aws ssm start-automation-execution --document-name "AWS-ResizeInstance" --document-version "\$DEFAULT" --parameters '{"InstanceId":["${{ secrets.DEPLOY_INSTANCE_ID }}"],"InstanceType":["t2.micro"],"SleepWait":["PT5S"]}' --region ${{ secrets.DEPLOY_REGION }}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Resize Deployment Server
2+
3+
# Resize the release-tools deployment server
4+
# during releases.
5+
#
6+
# Boost Releases occur three time per year.
7+
# Before betas and release, increase the size of the deployment
8+
# server so publish_release.py will have more CPU.
9+
#
10+
# See initial setup instructions at the end of this file.
11+
#
12+
13+
on:
14+
workflow_dispatch:
15+
# Runs on Wednesday at 1:00am, on certain months.
16+
schedule:
17+
- cron: "0 1 * 3 3"
18+
- cron: "0 1 * 4 3"
19+
- cron: "0 1 * 7 3"
20+
- cron: "0 1 * 8 3"
21+
- cron: "0 1 * 11 3"
22+
- cron: "0 1 * 12 3"
23+
24+
jobs:
25+
scale-deploy-server:
26+
runs-on: ubuntu-latest
27+
container: amazon/aws-cli:2.32.19
28+
name: Scale
29+
env:
30+
AWS_ACCESS_KEY_ID: ${{ secrets.DEPLOY_AWS_ACCESS_KEY_ID }}
31+
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEPLOY_AWS_SECRET_ACCESS_KEY }}
32+
if: github.repository == 'boostorg/release-tools'
33+
steps:
34+
- name: Debug
35+
run: |
36+
set -xe
37+
pwd
38+
whoami
39+
aws --version
40+
echo "github.event_name is ${{ github.event_name }}"
41+
42+
- name: Get number of Wednesday on a Wednesday
43+
id: number-of-wednesday-on-a-wednesday
44+
run: >-
45+
printf >> "$GITHUB_OUTPUT"
46+
"VALUE=%s"
47+
"$((($(date +%-d)-1)/7+1))"
48+
- name: Resize Instance
49+
if: ${{ ( steps.number-of-wednesday-on-a-wednesday.outputs.VALUE == 2 && github.event_name == 'schedule' ) || ( github.event_name == 'workflow_dispatch' ) }}
50+
run: |
51+
aws ssm start-automation-execution --document-name "AWS-ResizeInstance" --document-version "\$DEFAULT" --parameters '{"InstanceId":["${{ secrets.DEPLOY_INSTANCE_ID }}"],"InstanceType":["c8a.xlarge"],"SleepWait":["PT5S"]}' --region ${{ secrets.DEPLOY_REGION }}
52+
53+
54+
# Initial Setup Instructions
55+
#
56+
# In AWS, create an instance. Install packages.
57+
# In AWS IAM, create a user, api keys, assign policies.
58+
# Assign policies to the user: EC2-Resize and AmazonSSMFullAccess(managed).
59+
# Create the policy EC2-Resize:
60+
# {
61+
# "Version": "2012-10-17",
62+
# "Statement": [
63+
# {
64+
# "Sid": "Stmt1471613026000",
65+
# "Effect": "Allow",
66+
# "Action": [
67+
# "ec2:ModifyInstanceAttribute"
68+
# ],
69+
# "Resource": "arn:aws:ec2:_region_:_account_:instance/_instance-id_,
70+
# "Condition": {
71+
# "StringEquals": {
72+
# "ec2:Attribute": "InstanceType"
73+
# }
74+
# }
75+
# },
76+
# {
77+
# "Effect": "Allow",
78+
# "Action": [
79+
# "ec2:DescribeInstances"
80+
# ],
81+
# "Resource": "*"
82+
# },
83+
# {
84+
# "Effect": "Allow",
85+
# "Action": [
86+
# "ec2:StartInstances",
87+
# "ec2:StopInstances"
88+
# ],
89+
# "Resource": "arn:aws:ec2:_region_:_account_:instance/_instance-id_,
90+
# }
91+
# ]
92+
# }
93+
#
94+
# Fill in _region_, _account_, and _instance-id_.
95+
#
96+
# Add github actions secrets:
97+
#
98+
# DEPLOY_INSTANCE_ID
99+
# DEPLOY_REGION
100+
# DEPLOY_AWS_ACCESS_KEY_ID
101+
# DEPLOY_AWS_SECRET_ACCESS_KEY

0 commit comments

Comments
 (0)