Skip to content

Commit 13ae355

Browse files
committed
Modify markdown and id retrieval tests
1 parent 72d7019 commit 13ae355

3 files changed

Lines changed: 115 additions & 14 deletions

File tree

.github/workflows/develop.yaml

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,10 @@ jobs:
335335
id: create-markdown-cs
336336
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
337337
with:
338+
mode: "create-only"
338339
name: test-markdown-${{ github.run_number }}
339-
template: markdown-test-template.yaml
340-
parameter-overrides: "Environment=gamma" # Change parameter to trigger update
340+
template: markdown-test-template-updated.yaml
341+
parameter-overrides: "Environment=test"
341342

342343
- name: Verify markdown output format
343344
run: |
@@ -462,27 +463,36 @@ jobs:
462463
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
463464
aws-region: us-east-1
464465

465-
- name: Test stack creation with ID retrieval
466-
id: create-stack
466+
- name: Test stack creation that fails to retrieve stack ID
467+
id: create-failing-stack
467468
uses: aws-actions/aws-cloudformation-github-deploy@v2.0.0-beta
468469
with:
469-
name: test-stack-id-${{ github.run_number }}
470-
template: stack.yaml
471-
parameter-overrides: "Environment=beta"
470+
name: test-failing-stack-id-${{ github.run_number }}
471+
template: failing-stack.yaml
472+
parameter-overrides: "Environment=test"
473+
continue-on-error: true
472474

473-
- name: Verify stack ID format
475+
- name: Verify stack ID retrieval on failure
474476
run: |
475-
STACK_ID="${{ steps.create-stack.outputs.stack-id }}"
477+
STACK_ID="${{ steps.create-failing-stack.outputs.stack-id }}"
476478
echo "Stack ID: $STACK_ID"
479+
echo "Deployment outcome: ${{ steps.create-failing-stack.outcome }}"
477480
478-
if [[ $STACK_ID == arn:aws:cloudformation:* ]]; then
479-
echo "✅ Stack ID is in correct ARN format"
481+
# For failed deployments, we should get a stack ID (ARN) for debugging
482+
if [[ "${{ steps.create-failing-stack.outcome }}" == "failure" ]]; then
483+
if [[ $STACK_ID == arn:aws:cloudformation:* ]]; then
484+
echo "✅ Stack ID retrieved successfully for failed deployment"
485+
# Verify we can access the failed stack for debugging
486+
aws cloudformation describe-stacks --stack-name "$STACK_ID"
487+
echo "✅ Failed stack is accessible for debugging"
488+
else
489+
echo "❌ Expected stack ARN for failed deployment, got: $STACK_ID"
490+
exit 1
491+
fi
480492
else
481-
echo "❌ Stack ID format is incorrect: $STACK_ID"
493+
echo "❌ Expected deployment to fail for this test"
482494
exit 1
483495
fi
484-
485-
aws cloudformation describe-stacks --stack-name "$STACK_ID"
486496
487497
test-execute-only-with-events:
488498
runs-on: ubuntu-latest

failing-stack.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Description: 'Template designed to fail during deployment for stack ID testing'
3+
4+
Parameters:
5+
Environment:
6+
Type: String
7+
Default: test
8+
9+
Resources:
10+
# This will fail because we're trying to create a bucket with an invalid name
11+
FailingBucket:
12+
Type: AWS::S3::Bucket
13+
Properties:
14+
BucketName: "INVALID_BUCKET_NAME_WITH_UPPERCASE_AND_UNDERSCORES"
15+
16+
# This Lambda will fail because the code doesn't exist
17+
FailingLambda:
18+
Type: AWS::Lambda::Function
19+
Properties:
20+
FunctionName: !Sub "failing-lambda-${Environment}"
21+
Runtime: python3.9
22+
Handler: index.handler
23+
Code:
24+
ZipFile: |
25+
# This will cause a runtime error
26+
import nonexistent_module
27+
def handler(event, context):
28+
return nonexistent_module.do_something()
29+
Role: !GetAtt FailingRole.Arn
30+
31+
FailingRole:
32+
Type: AWS::IAM::Role
33+
Properties:
34+
AssumeRolePolicyDocument:
35+
Version: '2012-10-17'
36+
Statement:
37+
- Effect: Allow
38+
Principal:
39+
Service: lambda.amazonaws.com
40+
Action: sts:AssumeRole
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Description: 'Updated template for testing markdown output generation'
3+
4+
Parameters:
5+
Environment:
6+
Type: String
7+
Default: test
8+
9+
Resources:
10+
MarkdownTestBucket:
11+
Type: AWS::S3::Bucket
12+
Properties:
13+
BucketName: !Sub "markdown-test-${Environment}-${AWS::StackName}"
14+
PublicAccessBlockConfiguration:
15+
BlockPublicAcls: true
16+
BlockPublicPolicy: true
17+
IgnorePublicAcls: true
18+
RestrictPublicBuckets: true
19+
# Added versioning to trigger a change
20+
VersioningConfiguration:
21+
Status: Enabled
22+
23+
MarkdownTestParameter:
24+
Type: AWS::SSM::Parameter
25+
Properties:
26+
Name: !Sub "/${Environment}/markdown-test/${AWS::StackName}"
27+
Type: String
28+
Value: "updated-markdown-test-value" # Changed value
29+
Description: "Updated parameter for markdown output testing"
30+
31+
# Added new resource
32+
MarkdownTestRole:
33+
Type: AWS::IAM::Role
34+
Properties:
35+
AssumeRolePolicyDocument:
36+
Version: '2012-10-17'
37+
Statement:
38+
- Effect: Allow
39+
Principal:
40+
Service: lambda.amazonaws.com
41+
Action: sts:AssumeRole
42+
ManagedPolicyArns:
43+
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
44+
45+
Outputs:
46+
BucketArn:
47+
Value: !GetAtt MarkdownTestBucket.Arn
48+
ParameterArn:
49+
Value: !Sub "arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter${MarkdownTestParameter}"
50+
RoleArn:
51+
Value: !GetAtt MarkdownTestRole.Arn

0 commit comments

Comments
 (0)