Skip to content

Commit

Permalink
feat: enable snapshot tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sbstjn committed Mar 23, 2024
1 parent bbea109 commit 5cd9ae3
Show file tree
Hide file tree
Showing 4 changed files with 407 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/aws/stacks/Compute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ describe('Stack', () => {
template = Template.fromStack(stack)
})

describe('Template', () => {
it('match snapshot', () => {
expect(template.toJSON()).toMatchSnapshot();
})
})

describe('SQS Queue', () => {
it('is created', () => {
template.hasResource('AWS::SQS::Queue', {
Expand Down
6 changes: 6 additions & 0 deletions test/aws/stacks/Storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ describe('Stack', () => {
template = Template.fromStack(stack)
})

describe('Template', () => {
it('match snapshot', () => {
expect(template.toJSON()).toMatchSnapshot();
})
})

describe('S3 Bucket', () => {
it('is created', () => {
template.hasResource('AWS::S3::Bucket', {})
Expand Down
283 changes: 283 additions & 0 deletions test/aws/stacks/__snapshots__/Compute.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,283 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Stack Template match snapshot 1`] = `
{
"Parameters": {
"BootstrapVersion": {
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]",
"Type": "AWS::SSM::Parameter::Value<String>",
},
},
"Resources": {
"keyAliasCEB16DF2": {
"Properties": {
"AliasName": "alias/compute/key",
"TargetKeyId": {
"Fn::GetAtt": [
"keyFEDD6EC0",
"Arn",
],
},
},
"Type": "AWS::KMS::Alias",
},
"keyFEDD6EC0": {
"DeletionPolicy": "Retain",
"Properties": {
"KeyPolicy": {
"Statement": [
{
"Action": "kms:*",
"Effect": "Allow",
"Principal": {
"AWS": {
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition",
},
":iam::",
{
"Ref": "AWS::AccountId",
},
":root",
],
],
},
},
"Resource": "*",
},
{
"Action": [
"kms:Decrypt",
"kms:GenerateDataKey",
],
"Effect": "Allow",
"Principal": {
"Service": "sns.amazonaws.com",
},
"Resource": "*",
},
{
"Action": [
"kms:Decrypt",
"kms:GenerateDataKey",
],
"Effect": "Allow",
"Principal": {
"AWS": {
"Fn::GetAtt": [
"processServiceRole4D05741A",
"Arn",
],
},
"Service": "sns.amazonaws.com",
},
"Resource": "*",
"Sid": "allow-sns",
},
],
"Version": "2012-10-17",
},
},
"Type": "AWS::KMS::Key",
"UpdateReplacePolicy": "Retain",
},
"process321CE2AE": {
"DependsOn": [
"processServiceRoleDefaultPolicy711CAD66",
"processServiceRole4D05741A",
],
"Properties": {
"Code": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
},
"S3Key": "e442148fa28aa746e7676e5f5c9c3de54f1f98d9a1fd1b96b52a9e391dd9b5f7.zip",
},
"Environment": {
"Variables": {
"AWS_NODEJS_CONNECTION_REUSE_ENABLED": "1",
"TOPIC_ARN": {
"Ref": "topic69831491",
},
},
},
"Handler": "index.handler",
"Role": {
"Fn::GetAtt": [
"processServiceRole4D05741A",
"Arn",
],
},
"Runtime": "nodejs16.x",
},
"Type": "AWS::Lambda::Function",
},
"processServiceRole4D05741A": {
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com",
},
},
],
"Version": "2012-10-17",
},
"ManagedPolicyArns": [
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition",
},
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
],
],
},
],
},
"Type": "AWS::IAM::Role",
},
"processServiceRoleDefaultPolicy711CAD66": {
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": "sns:Publish",
"Effect": "Allow",
"Resource": {
"Ref": "topic69831491",
},
},
],
"Version": "2012-10-17",
},
"PolicyName": "processServiceRoleDefaultPolicy711CAD66",
"Roles": [
{
"Ref": "processServiceRole4D05741A",
},
],
},
"Type": "AWS::IAM::Policy",
},
"queue276F7297": {
"DeletionPolicy": "Delete",
"Properties": {
"KmsDataKeyReusePeriodSeconds": 300,
"KmsMasterKeyId": {
"Fn::GetAtt": [
"keyFEDD6EC0",
"Arn",
],
},
"VisibilityTimeout": 300,
},
"Type": "AWS::SQS::Queue",
"UpdateReplacePolicy": "Delete",
},
"queuePolicy89DB7105": {
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": "sqs:SendMessage",
"Condition": {
"ArnEquals": {
"aws:SourceArn": {
"Ref": "topic69831491",
},
},
},
"Effect": "Allow",
"Principal": {
"Service": "sns.amazonaws.com",
},
"Resource": {
"Fn::GetAtt": [
"queue276F7297",
"Arn",
],
},
},
],
"Version": "2012-10-17",
},
"Queues": [
{
"Ref": "queue276F7297",
},
],
},
"Type": "AWS::SQS::QueuePolicy",
},
"queuecomputetopic73AC0DBD00649C29": {
"DependsOn": [
"queuePolicy89DB7105",
],
"Properties": {
"Endpoint": {
"Fn::GetAtt": [
"queue276F7297",
"Arn",
],
},
"Protocol": "sqs",
"RawMessageDelivery": true,
"TopicArn": {
"Ref": "topic69831491",
},
},
"Type": "AWS::SNS::Subscription",
},
"topic69831491": {
"Properties": {
"KmsMasterKeyId": {
"Fn::GetAtt": [
"keyFEDD6EC0",
"Arn",
],
},
},
"Type": "AWS::SNS::Topic",
},
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
{
"Assert": {
"Fn::Not": [
{
"Fn::Contains": [
[
"1",
"2",
"3",
"4",
"5",
],
{
"Ref": "BootstrapVersion",
},
],
},
],
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.",
},
],
},
},
}
`;
Loading

0 comments on commit 5cd9ae3

Please sign in to comment.