Skip to content

Commit 2622101

Browse files
committed
Add additional testing
1 parent 2e17eb9 commit 2622101

File tree

8 files changed

+521
-12
lines changed

8 files changed

+521
-12
lines changed

.github/workflows/develop.yaml

Lines changed: 233 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,241 @@ jobs:
279279
capabilities: "CAPABILITY_IAM"
280280
timeout-in-minutes: 90
281281

282+
test-changeset-formatting:
283+
runs-on: ubuntu-latest
284+
steps:
285+
- uses: actions/checkout@v4
286+
287+
- name: Configure AWS credentials
288+
uses: aws-actions/configure-aws-credentials@v4
289+
with:
290+
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
291+
aws-region: us-east-1
292+
293+
- name: Create stack with multiple resource types for formatting test
294+
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
295+
with:
296+
name: test-formatting-${{ github.run_number }}
297+
template: formatting-test-template.yaml
298+
parameter-overrides: "Environment=test,BucketPrefix=format-test"
299+
300+
- name: Update stack to generate diverse change set
301+
id: update-stack
302+
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
303+
with:
304+
name: test-formatting-${{ github.run_number }}
305+
template: formatting-test-template-updated.yaml
306+
parameter-overrides: "Environment=prod,BucketPrefix=format-updated"
307+
308+
- name: Verify change set outputs
309+
run: |
310+
echo "Changes Count: ${{ steps.update-stack.outputs.changes-count }}"
311+
echo "Has Changes: ${{ steps.update-stack.outputs.has-changes }}"
312+
echo '${{ steps.update-stack.outputs.changes-summary }}' | jq .
313+
314+
test-markdown-output:
315+
runs-on: ubuntu-latest
316+
steps:
317+
- uses: actions/checkout@v4
318+
319+
- name: Configure AWS credentials
320+
uses: aws-actions/configure-aws-credentials@v4
321+
with:
322+
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
323+
aws-region: us-east-1
324+
325+
- name: Create change set for markdown testing
326+
id: create-markdown-cs
327+
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
328+
with:
329+
mode: "create-only"
330+
name: test-markdown-${{ github.run_number }}
331+
template: markdown-test-template.yaml
332+
parameter-overrides: "Environment=test"
333+
334+
- name: Verify markdown output format
335+
run: |
336+
echo "Markdown Output:"
337+
echo '${{ steps.create-markdown-cs.outputs.changes-markdown }}'
338+
339+
if [[ '${{ steps.create-markdown-cs.outputs.changes-markdown }}' == *"## 📋 CloudFormation Change Set"* ]]; then
340+
echo "✅ Markdown header found"
341+
else
342+
echo "❌ Markdown header missing"
343+
exit 1
344+
fi
345+
346+
if [[ '${{ steps.create-markdown-cs.outputs.changes-markdown }}' == *"<details>"* ]]; then
347+
echo "✅ Collapsible sections found"
348+
else
349+
echo "❌ Collapsible sections missing"
350+
exit 1
351+
fi
352+
353+
test-event-streaming:
354+
runs-on: ubuntu-latest
355+
steps:
356+
- uses: actions/checkout@v4
357+
358+
- name: Configure AWS credentials
359+
uses: aws-actions/configure-aws-credentials@v4
360+
with:
361+
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
362+
aws-region: us-east-1
363+
364+
- name: Deploy stack with event streaming
365+
id: deploy-with-events
366+
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
367+
with:
368+
name: test-events-${{ github.run_number }}
369+
template: event-streaming-test.yaml
370+
parameter-overrides: "Environment=test,DelaySeconds=30"
371+
372+
- name: Verify deployment completed
373+
run: |
374+
echo "Stack ID: ${{ steps.deploy-with-events.outputs.stack-id }}"
375+
aws cloudformation describe-stacks --stack-name test-events-${{ github.run_number }}
376+
377+
test-boolean-inputs:
378+
runs-on: ubuntu-latest
379+
strategy:
380+
matrix:
381+
test-case:
382+
- name: "string-true"
383+
fail-on-empty: "true"
384+
no-execute: "false"
385+
disable-rollback: "1"
386+
- name: "boolean-true"
387+
fail-on-empty: true
388+
no-execute: false
389+
disable-rollback: true
390+
- name: "boolean-false"
391+
fail-on-empty: false
392+
no-execute: true
393+
disable-rollback: false
394+
steps:
395+
- uses: actions/checkout@v4
396+
397+
- name: Configure AWS credentials
398+
uses: aws-actions/configure-aws-credentials@v4
399+
with:
400+
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
401+
aws-region: us-east-1
402+
403+
- name: Test boolean input parsing - ${{ matrix.test-case.name }}
404+
id: test-boolean
405+
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
406+
with:
407+
name: test-bool-${{ matrix.test-case.name }}-${{ github.run_number }}
408+
template: stack.yaml
409+
parameter-overrides: "Environment=test"
410+
fail-on-empty-changeset: ${{ matrix.test-case.fail-on-empty }}
411+
no-execute-changeset: ${{ matrix.test-case.no-execute }}
412+
disable-rollback: ${{ matrix.test-case.disable-rollback }}
413+
continue-on-error: true
414+
415+
- name: Verify boolean handling
416+
run: |
417+
echo "Test case: ${{ matrix.test-case.name }}"
418+
echo "Boolean inputs processed successfully"
419+
420+
test-enhanced-validation-errors:
421+
runs-on: ubuntu-latest
422+
steps:
423+
- uses: actions/checkout@v4
424+
425+
- name: Configure AWS credentials
426+
uses: aws-actions/configure-aws-credentials@v4
427+
with:
428+
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
429+
aws-region: us-east-1
430+
431+
- name: Test multiple validation errors
432+
id: validation-test
433+
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
434+
with:
435+
name: test-validation-enhanced-${{ github.run_number }}
436+
template: multiple-validation-errors.yaml
437+
parameter-overrides: "Environment=test"
438+
continue-on-error: true
439+
440+
- name: Verify detailed error information
441+
run: |
442+
echo "Validation test completed (expected to fail)"
443+
echo "Enhanced error reporting should provide detailed validation failure information"
444+
445+
test-stack-id-retrieval:
446+
runs-on: ubuntu-latest
447+
steps:
448+
- uses: actions/checkout@v4
449+
450+
- name: Configure AWS credentials
451+
uses: aws-actions/configure-aws-credentials@v4
452+
with:
453+
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
454+
aws-region: us-east-1
455+
456+
- name: Test stack creation with ID retrieval
457+
id: create-stack
458+
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
459+
with:
460+
name: test-stack-id-${{ github.run_number }}
461+
template: stack.yaml
462+
parameter-overrides: "Environment=test"
463+
464+
- name: Verify stack ID format
465+
run: |
466+
STACK_ID="${{ steps.create-stack.outputs.stack-id }}"
467+
echo "Stack ID: $STACK_ID"
468+
469+
if [[ $STACK_ID == arn:aws:cloudformation:* ]]; then
470+
echo "✅ Stack ID is in correct ARN format"
471+
else
472+
echo "❌ Stack ID format is incorrect: $STACK_ID"
473+
exit 1
474+
fi
475+
476+
aws cloudformation describe-stacks --stack-name "$STACK_ID"
477+
478+
test-execute-only-with-events:
479+
runs-on: ubuntu-latest
480+
steps:
481+
- uses: actions/checkout@v4
482+
483+
- name: Configure AWS credentials
484+
uses: aws-actions/configure-aws-credentials@v4
485+
with:
486+
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
487+
aws-region: us-east-1
488+
489+
- name: Create change set
490+
id: create-cs
491+
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
492+
with:
493+
mode: "create-only"
494+
name: test-execute-events-${{ github.run_number }}
495+
template: event-streaming-test.yaml
496+
parameter-overrides: "Environment=test,DelaySeconds=20"
497+
498+
- name: Execute change set with event streaming
499+
id: execute-cs
500+
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
501+
with:
502+
mode: "execute-only"
503+
name: test-execute-events-${{ github.run_number }}
504+
execute-change-set-id: ${{ steps.create-cs.outputs.change-set-id }}
505+
506+
- name: Verify execution with events
507+
run: |
508+
echo "Execution completed with stack ID: ${{ steps.execute-cs.outputs.stack-id }}"
509+
aws cloudformation describe-stacks \
510+
--stack-name test-execute-events-${{ github.run_number }} \
511+
--query 'Stacks[0].StackStatus' \
512+
--output text
513+
282514
cleanup:
283515
runs-on: ubuntu-latest
284-
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]
516+
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]
285517
if: always()
286518
steps:
287519
- name: Configure AWS credentials

