Skip to content

Commit 61c8093

Browse files
committed
Add no execute changeset test
1 parent 052d850 commit 61c8093

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,52 @@ jobs:
4545
template: long-running-stack.yaml
4646
capabilities: "CAPABILITY_IAM"
4747
timeout-in-minutes: 90
48+
49+
test-no-execute-changeset:
50+
runs-on: ubuntu-latest
51+
steps:
52+
- name: Check out repository code
53+
uses: actions/checkout@v3
54+
- name: Configure AWS credentials from Test account
55+
uses: aws-actions/configure-aws-credentials@v1
56+
with:
57+
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
58+
aws-region: us-east-1
59+
- name: Cleanup existing stack if present
60+
run: |
61+
STACK_NAME="test-no-execute-changeset-${{ github.run_number }}-${{ github.run_attempt }}"
62+
if aws cloudformation describe-stacks --stack-name $STACK_NAME 2>/dev/null; then
63+
echo "Stack exists, deleting it first..."
64+
aws cloudformation delete-stack --stack-name $STACK_NAME
65+
aws cloudformation wait stack-delete-complete --stack-name $STACK_NAME
66+
fi
67+
- name: Deploy with no-execute-changeset=1 (should create stack in REVIEW_IN_PROGRESS)
68+
uses: aws-actions/aws-cloudformation-github-deploy@master
69+
with:
70+
name: test-no-execute-changeset-${{ github.run_number }}-${{ github.run_attempt }}
71+
template: no-execute-changeset-test.yaml
72+
capabilities: "CAPABILITY_IAM"
73+
no-execute-changeset: "1"
74+
- name: Verify stack is in REVIEW_IN_PROGRESS status
75+
run: |
76+
STACK_NAME="test-no-execute-changeset-${{ github.run_number }}-${{ github.run_attempt }}"
77+
echo "Checking stack status after deployment with no-execute-changeset=1..."
78+
STACK_STATUS=$(aws cloudformation describe-stacks --stack-name $STACK_NAME --query 'Stacks[0].StackStatus' --output text)
79+
echo "Stack status: $STACK_STATUS"
80+
81+
if [ "$STACK_STATUS" = "REVIEW_IN_PROGRESS" ]; then
82+
echo "✅ SUCCESS: Stack is in REVIEW_IN_PROGRESS status as expected"
83+
else
84+
echo "❌ FAILURE: Stack status is $STACK_STATUS, expected REVIEW_IN_PROGRESS"
85+
echo "This indicates the bug is present - the changeset was executed despite no-execute-changeset=1"
86+
exit 1
87+
fi
88+
- name: Cleanup test stack
89+
if: always()
90+
run: |
91+
STACK_NAME="test-no-execute-changeset-${{ github.run_number }}-${{ github.run_attempt }}"
92+
if aws cloudformation describe-stacks --stack-name $STACK_NAME 2>/dev/null; then
93+
aws cloudformation delete-stack --stack-name $STACK_NAME
94+
aws cloudformation wait stack-delete-complete --stack-name $STACK_NAME
95+
echo "Test stack cleaned up successfully"
96+
fi

no-execute-changeset-test.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Description: 'Simple S3 bucket for testing no-execute-changeset functionality'
3+
4+
Parameters:
5+
BucketPrefix:
6+
Type: String
7+
Default: 'test-no-execute-changeset'
8+
Description: 'Prefix for the S3 bucket name'
9+
10+
Resources:
11+
TestBucket:
12+
Type: AWS::S3::Bucket
13+
Properties:
14+
BucketName: !Sub '${BucketPrefix}-${AWS::AccountId}-${AWS::Region}'
15+
PublicAccessBlockConfiguration:
16+
BlockPublicAcls: true
17+
BlockPublicPolicy: true
18+
IgnorePublicAcls: true
19+
RestrictPublicBuckets: true
20+
21+
Outputs:
22+
BucketName:
23+
Description: 'Name of the created S3 bucket'
24+
Value: !Ref TestBucket

0 commit comments

Comments
 (0)