-
Notifications
You must be signed in to change notification settings - Fork 0
278 lines (276 loc) · 9.46 KB
/
databases.yml
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
---
name: databases
on:
workflow_dispatch: {}
schedule:
- cron: '0 2 * * *'
jobs:
init:
name: init
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22"
-
name: Build
run: go build -o bin/apppack
-
uses: actions/upload-artifact@v3
with:
name: apppack
path: bin
-
name: AppPack Init
run: |
./bin/apppack create region --region us-east-2 \
--aws-credentials \
--dockerhub-username $DOCKERHUB_USERNAME \
--dockerhub-access-token $DOCKERHUB_ACCESS_TOKEN \
--non-interactive
./bin/apppack create cluster --region us-east-2 \
--aws-credentials \
--domain testclusters.apppack.io \
--non-interactive
timeout-minutes: 15
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_ACCESS_TOKEN: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
standard-mysql:
runs-on: ubuntu-latest
needs: ["init"]
steps:
-
uses: actions/download-artifact@v3
with:
name: apppack
path: bin
-
name: Create standard MySQL
run: |
chmod +x ./bin/apppack
./bin/apppack create database --region us-east-2 \
--aws-credentials \
--non-interactive \
--cluster apppack \
--instance-class db.t4g.micro \
--engine mysql \
--allocated-storage 10 \
--max-allocated-storage 20 \
standard-mysql
timeout-minutes: 30
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-
name: Destroy standard MySQL
run: |
yes apppack-database-standard-mysql | ./bin/apppack destroy database standard-mysql \
--aws-credentials --region us-east-2
if: always()
timeout-minutes: 35
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
standard-postgres:
runs-on: ubuntu-latest
needs: ["init"]
steps:
-
uses: actions/download-artifact@v3
with:
name: apppack
path: bin
-
name: Create standard Postgres
run: |
chmod +x ./bin/apppack
./bin/apppack create database --region us-east-2 \
--aws-credentials \
--non-interactive \
--cluster apppack \
--instance-class db.t4g.micro \
--engine postgres \
--allocated-storage 10 \
--max-allocated-storage 20 \
standard-postgres
timeout-minutes: 25
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-
name: Destroy standard Postgres
run: |
yes apppack-database-standard-postgres | ./bin/apppack destroy database standard-postgres \
--aws-credentials --region us-east-2
if: always()
timeout-minutes: 35
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aurora-mysql:
runs-on: ubuntu-latest
needs: ["init"]
steps:
-
uses: actions/download-artifact@v3
with:
name: apppack
path: bin
-
name: Create Aurora MySQL
run: |
chmod +x ./bin/apppack
./bin/apppack create database --region us-east-2 \
--aws-credentials \
--non-interactive \
--cluster apppack \
--instance-class db.t4g.medium \
--engine aurora-mysql \
--allocated-storage 10 \
--max-allocated-storage 20 \
aurora-mysql
timeout-minutes: 35
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-
name: Destroy Aurora MySQL
run: |
yes apppack-database-aurora-mysql | ./bin/apppack destroy database aurora-mysql \
--aws-credentials --region us-east-2
if: always()
timeout-minutes: 35
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aurora-postgres:
runs-on: ubuntu-latest
needs: ["init"]
steps:
-
uses: actions/download-artifact@v3
with:
name: apppack
path: bin
-
name: Create Aurora Postgres
run: |
chmod +x ./bin/apppack
./bin/apppack create database --region us-east-2 \
--aws-credentials \
--non-interactive \
--cluster apppack \
--instance-class db.t4g.medium \
--engine aurora-postgresql \
aurora-postgres
timeout-minutes: 25
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-
name: Destroy Aurora Postgres
run: |
yes apppack-database-aurora-postgres | ./bin/apppack destroy database aurora-postgres \
--aws-credentials --region us-east-2
if: always()
timeout-minutes: 35
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
redis:
runs-on: ubuntu-latest
needs: ["init"]
steps:
-
name: Checkout
uses: actions/checkout@v3
-
uses: actions/download-artifact@v3
with:
name: apppack
path: bin
-
name: Create Redis
run: |
chmod +x ./bin/apppack
./bin/apppack create redis --region us-east-2 \
--aws-credentials \
--non-interactive \
--cluster apppack
timeout-minutes: 35
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-
name: Destroy Redis
# Redis clusters fail to destroy occassionally when there were just created
# The error is:
# Cache cluster xxx-001 is not in a valid state to be deleted. (Service: AmazonElastiCache; Status Code: 400; Error Code: InvalidReplicationGroupState
# The state during this time is "available", so there's nothing we can do but retry the operation :P
# Amazon support's recommendation is to wait 5-10 minutes after creation to delete it
run: |
yes apppack-redis-apppack | ./bin/apppack destroy redis apppack \
--aws-credentials --region us-east-2 || \
yes apppack-redis-apppack | ./bin/apppack destroy redis apppack \
--aws-credentials --region us-east-2
if: always()
timeout-minutes: 25
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-2
destroy:
runs-on: ubuntu-latest
if: always()
needs:
- standard-mysql
- standard-postgres
- aurora-mysql
- aurora-postgres
- redis
steps:
-
uses: actions/download-artifact@v3
with:
name: apppack
path: bin
-
name: Destroy cluster
run: |
chmod +x ./bin/apppack
yes apppack-cluster-apppack | ./bin/apppack destroy cluster apppack --aws-credentials --region us-east-2
if: always()
timeout-minutes: 8
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-
name: Destroy region
run: |
yes apppack-region-us-east-2 | ./bin/apppack destroy region --aws-credentials --region us-east-2
if: always()
timeout-minutes: 3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-
name: Cleanup database snapshots
run: |
for d in $(aws rds describe-db-snapshots --snapshot-type manual --query 'DBSnapshots[].DBSnapshotIdentifier' --output text); do
aws rds delete-db-snapshot --db-snapshot-identifier "$d"
done
for d in $(aws rds describe-db-cluster-snapshots --snapshot-type manual --query 'DBClusterSnapshots[].DBClusterSnapshotIdentifier' --output text); do
aws rds delete-db-cluster-snapshot --db-cluster-snapshot-identifier "$d"
done
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-2