event-streaming-test.yaml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Description: 'Template with resources that take time to create for event streaming tests'
3+
4+
Parameters:
5+
Environment:
6+
Type: String
7+
Default: test
8+
DelaySeconds:
9+
Type: Number
10+
Default: 30
11+
Description: 'Delay in seconds for Lambda function'
12+
13+
Resources:
14+
EventTestVPC:
15+
Type: AWS::EC2::VPC
16+
Properties:
17+
CidrBlock: 10.0.0.0/16
18+
EnableDnsHostnames: true
19+
EnableDnsSupport: true
20+
Tags:
21+
- Key: Name
22+
Value: !Sub "${Environment}-event-test-vpc"
23+
24+
EventTestSubnet:
25+
Type: AWS::EC2::Subnet
26+
Properties:
27+
VpcId: !Ref EventTestVPC
28+
CidrBlock: 10.0.1.0/24
29+
AvailabilityZone: !Select [0, !GetAZs '']
30+
Tags:
31+
- Key: Name
32+
Value: !Sub "${Environment}-event-test-subnet"
33+
34+
EventTestSecurityGroup:
35+
Type: AWS::EC2::SecurityGroup
36+
Properties:
37+
GroupDescription: Security group for event streaming test
38+
VpcId: !Ref EventTestVPC
39+
SecurityGroupEgress:
40+
- IpProtocol: -1
41+
CidrIp: 0.0.0.0/0
42+
43+
EventTestRole:
44+
Type: AWS::IAM::Role
45+
Properties:
46+
AssumeRolePolicyDocument:
47+
Version: '2012-10-17'
48+
Statement:
49+
- Effect: Allow
50+
Principal:
51+
Service: lambda.amazonaws.com
52+
Action: sts:AssumeRole
53+
ManagedPolicyArns:
54+
- arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole
55+
56+
EventTestFunction:
57+
Type: AWS::Lambda::Function
58+
Properties:
59+
FunctionName: !Sub "event-test-${Environment}-${AWS::AccountId}"
60+
Runtime: python3.9
61+
Handler: index.handler
62+
Role: !GetAtt EventTestRole.Arn
63+
VpcConfig:
64+
SecurityGroupIds:
65+
- !Ref EventTestSecurityGroup
66+
SubnetIds:
67+
- !Ref EventTestSubnet
68+
Code:
69+
ZipFile: !Sub |
70+
import time
71+
def handler(event, context):
72+
time.sleep(${DelaySeconds})
73+
return {'statusCode': 200, 'body': 'Event streaming test complete'}
74+
75+
Outputs:
76+
VPCId:
77+
Value: !Ref EventTestVPC
78+
FunctionArn:
79+
Value: !GetAtt EventTestFunction.Arn
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Description: 'Updated template for testing change set formatting with modifications'
3+
4+
Parameters:
5+
Environment:
6+
Type: String
7+
Default: prod
8+
BucketPrefix:
9+
Type: String
10+
Default: format-updated
11+
12+
Resources:
13+
TestBucket:
14+
Type: AWS::S3::Bucket
15+
Properties:
16+
BucketName: !Sub "${BucketPrefix}-${Environment}-${AWS::AccountId}"
17+
VersioningConfiguration:
18+
Status: Enabled
19+
Tags:
20+
- Key: Environment
21+
Value: !Ref Environment
22+
- Key: Updated
23+
Value: "true"
24+
25+
TestParameter:
26+
Type: AWS::SSM::Parameter
27+
Properties:
28+
Name: !Sub "/${Environment}/formatting-test/parameter"
29+
Type: String
30+
Value: !Sub "updated-value-${Environment}"
31+
Description: "Updated parameter for formatting test"
32+
Tags:
33+
Environment: !Ref Environment
34+
Updated: "true"
35+
36+
TestRole:
37+
Type: AWS::IAM::Role
38+
Properties:
39+
RoleName: !Sub "formatting-test-role-${Environment}"
40+
AssumeRolePolicyDocument:
41+
Version: '2012-10-17'
42+
Statement:
43+
- Effect: Allow
44+
Principal:
45+
Service: lambda.amazonaws.com
46+
Action: sts:AssumeRole
47+
ManagedPolicyArns:
48+
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
49+
- arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess
50+
51+
NewParameter:
52+
Type: AWS::SSM::Parameter
53+
Properties:
54+
Name: !Sub "/${Environment}/formatting-test/new-parameter"
55+
Type: String
56+
Value: "newly-added-parameter"
57+
Tags:
58+
Environment: !Ref Environment
59+
60+
Outputs:
61+
BucketName:
62+
Value: !Ref TestBucket
63+
ParameterName:
64+
Value: !Ref TestParameter
65+
RoleName:
66+
Value: !Ref TestRole
67+
NewParameterName:
68+
Value: !Ref NewParameter

0 commit comments

Comments
 (0)