-
Notifications
You must be signed in to change notification settings - Fork 0
238 lines (202 loc) · 9.6 KB
/
ci.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
name: ci
on:
push:
paths-ignore:
- '**.md'
env:
AWS_REGION: us-east-1
jobs:
test-create-complete-stack-status:
runs-on: ubuntu-latest
env:
CFN_TEMPLATES: "./test/stacks/test-create-complete-stack.yml\n"
steps:
- name: clone the repo
uses: actions/checkout@v3
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v1.5.3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: validates all cloudformation templates
run: |
printf "${{ env.CFN_TEMPLATES }}" | while read template; do
aws cloudformation validate-template \
--template-body="file://$template"
done
- name: configure the environment
run: |
echo "STACK_NAME=test-create-complete-cfn-check-failed-status" >> $GITHUB_ENV
echo "CFN_CHECK_STATUS_CREATE_COMPLETE_BUCKET_NAME=test-create-complete-cfn-check-failed-status-bucket" >> $GITHUB_ENV
- name: deploy the create-complete-cfn-check-failed-status stack to "force" CREATE_COMPLETE status
run: |
aws cloudformation deploy \
--template-file="test/stacks/test-create-complete-stack.yml" \
--stack-name=${{ env.STACK_NAME }} \
--parameter-overrides \
CfnCheckStatusBucketName=${{ env.CFN_CHECK_STATUS_CREATE_COMPLETE_BUCKET_NAME }} \
--capabilities=CAPABILITY_NAMED_IAM \
--no-fail-on-empty-changeset
- name: test cfn-check-failed-status with a cloudformation stack in CREATE_COMPLETE status
uses: ./
id: checkstatus_create_complete
with:
cfn-stack-name: ${{ env.STACK_NAME }}
- name: validate output message of the status check
run: |
echo "${{ steps.checkstatus_create_complete.outputs.message }}"
- name: delete the create-complete-cfn-check-failed-status test stack
run: |
aws cloudformation delete-stack \
--stack-name=${{ env.STACK_NAME }}
aws s3 rb s3://${{ env.CFN_CHECK_STATUS_CREATE_COMPLETE_BUCKET_NAME }} --force
test-rollback-complete-stack-status:
runs-on: ubuntu-latest
needs: test-create-complete-stack-status
env:
CFN_TEMPLATES: "./test/stacks/test-rollback-complete-stack.yml\n"
steps:
- name: clone the repo
uses: actions/checkout@v3
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v1.5.3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: validates all cloudformation templates
run: |
printf "${{ env.CFN_TEMPLATES }}" | while read template; do
aws cloudformation validate-template \
--template-body="file://$template"
done
- name: configure the environment with two identical bucket name environment variables
run: |
echo "STACK_NAME=test-rollback-complete-cfn-check-failed-status" >> $GITHUB_ENV
echo "CFN_CHECK_STATUS_CREATE_FAILED_BUCKET_NAME=test-rollback-complete-cfn-check-failed-status-bucket" >> $GITHUB_ENV
echo "CFN_CHECK_STATUS_CREATE_FAILED_BUCKET_NAME_2=test-rollback-complete-cfn-check-failed-status-bucket" >> $GITHUB_ENV
- name: deploy the rollback-complete-cfn-check-failed-status stack
continue-on-error: true
run: |
aws cloudformation deploy \
--template-file="test/stacks/test-rollback-complete-stack.yml" \
--stack-name=${{ env.STACK_NAME }} \
--parameter-overrides \
CfnCheckStatusBucketName=${{ env.CFN_CHECK_STATUS_CREATE_FAILED_BUCKET_NAME }} \
--capabilities=CAPABILITY_NAMED_IAM \
--no-fail-on-empty-changeset
- name: test cfn-check-failed-status with a cloudformation stack in ROLLBACK_COMPLETE status
uses: ./
id: checkstatus_rollback_complete
with:
cfn-stack-name: ${{ env.STACK_NAME }}
- name: delete the rollback-complete-cfn-check-failed-status test stack
run: |
aws cloudformation delete-stack \
--stack-name=${{ env.STACK_NAME }}
- name: validate output message of the status check
run: |
echo "${{ steps.checkstatus_rollback_complete.outputs.message }}"
test-delete-failed-stack-status:
runs-on: ubuntu-latest
needs: test-rollback-complete-stack-status
env:
CFN_TEMPLATES: "./test/stacks/test-delete-failed-stack.yml\n"
steps:
- name: clone the repo
uses: actions/checkout@v3
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v1.5.3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: validates all cloudformation templates
run: |
printf "${{ env.CFN_TEMPLATES }}" | while read template; do
aws cloudformation validate-template \
--template-body="file://$template"
done
- name: configure the environment
run: |
echo "STACK_NAME=test-delete-failed-cfn-check-failed-status" >> $GITHUB_ENV
echo "CFN_CHECK_STATUS_DELETE_FAILED_A_BUCKET_NAME=test-delete-failed-cfn-check-failed-status-bucket-a" >> $GITHUB_ENV
echo "CFN_CHECK_STATUS_DELETE_FAILED_B_BUCKET_NAME=test-delete-failed-cfn-check-failed-status-bucket-b" >> $GITHUB_ENV
- name: deploy the cfn stack
run: |
aws cloudformation deploy \
--template-file="test/stacks/test-delete-failed-stack.yml" \
--stack-name=${{ env.STACK_NAME }} \
--parameter-overrides \
CfnCheckStatusABucketName=${{ env.CFN_CHECK_STATUS_DELETE_FAILED_A_BUCKET_NAME }} \
CfnCheckStatusBBucketName=${{ env.CFN_CHECK_STATUS_DELETE_FAILED_B_BUCKET_NAME }} \
--capabilities=CAPABILITY_NAMED_IAM \
--no-fail-on-empty-changeset
- name: populate buckets of the test stack
run: |
aws s3 cp test/fixtures/example.txt s3://${{ env.CFN_CHECK_STATUS_DELETE_FAILED_A_BUCKET_NAME }}/
aws s3 cp test/fixtures/example.txt s3://${{ env.CFN_CHECK_STATUS_DELETE_FAILED_B_BUCKET_NAME }}/
- name: deletes test stack (no --force) to force DELETE_FAILED status
continue-on-error: true
run: |
aws cloudformation delete-stack --stack-name=${{ env.STACK_NAME }}
- name: test cfn-check-failed-status with a cloudformation stack in DELETE_FAILED status
uses: ./
id: checkstatus_delete_failed
with:
cfn-stack-name: ${{ env.STACK_NAME }}
- name: validate output message of the status check
run: |
echo "${{ steps.checkstatus_delete_failed.outputs.message }}"
test-update-rollback-complete-stack-status:
runs-on: ubuntu-latest
needs: test-delete-failed-stack-status
env:
CFN_TEMPLATES: "./test/stacks/test-update-rollback-complete-stack.yml\n./test/stacks/test-update-rollback-complete-stack0.yml\n"
steps:
- name: clone the repo
uses: actions/checkout@v3
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v1.5.3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: validates all cloudformation templates
run: |
printf "${{ env.CFN_TEMPLATES }}" | while read template; do
aws cloudformation validate-template \
--template-body="file://$template"
done
- name: configure the environment
run: |
echo "STACK_NAME=test-update-rollback-complete-cfn-check-failed-status" >> $GITHUB_ENV
echo "CFN_CHECK_STATUS_UPDATE_ROLLBACK_COMPLETE_BUCKET_NAME=test-update-rollback-complete-cfn-check-failed-status-bucket" >> $GITHUB_ENV
- name: deploy the update-rollback-complete-cfn-check-failed-status stack
run: |
aws cloudformation deploy \
--template-file="test/stacks/test-update-rollback-complete-stack.yml" \
--stack-name=${{ env.STACK_NAME }} \
--parameter-overrides \
CfnCheckStatusBucketName=${{ env.CFN_CHECK_STATUS_UPDATE_ROLLBACK_COMPLETE_BUCKET_NAME }} \
--capabilities=CAPABILITY_NAMED_IAM \
--no-fail-on-empty-changeset
- name: redeploy the update-rollback-complete-cfn-check-failed-status stack to force UPDATE_ROLLBACK_COMPLETE status
continue-on-error: true
run: |
aws cloudformation deploy \
--template-file="test/stacks/test-update-rollback-complete-stack0.yml" \
--stack-name=${{ env.STACK_NAME }} \
--parameter-overrides \
CfnCheckStatusBucketName=${{ env.CFN_CHECK_STATUS_UPDATE_ROLLBACK_COMPLETE_BUCKET_NAME }} \
--capabilities=CAPABILITY_NAMED_IAM \
--no-fail-on-empty-changeset
- name: test cfn-check-failed-status with a cloudformation stack in UPDATE_ROLLBACK_COMPLETE status
uses: ./
id: checkstatus_update_rollback_complete
with:
cfn-stack-name: ${{ env.STACK_NAME }}
- name: validate output message of the status check
run: |
echo "${{ steps.checkstatus_update_rollback_complete.outputs.message }}"