-
Notifications
You must be signed in to change notification settings - Fork 0
583 lines (501 loc) · 22 KB
/
develop.yaml
File metadata and controls
583 lines (501 loc) · 22 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
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
name: Test CloudFormation Action v2.0.0-beta
on:
workflow_dispatch:
push:
branches: [main]
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
test-create-and-execute:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Test with local template and JSON file
id: deploy-file
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
name: test-file-${{ github.run_number }}
template: stack.yaml
parameter-overrides: "file:///${{ github.workspace }}/overrides.json"
- name: Test with inline parameters
id: deploy-inline
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
name: test-inline-${{ github.run_number }}
template: stack.yaml
parameter-overrides: "Environment=gamma,AList=value1,AList=value2"
test-large-template:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Test with large template (should fail with clean error message)
id: deploy-large
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
name: test-large-${{ github.run_number }}
template: large-template.yaml
parameter-overrides: "Environment=test"
continue-on-error: true
- name: Verify large template error message
run: |
echo "Large template test completed (expected to fail)"
echo "This test verifies that oversized templates produce clean error messages"
test-validation-error:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Test template with validation error (should fail during change set creation)
id: deploy-validation-error
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
name: test-validation-error-${{ github.run_number }}
template: validation-error-template.yaml
parameter-overrides: "Environment=test"
continue-on-error: true
- name: Verify validation error handling
run: |
echo "Validation error test completed (expected to fail during change set creation)"
echo "This test verifies that template validation errors produce clean error messages"
test-execution-error:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Test template with execution error (should fail during change set execution)
id: deploy-execution-error
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
name: test-execution-error-${{ github.run_number }}
template: execution-error-template.yaml
parameter-overrides: "Environment=test"
continue-on-error: true
- name: Verify execution error handling
run: |
echo "Execution error test completed (expected to fail during change set execution)"
echo "This test verifies that execution errors produce detailed failure information"
test-empty-changeset:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Deploy stack first time
id: deploy-first
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
name: test-empty-changeset-${{ github.run_number }}
template: stack.yaml
parameter-overrides: "Environment=beta,AList=value1,AList=value2"
- name: Deploy same stack again with default behavior (should succeed on empty changeset)
id: deploy-second-default
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
name: test-empty-changeset-${{ github.run_number }}
template: stack.yaml
parameter-overrides: "Environment=beta,AList=value1,AList=value2"
- name: Deploy same stack again with fail-on-empty-changeset=1 (should fail on empty changeset)
id: deploy-second-fail
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
name: test-empty-changeset-${{ github.run_number }}
template: stack.yaml
parameter-overrides: "Environment=beta,AList=value1,AList=value2"
fail-on-empty-changeset: "1"
continue-on-error: true
- name: Verify empty changeset behavior
run: |
echo "Empty changeset test completed"
echo "First deployment: ${{ steps.deploy-first.outputs.stack-id }}"
echo "Second deployment (default): ${{ steps.deploy-second-default.outputs.stack-id }}"
echo "Third deployment (fail flag): Expected to fail"
echo "This verifies v2 behavior: empty changesets succeed by default, fail when flag is set"
test-create-only-then-execute:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Create change set for review
id: create-cs
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
mode: "create-only"
name: test-two-step-${{ github.run_number }}
template: stack.yaml
parameter-overrides: "Environment=prod,AList=prod1,AList=prod2"
- name: Review change set outputs
run: |
echo "Change Set ID: ${{ steps.create-cs.outputs.change-set-id }}"
echo "Has Changes: ${{ steps.create-cs.outputs.has-changes }}"
echo "Changes Count: ${{ steps.create-cs.outputs.changes-count }}"
echo "Changes Summary: ${{ steps.create-cs.outputs.changes-summary }}"
- name: Execute change set
if: steps.create-cs.outputs.has-changes == 'true'
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
mode: "execute-only"
name: test-two-step-${{ github.run_number }}
execute-change-set-id: ${{ steps.create-cs.outputs.change-set-id }}
test-drift-detection:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Deploy initial stack for drift testing
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
name: test-drift-${{ github.run_number }}
template: drift-test.yaml
parameter-overrides: "RunNumber=${{ github.run_number }}"
- name: Introduce drift by manually changing parameter
run: |
# Debug: Check if parameter exists
echo "Checking if parameter exists..."
aws ssm describe-parameters --parameter-filters "Key=Name,Values=/test/drift-${{ github.run_number }}" || echo "Parameter not found"
# Debug: List all parameters with our prefix
echo "Listing parameters with /test/drift prefix..."
aws ssm describe-parameters --parameter-filters "Key=Name,Option=BeginsWith,Values=/test/drift" || echo "No parameters found"
# Add a tag outside of CloudFormation to create drift
echo "Adding tags to parameter..."
aws ssm add-tags-to-resource \
--resource-type Parameter \
--resource-id /test/drift-${{ github.run_number }} \
--tags Key=ManualTag,Value=added-outside-cfn
# Change the parameter value to create more drift
echo "Updating parameter value..."
aws ssm put-parameter \
--name /test/drift-${{ github.run_number }} \
--value "manually-changed-value" \
--overwrite
- name: Create drift-reverting change set
id: drift-cs
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
mode: "create-only"
name: test-drift-${{ github.run_number }}
template: drift-test.yaml
parameter-overrides: "RunNumber=${{ github.run_number }}"
deployment-mode: "REVERT_DRIFT"
- name: Review drift change set
run: |
echo "Drift Change Set ID: ${{ steps.drift-cs.outputs.change-set-id }}"
echo "Has Changes: ${{ steps.drift-cs.outputs.has-changes }}"
echo "Changes Count: ${{ steps.drift-cs.outputs.changes-count }}"
echo "Changes Summary: ${{ steps.drift-cs.outputs.changes-summary }}"
- name: Execute drift-reverting change set
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
mode: "execute-only"
name: test-drift-${{ github.run_number }}
execute-change-set-id: ${{ steps.drift-cs.outputs.change-set-id }}
test-long-running:
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
role-duration-seconds: 7200
- name: Test long-running stack (70 minutes)
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
name: test-long-running-${{ github.run_number }}
template: long-running-stack.yaml
capabilities: "CAPABILITY_IAM"
timeout-in-minutes: 90
test-changeset-formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Create stack with multiple resource types for formatting test
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
name: test-formatting-${{ github.run_number }}
template: formatting-test-template.yaml
parameter-overrides: "Environment=test,BucketPrefix=format-test"
capabilities: "CAPABILITY_NAMED_IAM"
- name: Update stack to generate diverse change set
id: update-stack
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
name: test-formatting-${{ github.run_number }}
template: formatting-test-template-updated.yaml
parameter-overrides: "Environment=prod,BucketPrefix=format-updated"
capabilities: "CAPABILITY_NAMED_IAM"
- name: Verify change set outputs
run: |
echo "Changes Count: ${{ steps.update-stack.outputs.changes-count }}"
echo "Has Changes: ${{ steps.update-stack.outputs.has-changes }}"
echo '${{ steps.update-stack.outputs.changes-summary }}' | jq .
test-markdown-output:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Create initial stack for markdown testing
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
name: test-markdown-${{ github.run_number }}
template: markdown-test-template.yaml
parameter-overrides: "Environment=test"
- name: Update stack to generate markdown output
id: create-markdown-cs
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
mode: "create-only"
name: test-markdown-${{ github.run_number }}
template: markdown-test-template-updated.yaml
parameter-overrides: "Environment=test"
no-execute-changeset: true
- name: Verify markdown output format
run: |
echo "Markdown Output:"
echo '${{ steps.create-markdown-cs.outputs.changes-markdown }}'
if [[ '${{ steps.create-markdown-cs.outputs.changes-markdown }}' == *"## 📋 CloudFormation Change Set"* ]]; then
echo "✅ Markdown header found"
else
echo "❌ Markdown header missing"
exit 1
fi
if [[ '${{ steps.create-markdown-cs.outputs.changes-markdown }}' == *"<details>"* ]]; then
echo "✅ Collapsible sections found"
else
echo "❌ Collapsible sections missing"
exit 1
fi
test-event-streaming:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Deploy stack with event streaming
id: deploy-with-events
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
name: test-events-${{ github.run_number }}
template: event-streaming-test.yaml
parameter-overrides: "Environment=test,DelaySeconds=30"
capabilities: "CAPABILITY_IAM"
- name: Verify deployment completed
run: |
echo "Stack ID: ${{ steps.deploy-with-events.outputs.stack-id }}"
aws cloudformation describe-stacks --stack-name test-events-${{ github.run_number }}
test-boolean-inputs:
runs-on: ubuntu-latest
strategy:
matrix:
test-case:
- name: "string-true"
fail-on-empty: "true"
no-execute: "false"
disable-rollback: "1"
- name: "boolean-true"
fail-on-empty: true
no-execute: false
disable-rollback: true
- name: "boolean-false"
fail-on-empty: false
no-execute: true
disable-rollback: false
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Test boolean input parsing - ${{ matrix.test-case.name }}
id: test-boolean
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
name: test-bool-${{ matrix.test-case.name }}-${{ github.run_number }}
template: stack.yaml
parameter-overrides: "Environment=beta"
fail-on-empty-changeset: ${{ matrix.test-case.fail-on-empty }}
no-execute-changeset: ${{ matrix.test-case.no-execute }}
disable-rollback: ${{ matrix.test-case.disable-rollback }}
continue-on-error: true
- name: Verify boolean handling
run: |
echo "Test case: ${{ matrix.test-case.name }}"
echo "Boolean inputs processed successfully"
test-enhanced-validation-errors:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Test multiple validation errors
id: validation-test
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
name: test-validation-enhanced-${{ github.run_number }}
template: multiple-validation-errors.yaml
parameter-overrides: "Environment=test"
continue-on-error: true
- name: Verify detailed error information
run: |
echo "Validation test completed (expected to fail)"
echo "Enhanced error reporting should provide detailed validation failure information"
test-stack-id-retrieval:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Test stack creation with ID retrieval
id: create-stack
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
name: test-stack-id-${{ github.run_number }}
template: stack.yaml
parameter-overrides: "Environment=beta"
- name: Verify stack ID retrieval
run: |
STACK_ID="${{ steps.create-stack.outputs.stack-id }}"
echo "Stack ID: $STACK_ID"
echo "Deployment outcome: ${{ steps.create-stack.outcome }}"
# Should get either ARN or stack name for successful deployment
if [[ $STACK_ID == arn:aws:cloudformation:* ]]; then
echo "✅ Got stack ARN: $STACK_ID"
elif [[ "$STACK_ID" == "test-stack-id-${{ github.run_number }}" ]]; then
echo "✅ Got stack name: $STACK_ID"
else
echo "❌ Unexpected stack ID: $STACK_ID (expected ARN or stack name)"
exit 1
fi
# Verify we can access the stack
aws cloudformation describe-stacks --stack-name "$STACK_ID"
echo "✅ Stack is accessible"
test-execute-only-with-events:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Create change set
id: create-cs
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
mode: "create-only"
name: test-execute-events-${{ github.run_number }}
template: event-streaming-test.yaml
parameter-overrides: "Environment=test,DelaySeconds=20"
capabilities: "CAPABILITY_IAM"
- name: Execute change set with event streaming
id: execute-cs
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
with:
mode: "execute-only"
name: test-execute-events-${{ github.run_number }}
execute-change-set-id: ${{ steps.create-cs.outputs.change-set-id }}
- name: Verify execution with events
run: |
echo "Execution completed with stack ID: ${{ steps.execute-cs.outputs.stack-id }}"
aws cloudformation describe-stacks \
--stack-name test-execute-events-${{ github.run_number }} \
--query 'Stacks[0].StackStatus' \
--output text
cleanup:
runs-on: ubuntu-latest
needs: [test-create-and-execute, test-large-template, test-validation-error, test-execution-error, test-create-only-then-execute, test-drift-detection, test-long-running, test-changeset-formatting, test-markdown-output, test-event-streaming, test-boolean-inputs, test-enhanced-validation-errors, test-stack-id-retrieval, test-execute-only-with-events]
if: always()
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Cleanup test stacks
run: |
# Find all test stacks for this run
stacks=$(aws cloudformation list-stacks \
--query "StackSummaries[?contains(StackName, 'test-') && contains(StackName, '${{ github.run_number }}') && StackStatus != 'DELETE_COMPLETE'].StackName" \
--output text)
if [ ! -z "$stacks" ]; then
echo "Found stacks to delete: $stacks"
echo "$stacks" | tr '\t' '\n' | while read stack; do
if [ ! -z "$stack" ]; then
echo "Deleting stack: $stack"
aws cloudformation delete-stack --stack-name "$stack"
fi
done
# Wait for all deletions to complete
echo "Waiting for stack deletions to complete..."
echo "$stacks" | tr '\t' '\n' | while read stack; do
if [ ! -z "$stack" ]; then
echo "Waiting for $stack to delete..."
aws cloudformation wait stack-delete-complete --stack-name "$stack" || echo "Stack $stack deletion failed or timed out"
fi
done
else
echo "No stacks found to delete"
fi
- name: Cleanup SSM parameters
run: |
# Clean up all test parameters for this run
echo "Cleaning up SSM parameters..."
aws ssm describe-parameters \
--parameter-filters "Key=Name,Option=BeginsWith,Values=/test/" \
--query "Parameters[?contains(Name, '${{ github.run_number }}')].Name" \
--output text | tr '\t' '\n' | while read param; do
if [ ! -z "$param" ]; then
echo "Deleting parameter: $param"
aws ssm delete-parameter --name "$param" || echo "Parameter $param already deleted"
fi
done