diff --git a/.github/semantic.yml b/.github/semantic.yml deleted file mode 100644 index 9de964cc96cc3..0000000000000 --- a/.github/semantic.yml +++ /dev/null @@ -1,17 +0,0 @@ -# Configuration for Semantic Pull Requests -titleOnly: true - -types: - - feat - - fix - - docs - - style - - refactor - - perf - - test - - build - - ci - - chore - - revert - - release - diff --git a/packages/@aws-cdk/aws-events/lib/archive.ts b/packages/@aws-cdk/aws-events/lib/archive.ts index b4710cc3c7fb8..95d1e72ac2e11 100644 --- a/packages/@aws-cdk/aws-events/lib/archive.ts +++ b/packages/@aws-cdk/aws-events/lib/archive.ts @@ -74,5 +74,6 @@ export class Archive extends Resource { this.archiveArn = archive.attrArn; this.archiveName = archive.attrArchiveName; + this.node.defaultChild = archive; } } diff --git a/packages/@aws-cdk/aws-events/package.json b/packages/@aws-cdk/aws-events/package.json index daceb1f27e8fb..d1d4acefa688b 100644 --- a/packages/@aws-cdk/aws-events/package.json +++ b/packages/@aws-cdk/aws-events/package.json @@ -85,6 +85,8 @@ "@aws-cdk/assertions": "0.0.0", "@aws-cdk/cdk-build-tools": "0.0.0", "@aws-cdk/cfn2ts": "0.0.0", + "@aws-cdk/integ-runner": "0.0.0", + "@aws-cdk/integ-tests": "0.0.0", "@aws-cdk/pkglint": "0.0.0", "@types/jest": "^27.5.2", "jest": "^27.5.1" diff --git a/packages/@aws-cdk/aws-events/test/archive.integ.snapshot/IntegStack.assets.json b/packages/@aws-cdk/aws-events/test/archive.integ.snapshot/IntegStack.assets.json new file mode 100644 index 0000000000000..b2decb971c4a3 --- /dev/null +++ b/packages/@aws-cdk/aws-events/test/archive.integ.snapshot/IntegStack.assets.json @@ -0,0 +1,19 @@ +{ + "version": "20.0.0", + "files": { + "c328ab321c3d5fd5f5a82abed4520136f53bd07785ecd2a382c66fc17090bb0d": { + "source": { + "path": "IntegStack.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "c328ab321c3d5fd5f5a82abed4520136f53bd07785ecd2a382c66fc17090bb0d.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-events/test/archive.integ.snapshot/IntegStack.template.json b/packages/@aws-cdk/aws-events/test/archive.integ.snapshot/IntegStack.template.json new file mode 100644 index 0000000000000..3597ce864ba57 --- /dev/null +++ b/packages/@aws-cdk/aws-events/test/archive.integ.snapshot/IntegStack.template.json @@ -0,0 +1,29 @@ +{ + "Resources": { + "EventBridgeF6D0CF9D": { + "Type": "AWS::Events::EventBus", + "Properties": { + "Name": "IntegStackEventBridgeF828A2C9" + } + }, + "MyCustomArchive": { + "Type": "AWS::Events::Archive", + "Properties": { + "SourceArn": { + "Fn::GetAtt": [ + "EventBridgeF6D0CF9D", + "Arn" + ] + }, + "EventPattern": { + "account": [ + { + "Ref": "AWS::AccountId" + } + ] + }, + "RetentionDays": 0 + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-events/test/archive.integ.snapshot/cdk.out b/packages/@aws-cdk/aws-events/test/archive.integ.snapshot/cdk.out new file mode 100644 index 0000000000000..588d7b269d34f --- /dev/null +++ b/packages/@aws-cdk/aws-events/test/archive.integ.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"20.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-events/test/archive.integ.snapshot/integ.json b/packages/@aws-cdk/aws-events/test/archive.integ.snapshot/integ.json new file mode 100644 index 0000000000000..61f733fb5e8db --- /dev/null +++ b/packages/@aws-cdk/aws-events/test/archive.integ.snapshot/integ.json @@ -0,0 +1,14 @@ +{ + "version": "20.0.0", + "testCases": { + "integ.archive": { + "stacks": [ + "IntegStack" + ], + "diffAssets": false, + "stackUpdateWorkflow": true + } + }, + "synthContext": {}, + "enableLookups": false +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-events/test/archive.integ.snapshot/manifest.json b/packages/@aws-cdk/aws-events/test/archive.integ.snapshot/manifest.json new file mode 100644 index 0000000000000..7d8745565413e --- /dev/null +++ b/packages/@aws-cdk/aws-events/test/archive.integ.snapshot/manifest.json @@ -0,0 +1,43 @@ +{ + "version": "20.0.0", + "artifacts": { + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + }, + "IntegStack": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "IntegStack.template.json", + "validateOnSynth": false + }, + "metadata": { + "/IntegStack/EventBridge/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "EventBridgeF6D0CF9D" + } + ], + "/IntegStack/Archive/Archive": [ + { + "type": "aws:cdk:logicalId", + "data": "MyCustomArchive" + } + ], + "Archive4DBC1EC9": [ + { + "type": "aws:cdk:logicalId", + "data": "Archive4DBC1EC9", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ] + }, + "displayName": "IntegStack" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-events/test/archive.integ.snapshot/tree.json b/packages/@aws-cdk/aws-events/test/archive.integ.snapshot/tree.json new file mode 100644 index 0000000000000..f4aa900c9ece9 --- /dev/null +++ b/packages/@aws-cdk/aws-events/test/archive.integ.snapshot/tree.json @@ -0,0 +1,92 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.58" + } + }, + "IntegStack": { + "id": "IntegStack", + "path": "IntegStack", + "children": { + "EventBridge": { + "id": "EventBridge", + "path": "IntegStack/EventBridge", + "children": { + "Resource": { + "id": "Resource", + "path": "IntegStack/EventBridge/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Events::EventBus", + "aws:cdk:cloudformation:props": { + "name": "IntegStackEventBridgeF828A2C9" + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-events.CfnEventBus", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-events.EventBus", + "version": "0.0.0" + } + }, + "Archive": { + "id": "Archive", + "path": "IntegStack/Archive", + "children": { + "Archive": { + "id": "Archive", + "path": "IntegStack/Archive/Archive", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Events::Archive", + "aws:cdk:cloudformation:props": { + "sourceArn": { + "Fn::GetAtt": [ + "EventBridgeF6D0CF9D", + "Arn" + ] + }, + "eventPattern": { + "account": [ + { + "Ref": "AWS::AccountId" + } + ] + }, + "retentionDays": 0 + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-events.CfnArchive", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-events.Archive", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-events/test/archive.test.ts b/packages/@aws-cdk/aws-events/test/archive.test.ts index 8119961738cf1..595a845af60c0 100644 --- a/packages/@aws-cdk/aws-events/test/archive.test.ts +++ b/packages/@aws-cdk/aws-events/test/archive.test.ts @@ -77,4 +77,20 @@ describe('archive', () => { }, }); }); + + test('should have defined defaultChild', () => { + const stack = new Stack(); + + const eventBus = new EventBus(stack, 'Bus'); + + const archive = new Archive(stack, 'Archive', { + sourceEventBus: eventBus, + eventPattern: { + account: [stack.account], + }, + retention: Duration.days(10), + }); + + expect(archive.node.defaultChild).toBe(archive.node.findChild('Archive')); + }); }); diff --git a/packages/@aws-cdk/aws-events/test/integ.archive.ts b/packages/@aws-cdk/aws-events/test/integ.archive.ts new file mode 100644 index 0000000000000..b9a47ba6fafe6 --- /dev/null +++ b/packages/@aws-cdk/aws-events/test/integ.archive.ts @@ -0,0 +1,23 @@ +import { App, Stack } from '@aws-cdk/core'; +import { IntegTest } from '@aws-cdk/integ-tests'; +import { Archive, CfnArchive, EventBus } from '../lib'; + +const app = new App(); + +const stack = new Stack(app, 'IntegStack'); + +const eventBus = new EventBus(stack, 'EventBridge'); + +const archive = new Archive(stack, 'Archive', { + sourceEventBus: eventBus, + eventPattern: { + account: [stack.account], + }, +}); +(archive.node.defaultChild as CfnArchive).overrideLogicalId('MyCustomArchive'); + +new IntegTest(app, 'ArchiveTest', { + testCases: [stack], +}); + +app.synth();