From 454d60fdfcf348fbc114bfdfe5c6dc8429fb0afd Mon Sep 17 00:00:00 2001 From: Peter Woodworth <44349620+peterwoodworth@users.noreply.github.com> Date: Mon, 20 Jun 2022 03:50:39 -0700 Subject: [PATCH 1/3] feat(servicediscovery): add hostedzoneid as attribute to namespace (#20583) related to #20510 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../lib/private-dns-namespace.ts | 6 ++ .../lib/public-dns-namespace.ts | 6 ++ .../test/namespace.test.ts | 70 +++++++++++++++++++ 3 files changed, 82 insertions(+) diff --git a/packages/@aws-cdk/aws-servicediscovery/lib/private-dns-namespace.ts b/packages/@aws-cdk/aws-servicediscovery/lib/private-dns-namespace.ts index c5b8332c3238c..baf40ca47176f 100644 --- a/packages/@aws-cdk/aws-servicediscovery/lib/private-dns-namespace.ts +++ b/packages/@aws-cdk/aws-servicediscovery/lib/private-dns-namespace.ts @@ -61,6 +61,11 @@ export class PrivateDnsNamespace extends Resource implements IPrivateDnsNamespac */ public readonly namespaceArn: string; + /** + * ID of hosted zone created by namespace + */ + public readonly namespaceHostedZoneId: string; + /** * Type of the namespace. */ @@ -81,6 +86,7 @@ export class PrivateDnsNamespace extends Resource implements IPrivateDnsNamespac this.namespaceName = props.name; this.namespaceId = ns.attrId; this.namespaceArn = ns.attrArn; + this.namespaceHostedZoneId = ns.attrHostedZoneId; this.type = NamespaceType.DNS_PRIVATE; } diff --git a/packages/@aws-cdk/aws-servicediscovery/lib/public-dns-namespace.ts b/packages/@aws-cdk/aws-servicediscovery/lib/public-dns-namespace.ts index 431befda4c22d..5c18dce44bacf 100644 --- a/packages/@aws-cdk/aws-servicediscovery/lib/public-dns-namespace.ts +++ b/packages/@aws-cdk/aws-servicediscovery/lib/public-dns-namespace.ts @@ -53,6 +53,11 @@ export class PublicDnsNamespace extends Resource implements IPublicDnsNamespace */ public readonly namespaceArn: string; + /** + * ID of hosted zone created by namespace + */ + public readonly namespaceHostedZoneId: string; + /** * Type of the namespace. */ @@ -69,6 +74,7 @@ export class PublicDnsNamespace extends Resource implements IPublicDnsNamespace this.namespaceName = props.name; this.namespaceId = ns.attrId; this.namespaceArn = ns.attrArn; + this.namespaceHostedZoneId = ns.attrHostedZoneId; this.type = NamespaceType.DNS_PUBLIC; } diff --git a/packages/@aws-cdk/aws-servicediscovery/test/namespace.test.ts b/packages/@aws-cdk/aws-servicediscovery/test/namespace.test.ts index 30ccf20fc85f1..eb5d9f920acef 100644 --- a/packages/@aws-cdk/aws-servicediscovery/test/namespace.test.ts +++ b/packages/@aws-cdk/aws-servicediscovery/test/namespace.test.ts @@ -1,6 +1,7 @@ import { Template } from '@aws-cdk/assertions'; import * as ec2 from '@aws-cdk/aws-ec2'; import * as cdk from '@aws-cdk/core'; +import { CfnOutput } from '@aws-cdk/core'; import * as servicediscovery from '../lib'; describe('namespace', () => { @@ -64,4 +65,73 @@ describe('namespace', () => { }); + + test('CloudFormation attributes', () => { + const stack = new cdk.Stack(); + const vpc = new ec2.Vpc(stack, 'MyVpc'); + + const privateNs = new servicediscovery.PrivateDnsNamespace(stack, 'MyPrivateNamespace', { + name: 'foobar.com', + vpc, + }); + const publicNs = new servicediscovery.PrivateDnsNamespace(stack, 'MyPublicNamespace', { + name: 'foobar.com', + vpc, + }); + new CfnOutput(stack, 'PrivateNsId', { value: privateNs.namespaceId }); + new CfnOutput(stack, 'PrivateNsArn', { value: privateNs.namespaceArn }); + new CfnOutput(stack, 'PrivateHostedZoneId', { value: privateNs.namespaceHostedZoneId }); + new CfnOutput(stack, 'PublicNsId', { value: publicNs.namespaceId }); + new CfnOutput(stack, 'PublicNsArn', { value: publicNs.namespaceArn }); + new CfnOutput(stack, 'PublicHostedZoneId', { value: publicNs.namespaceHostedZoneId }); + + Template.fromStack(stack).hasOutput('PrivateNsId', { + Value: { + 'Fn::GetAtt': [ + 'MyPrivateNamespace8CB3AE39', + 'Id', + ], + }, + }); + Template.fromStack(stack).hasOutput('PrivateNsArn', { + Value: { + 'Fn::GetAtt': [ + 'MyPrivateNamespace8CB3AE39', + 'Arn', + ], + }, + }); + Template.fromStack(stack).hasOutput('PrivateHostedZoneId', { + Value: { + 'Fn::GetAtt': [ + 'MyPrivateNamespace8CB3AE39', + 'HostedZoneId', + ], + }, + }); + Template.fromStack(stack).hasOutput('PublicNsId', { + Value: { + 'Fn::GetAtt': [ + 'MyPublicNamespaceAB66AFAC', + 'Id', + ], + }, + }); + Template.fromStack(stack).hasOutput('PublicNsArn', { + Value: { + 'Fn::GetAtt': [ + 'MyPublicNamespaceAB66AFAC', + 'Arn', + ], + }, + }); + Template.fromStack(stack).hasOutput('PublicHostedZoneId', { + Value: { + 'Fn::GetAtt': [ + 'MyPublicNamespaceAB66AFAC', + 'HostedZoneId', + ], + }, + }); + }); }); From 26ff3c7748dbdb1faa5d7adf30242b307db2db47 Mon Sep 17 00:00:00 2001 From: Cory Hall <43035978+corymhall@users.noreply.github.com> Date: Mon, 20 Jun 2022 12:01:45 -0400 Subject: [PATCH 2/3] fix(events-targets): cloudwatch logs requires specific input template (#20748) The CloudWatch logs log group target requires a very specific input template. It does not support `input` or `inputPath` and if `inputTemplate` is specified it must be in the format of `{"timestamp":