From 3bbc9a1e04b510a96629c4fd756ec9980378f785 Mon Sep 17 00:00:00 2001 From: Santanu Ghosh Date: Wed, 11 Jan 2023 13:21:27 -0800 Subject: [PATCH 1/6] Issue-23641: Fixing dynamic description bug --- .../aws-servicecatalogappregistry/lib/application.ts | 2 +- .../aws-servicecatalogappregistry/lib/target-application.ts | 2 +- .../test/integ.application.js.snapshot/cdk.out | 2 +- .../integ-servicecatalogappregistry-application.assets.json | 6 +++--- ...nteg-servicecatalogappregistry-application.template.json | 2 +- .../test/integ.application.js.snapshot/integ.json | 2 +- .../test/integ.application.js.snapshot/manifest.json | 4 ++-- .../test/integ.application.js.snapshot/tree.json | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/lib/application.ts b/packages/@aws-cdk/aws-servicecatalogappregistry/lib/application.ts index ee0465eae5d12..e596fb573bcc5 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/lib/application.ts +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/lib/application.ts @@ -277,7 +277,7 @@ export class Application extends ApplicationBase { this.applicationManagerUrl = new cdk.CfnOutput(this, 'ApplicationManagerUrl', { value: `https://${this.env.region}.console.aws.amazon.com/systems-manager/appmanager/application/AWS_AppRegistry_Application-${this.applicationName}`, - description: `Application manager url for application ${this.applicationName}`, + description: 'Application manager url for the application created.', }); } diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/lib/target-application.ts b/packages/@aws-cdk/aws-servicecatalogappregistry/lib/target-application.ts index 5da8699bdc1f7..db3cafa031758 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/lib/target-application.ts +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/lib/target-application.ts @@ -92,7 +92,7 @@ class CreateTargetApplication extends TargetApplication { public bind(scope: Construct): BindTargetApplicationResult { const stackId = this.applicationOptions.stackId ?? 'ApplicationAssociatorStack'; (this.applicationOptions.description as string) = - this.applicationOptions.description || `Stack that holds the ${this.applicationOptions.applicationName} application`; + this.applicationOptions.description || 'Stack to create AppRegistry application'; (this.applicationOptions.env as cdk.Environment) = this.applicationOptions.env || { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION }; const applicationStack = new cdk.Stack(scope, stackId, this.applicationOptions); diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/cdk.out b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/cdk.out index 145739f539580..d8b441d447f8a 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"22.0.0"} \ No newline at end of file +{"version":"29.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.assets.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.assets.json index 0f728aa69a648..f82fc168e9a8c 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.assets.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.assets.json @@ -1,7 +1,7 @@ { - "version": "22.0.0", + "version": "29.0.0", "files": { - "225f3d7f7d17bfb53aa17ae8a44119a756f2fc51682bfd5ee27b84ea25f994eb": { + "39e6b01720df76f8271850aad4b63da2d0fb73b23c547570d64e3aaf4b7d8328": { "source": { "path": "integ-servicecatalogappregistry-application.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "225f3d7f7d17bfb53aa17ae8a44119a756f2fc51682bfd5ee27b84ea25f994eb.json", + "objectKey": "39e6b01720df76f8271850aad4b63da2d0fb73b23c547570d64e3aaf4b7d8328.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.template.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.template.json index d569907291d49..a9add3e0653ef 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.template.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.template.json @@ -123,7 +123,7 @@ }, "Outputs": { "TestApplicationApplicationManagerUrlE1058321": { - "Description": "Application manager url for application myApplication", + "Description": "Application manager url for the application created.", "Value": { "Fn::Join": [ "", diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ.json index 7db84c3e5dfa8..f211b281f65e2 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "22.0.0", + "version": "29.0.0", "testCases": { "integ.application": { "stacks": [ diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/manifest.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/manifest.json index 6a0143a97aaf2..0eeaf682fab47 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "22.0.0", + "version": "29.0.0", "artifacts": { "integ-servicecatalogappregistry-application.assets": { "type": "cdk:asset-manifest", @@ -17,7 +17,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/225f3d7f7d17bfb53aa17ae8a44119a756f2fc51682bfd5ee27b84ea25f994eb.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/39e6b01720df76f8271850aad4b63da2d0fb73b23c547570d64e3aaf4b7d8328.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/tree.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/tree.json index 5e4d14f15093e..cf5e0364ec66a 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/tree.json @@ -249,7 +249,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.189" + "version": "10.1.209" } } }, From 4262fdb06f17e46ea2462c2e00682b26c655cdf5 Mon Sep 17 00:00:00 2001 From: Santanu Ghosh Date: Wed, 11 Jan 2023 13:39:13 -0800 Subject: [PATCH 2/6] Changing the integration test --- .../integ-servicecatalogappregistry-application.assets.json | 4 ++-- ...nteg-servicecatalogappregistry-application.template.json | 6 +++--- .../test/integ.application.js.snapshot/manifest.json | 2 +- .../test/integ.application.js.snapshot/tree.json | 4 ++-- .../aws-servicecatalogappregistry/test/integ.application.ts | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.assets.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.assets.json index f82fc168e9a8c..17d3b8241176a 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.assets.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.assets.json @@ -1,7 +1,7 @@ { "version": "29.0.0", "files": { - "39e6b01720df76f8271850aad4b63da2d0fb73b23c547570d64e3aaf4b7d8328": { + "8bf01e42edcc7e9cd4c65b9db9e52d2d6564f931bc84e7f564a1a4c43e499d6e": { "source": { "path": "integ-servicecatalogappregistry-application.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "39e6b01720df76f8271850aad4b63da2d0fb73b23c547570d64e3aaf4b7d8328.json", + "objectKey": "8bf01e42edcc7e9cd4c65b9db9e52d2d6564f931bc84e7f564a1a4c43e499d6e.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.template.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.template.json index a9add3e0653ef..34343c5e60207 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.template.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.template.json @@ -3,8 +3,8 @@ "TestApplication2FBC585F": { "Type": "AWS::ServiceCatalogAppRegistry::Application", "Properties": { - "Name": "myApplication", - "Description": "my application description" + "Name": "TestApplication", + "Description": "Test application description" } }, "TestApplicationResourceAssociationd232b63e52a8414E905D": { @@ -132,7 +132,7 @@ { "Ref": "AWS::Region" }, - ".console.aws.amazon.com/systems-manager/appmanager/application/AWS_AppRegistry_Application-myApplication" + ".console.aws.amazon.com/systems-manager/appmanager/application/AWS_AppRegistry_Application-TestApplication" ] ] } diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/manifest.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/manifest.json index 0eeaf682fab47..431629ee09836 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/manifest.json @@ -17,7 +17,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/39e6b01720df76f8271850aad4b63da2d0fb73b23c547570d64e3aaf4b7d8328.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/8bf01e42edcc7e9cd4c65b9db9e52d2d6564f931bc84e7f564a1a4c43e499d6e.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/tree.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/tree.json index cf5e0364ec66a..e1dc8a2ae0954 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/tree.json @@ -18,8 +18,8 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::ServiceCatalogAppRegistry::Application", "aws:cdk:cloudformation:props": { - "name": "myApplication", - "description": "my application description" + "name": "TestApplication", + "description": "Test application description" } }, "constructInfo": { diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.ts b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.ts index 06c0395e31bfa..7f952e6c05b8a 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.ts +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.ts @@ -6,8 +6,8 @@ const app = new cdk.App(); const stack = new cdk.Stack(app, 'integ-servicecatalogappregistry-application'); const application = new appreg.Application(stack, 'TestApplication', { - applicationName: 'myApplication', - description: 'my application description', + applicationName: 'TestApplication', + description: 'Test application description', }); const attributeGroup = new appreg.AttributeGroup(stack, 'TestAttributeGroup', { From ae03cb541ef51ee514eda1acd671abecad21f33d Mon Sep 17 00:00:00 2001 From: Santanu Ghosh Date: Tue, 28 Feb 2023 10:38:23 -0800 Subject: [PATCH 3/6] Associate application with attribute group --- .../aws-servicecatalogappregistry/README.md | 45 ++++++++++++++++++ .../lib/attribute-group.ts | 34 +++++++++++++- .../test/application-associator.test.ts | 47 +++++++++++++++++++ .../test/attribute-group.test.ts | 24 ++++++++++ .../integ.attribute-group.js.snapshot/cdk.out | 2 +- ...logappregistry-attribute-group.assets.json | 6 +-- ...gappregistry-attribute-group.template.json | 4 +- .../integ.json | 2 +- .../manifest.json | 4 +- .../tree.json | 6 +-- .../test/integ.attribute-group.ts | 4 +- 11 files changed, 163 insertions(+), 15 deletions(-) diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/README.md b/packages/@aws-cdk/aws-servicecatalogappregistry/README.md index be09aef037fae..a0f132edb966c 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/README.md +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/README.md @@ -99,6 +99,41 @@ const associatedApp = new appreg.ApplicationAssociator(app, 'AssociatedApplicati }); ``` +If you want to associate an Attribute Group with application created by `ApplicationAssociator`, then use as shown in the example below: + +```ts +const app = new App(); +const customAttributeGroup = new CustomAppRegistryAttributeGroup(app, 'AppRegistryAttributeGroup'); + +const associatedApp = new appreg.ApplicationAssociator(app, 'AssociatedApplication', { + applications: [appreg.TargetApplication.createApplicationStack({ + applicationName: 'MyAssociatedApplication', + // 'Application containing stacks deployed via CDK.' is the default + applicationDescription: 'Associated Application description', + stackName: 'MyAssociatedApplicationStack', + // AWS Account and Region that are implied by the current CLI configuration is the default + env: { account: '123456789012', region: 'us-east-1' }, + })], +}); + +// Associate application to the attribute group. +customAttributeGroup.attributeGroup.associateApplicationWithAttributeGroup(associatedApp.appRegistryApplication()); + +class CustomAppRegistryAttributeGroup extends cdk.Stack { + public readonly attributeGroup: appreg.AttributeGroup + constructor(scope: Construct, id: string, props?: cdk.StackProps) { + super(scope, id, props); + const myAttributeGroup = new appreg.AttributeGroup(this, 'MyFirstAttributeGroup', { + attributeGroupName: 'MyAttributeGroupName', + description: 'Test attribute group', + attributes: {}, + }); + + this.attributeGroup = myAttributeGroup; + } +} +``` + If you are using CDK Pipelines to deploy your application, the application stacks will be inside Stages, and ApplicationAssociator will not be able to find them. Call `associateStage` on each Stage object before adding it to the Pipeline, as shown in the example below: @@ -191,6 +226,16 @@ declare const attributeGroup: appreg.AttributeGroup; application.associateAttributeGroup(attributeGroup); ``` +### Associating an attribute group with application + +You can associate an application with an attribute group with `associateApplicationWithAttributeGroup`: + +```ts +declare const application: appreg.Application; +declare const attributeGroup: appreg.AttributeGroup; +attributeGroup.associateApplicationWithAttributeGroup(application); +``` + ### Associating application with a Stack You can associate a stack with an application with the `associateStack()` API: diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/lib/attribute-group.ts b/packages/@aws-cdk/aws-servicecatalogappregistry/lib/attribute-group.ts index d6dda21fe797d..7e26dc8ce8740 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/lib/attribute-group.ts +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/lib/attribute-group.ts @@ -2,9 +2,10 @@ import { CfnResourceShare } from '@aws-cdk/aws-ram'; import * as cdk from '@aws-cdk/core'; import { Names } from '@aws-cdk/core'; import { Construct } from 'constructs'; +import { IApplication } from './application'; import { getPrincipalsforSharing, hashValues, ShareOptions, SharePermission } from './common'; import { InputValidator } from './private/validation'; -import { CfnAttributeGroup } from './servicecatalogappregistry.generated'; +import { CfnAttributeGroup, CfnAttributeGroupAssociation } from './servicecatalogappregistry.generated'; const ATTRIBUTE_GROUP_READ_ONLY_RAM_PERMISSION_ARN = 'arn:aws:ram::aws:permission/AWSRAMPermissionServiceCatalogAppRegistryAttributeGroupReadOnly'; const ATTRIBUTE_GROUP_ALLOW_ACCESS_RAM_PERMISSION_ARN = 'arn:aws:ram::aws:permission/AWSRAMPermissionServiceCatalogAppRegistryAttributeGroupAllowAssociation'; @@ -58,6 +59,22 @@ export interface AttributeGroupProps { abstract class AttributeGroupBase extends cdk.Resource implements IAttributeGroup { public abstract readonly attributeGroupArn: string; public abstract readonly attributeGroupId: string; + private readonly associatedApplications: Set = new Set(); + + /** + * Associate an application with attribute group + * If the attribute group is already associated, it will ignore duplicate request. + */ + public associateApplicationWithAttributeGroup(application: IApplication): void { + if (!this.associatedApplications.has(application.node.addr)) { + const hashId = this.generateUniqueHash(application.node.addr); + new CfnAttributeGroupAssociation(this, `ApplicationAttributeGroupAssociation${hashId}`, { + application: application.applicationId, + attributeGroup: this.attributeGroupId, + }); + this.associatedApplications.add(application.node.addr); + } + } public shareAttributeGroup(shareOptions: ShareOptions): void { const principals = getPrincipalsforSharing(shareOptions); @@ -85,6 +102,11 @@ abstract class AttributeGroupBase extends cdk.Resource implements IAttributeGrou return shareOptions.sharePermission ?? ATTRIBUTE_GROUP_READ_ONLY_RAM_PERMISSION_ARN; } } + + /** + * Create a unique hash + */ + protected abstract generateUniqueHash(resourceAddress: string): string; } /** @@ -109,6 +131,10 @@ export class AttributeGroup extends AttributeGroupBase implements IAttributeGrou class Import extends AttributeGroupBase { public readonly attributeGroupArn = attributeGroupArn; public readonly attributeGroupId = attributeGroupId!; + + protected generateUniqueHash(resourceAddress: string): string { + return hashValues(this.attributeGroupArn, resourceAddress); + } } return new Import(scope, id, { @@ -118,6 +144,7 @@ export class AttributeGroup extends AttributeGroupBase implements IAttributeGrou public readonly attributeGroupArn: string; public readonly attributeGroupId: string; + private readonly nodeAddress: string; constructor(scope: Construct, id: string, props: AttributeGroupProps) { super(scope, id); @@ -132,6 +159,11 @@ export class AttributeGroup extends AttributeGroupBase implements IAttributeGrou this.attributeGroupArn = attributeGroup.attrArn; this.attributeGroupId = attributeGroup.attrId; + this.nodeAddress = cdk.Names.nodeUniqueId(attributeGroup.node); + } + + protected generateUniqueHash(resourceAddress: string): string { + return hashValues(this.nodeAddress, resourceAddress); } private validateAttributeGroupProps(props: AttributeGroupProps) { diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/application-associator.test.ts b/packages/@aws-cdk/aws-servicecatalogappregistry/test/application-associator.test.ts index be0221ab49340..0d44e995e4b59 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/application-associator.test.ts +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/application-associator.test.ts @@ -35,6 +35,38 @@ describe('Scope based Associations with Application within Same Account', () => }); }); }); + +describe('Associate attribute group with Application', () => { + let app: cdk.App; + beforeEach(() => { + app = new cdk.App({ + context: { + '@aws-cdk/core:newStyleStackSynthesis': false, + }, + }); + }); + + test('Associate Attribute Group with application created by ApplicationAssociator', () => { + + const customAttributeGroup = new CustomAppRegistryAttributeGroup(app, 'AppRegistryAttributeGroup'); + + const appAssociator = new appreg.ApplicationAssociator(app, 'TestApplication', { + applications: [appreg.TargetApplication.createApplicationStack({ + applicationName: 'TestAssociatedApplication', + stackName: 'TestAssociatedApplicationStack', + })], + }); + + customAttributeGroup.attributeGroup.associateApplicationWithAttributeGroup(appAssociator.appRegistryApplication()); + Template.fromStack(customAttributeGroup.attributeGroup.stack).resourceCountIs('AWS::ServiceCatalogAppRegistry::AttributeGroupAssociation', 1); + Template.fromStack(customAttributeGroup.attributeGroup.stack).hasResourceProperties('AWS::ServiceCatalogAppRegistry::AttributeGroupAssociation', { + Application: { 'Fn::ImportValue': 'TestAssociatedApplicationStack:ExportsOutputFnGetAttDefaultCdkApplication4573D5A3IdAEBA32E0' }, + AttributeGroup: { 'Fn::GetAtt': ['MyFirstAttributeGroupDBC21379', 'Id'] }, + }); + + }); +}); + describe('Scope based Associations with Application with Cross Region/Account', () => { let app: cdk.App; beforeEach(() => { @@ -211,3 +243,18 @@ class AppRegistrySampleStack extends cdk.Stack { super(scope, id, props); } } + +class CustomAppRegistryAttributeGroup extends cdk.Stack { + public readonly attributeGroup: appreg.AttributeGroup; + + constructor(scope: Construct, id: string, props?: cdk.StackProps) { + super(scope, id, props); + const myAttributeGroup = new appreg.AttributeGroup(this, 'MyFirstAttributeGroup', { + attributeGroupName: 'MyFirstAttributeGroupName', + description: 'Test attribute group', + attributes: {}, + }); + + this.attributeGroup = myAttributeGroup; + } +} diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/attribute-group.test.ts b/packages/@aws-cdk/aws-servicecatalogappregistry/test/attribute-group.test.ts index 5230071cd50f1..361714f1cc7ab 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/attribute-group.test.ts +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/attribute-group.test.ts @@ -176,6 +176,30 @@ describe('Attribute Group', () => { }); }); + describe('Associate application to an attribute group', () => { + let attributeGroup: appreg.AttributeGroup; + + beforeEach(() => { + attributeGroup = new appreg.AttributeGroup(stack, 'MyAttributeGroupForAssociation', { + attributeGroupName: 'MyAttributeGroupForAssociation', + attributes: {}, + }); + }); + + test('Associate an application to an attribute group', () => { + const application = new appreg.Application(stack, 'MyApplication', { + applicationName: 'MyTestApplication', + }); + attributeGroup.associateApplicationWithAttributeGroup(application); + Template.fromStack(stack).hasResourceProperties('AWS::ServiceCatalogAppRegistry::AttributeGroupAssociation', { + Application: { 'Fn::GetAtt': ['MyApplication5C63EC1D', 'Id'] }, + AttributeGroup: { 'Fn::GetAtt': ['MyAttributeGroupForAssociation6B3E1329', 'Id'] }, + }); + + }); + + }); + describe('Resource sharing of an attribute group', () => { let attributeGroup: appreg.AttributeGroup; diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/cdk.out b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/cdk.out index 145739f539580..b72fef144f05c 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"22.0.0"} \ No newline at end of file +{"version":"30.1.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/integ-servicecatalogappregistry-attribute-group.assets.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/integ-servicecatalogappregistry-attribute-group.assets.json index 1aebd71d38d63..fe0371124386a 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/integ-servicecatalogappregistry-attribute-group.assets.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/integ-servicecatalogappregistry-attribute-group.assets.json @@ -1,7 +1,7 @@ { - "version": "22.0.0", + "version": "30.1.0", "files": { - "3dece22dad73361a79cb380f2880362a20ffc5c0cc75ddc6707e26b5a88cf93f": { + "eceea7410a36f9390f3bde280de21a8cf782a5552f62b847978c3106e40e8f7c": { "source": { "path": "integ-servicecatalogappregistry-attribute-group.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "3dece22dad73361a79cb380f2880362a20ffc5c0cc75ddc6707e26b5a88cf93f.json", + "objectKey": "eceea7410a36f9390f3bde280de21a8cf782a5552f62b847978c3106e40e8f7c.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/integ-servicecatalogappregistry-attribute-group.template.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/integ-servicecatalogappregistry-attribute-group.template.json index 08a8494f334c7..93489a8e1fbf1 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/integ-servicecatalogappregistry-attribute-group.template.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/integ-servicecatalogappregistry-attribute-group.template.json @@ -15,8 +15,8 @@ "beta": "time2" } }, - "Name": "myAttributeGroupTest", - "Description": "my attribute group description" + "Name": "myAttributeGroup", + "Description": "test attribute group description" } }, "TestAttributeGroupRAMSharec67f7d80e5baA10EFB4E": { diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/integ.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/integ.json index a50a65615f05b..1c5f8dae6c42d 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "22.0.0", + "version": "30.1.0", "testCases": { "integ.attribute-group": { "stacks": [ diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/manifest.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/manifest.json index edce9703115a8..939bd65890f26 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "22.0.0", + "version": "30.1.0", "artifacts": { "integ-servicecatalogappregistry-attribute-group.assets": { "type": "cdk:asset-manifest", @@ -17,7 +17,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/3dece22dad73361a79cb380f2880362a20ffc5c0cc75ddc6707e26b5a88cf93f.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/eceea7410a36f9390f3bde280de21a8cf782a5552f62b847978c3106e40e8f7c.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/tree.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/tree.json index 83ac3d2034037..b5fa95f82e73b 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/tree.json @@ -30,8 +30,8 @@ "beta": "time2" } }, - "name": "myAttributeGroupTest", - "description": "my attribute group description" + "name": "myAttributeGroup", + "description": "test attribute group description" } }, "constructInfo": { @@ -228,7 +228,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.189" + "version": "10.1.252" } } }, diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.ts b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.ts index 6d5ccb59b8ef2..e671633591496 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.ts +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.ts @@ -6,8 +6,8 @@ const app = new cdk.App(); const stack = new cdk.Stack(app, 'integ-servicecatalogappregistry-attribute-group'); const attributeGroup = new appreg.AttributeGroup(stack, 'TestAttributeGroup', { - attributeGroupName: 'myAttributeGroupTest', - description: 'my attribute group description', + attributeGroupName: 'myAttributeGroup', + description: 'test attribute group description', attributes: { stage: 'alpha', teamMembers: [ From c3dd40a84231833355e6b11c50e2f19279e02075 Mon Sep 17 00:00:00 2001 From: Santanu Ghosh Date: Tue, 28 Feb 2023 15:36:08 -0800 Subject: [PATCH 4/6] Associate application to AG --- .../aws-servicecatalogappregistry/README.md | 30 +++++++++++-------- .../lib/application.ts | 2 ++ .../lib/attribute-group.ts | 3 +- .../test/application-associator.test.ts | 2 +- .../integ.application.js.snapshot/cdk.out | 2 +- ...catalogappregistry-application.assets.json | 6 ++-- ...talogappregistry-application.template.json | 2 +- .../integ.application.js.snapshot/integ.json | 2 +- .../manifest.json | 4 +-- .../integ.application.js.snapshot/tree.json | 4 +-- .../test/integ.application.ts | 2 +- 11 files changed, 33 insertions(+), 26 deletions(-) diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/README.md b/packages/@aws-cdk/aws-servicecatalogappregistry/README.md index a0f132edb966c..9395f2b477cfe 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/README.md +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/README.md @@ -102,7 +102,24 @@ const associatedApp = new appreg.ApplicationAssociator(app, 'AssociatedApplicati If you want to associate an Attribute Group with application created by `ApplicationAssociator`, then use as shown in the example below: ```ts +import * as cdk from "@aws-cdk/core"; + const app = new App(); + +class CustomAppRegistryAttributeGroup extends cdk.Stack { + public readonly attributeGroup: appreg.AttributeGroup + constructor(scope: Construct, id: string, props?: cdk.StackProps) { + super(scope, id, props); + const myAttributeGroup = new appreg.AttributeGroup(app, 'MyFirstAttributeGroup', { + attributeGroupName: 'MyAttributeGroupName', + description: 'Test attribute group', + attributes: {}, + }); + + this.attributeGroup = myAttributeGroup; + } +} + const customAttributeGroup = new CustomAppRegistryAttributeGroup(app, 'AppRegistryAttributeGroup'); const associatedApp = new appreg.ApplicationAssociator(app, 'AssociatedApplication', { @@ -119,19 +136,6 @@ const associatedApp = new appreg.ApplicationAssociator(app, 'AssociatedApplicati // Associate application to the attribute group. customAttributeGroup.attributeGroup.associateApplicationWithAttributeGroup(associatedApp.appRegistryApplication()); -class CustomAppRegistryAttributeGroup extends cdk.Stack { - public readonly attributeGroup: appreg.AttributeGroup - constructor(scope: Construct, id: string, props?: cdk.StackProps) { - super(scope, id, props); - const myAttributeGroup = new appreg.AttributeGroup(this, 'MyFirstAttributeGroup', { - attributeGroupName: 'MyAttributeGroupName', - description: 'Test attribute group', - attributes: {}, - }); - - this.attributeGroup = myAttributeGroup; - } -} ``` If you are using CDK Pipelines to deploy your application, the application stacks will be inside Stages, and diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/lib/application.ts b/packages/@aws-cdk/aws-servicecatalogappregistry/lib/application.ts index e596fb573bcc5..dc39c12037ec4 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/lib/application.ts +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/lib/application.ts @@ -100,6 +100,8 @@ abstract class ApplicationBase extends cdk.Resource implements IApplication { /** * Associate an attribute group with application * If the attribute group is already associated, it will ignore duplicate request. + * + * @deprecated Use `AttributeGroup.associateApplicationWithAttributeGroup` instead. */ public associateAttributeGroup(attributeGroup: IAttributeGroup): void { if (!this.associatedAttributeGroups.has(attributeGroup.node.addr)) { diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/lib/attribute-group.ts b/packages/@aws-cdk/aws-servicecatalogappregistry/lib/attribute-group.ts index 7e26dc8ce8740..5dcdb32dbcb3b 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/lib/attribute-group.ts +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/lib/attribute-group.ts @@ -69,9 +69,10 @@ abstract class AttributeGroupBase extends cdk.Resource implements IAttributeGrou if (!this.associatedApplications.has(application.node.addr)) { const hashId = this.generateUniqueHash(application.node.addr); new CfnAttributeGroupAssociation(this, `ApplicationAttributeGroupAssociation${hashId}`, { - application: application.applicationId, + application: application.stack === cdk.Stack.of(this) ? application.applicationId : application.applicationName ?? application.applicationId, attributeGroup: this.attributeGroupId, }); + this.associatedApplications.add(application.node.addr); } } diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/application-associator.test.ts b/packages/@aws-cdk/aws-servicecatalogappregistry/test/application-associator.test.ts index 0d44e995e4b59..c155d7b7114a8 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/application-associator.test.ts +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/application-associator.test.ts @@ -60,7 +60,7 @@ describe('Associate attribute group with Application', () => { customAttributeGroup.attributeGroup.associateApplicationWithAttributeGroup(appAssociator.appRegistryApplication()); Template.fromStack(customAttributeGroup.attributeGroup.stack).resourceCountIs('AWS::ServiceCatalogAppRegistry::AttributeGroupAssociation', 1); Template.fromStack(customAttributeGroup.attributeGroup.stack).hasResourceProperties('AWS::ServiceCatalogAppRegistry::AttributeGroupAssociation', { - Application: { 'Fn::ImportValue': 'TestAssociatedApplicationStack:ExportsOutputFnGetAttDefaultCdkApplication4573D5A3IdAEBA32E0' }, + Application: 'TestAssociatedApplication', AttributeGroup: { 'Fn::GetAtt': ['MyFirstAttributeGroupDBC21379', 'Id'] }, }); diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/cdk.out b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/cdk.out index d8b441d447f8a..b72fef144f05c 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"29.0.0"} \ No newline at end of file +{"version":"30.1.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.assets.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.assets.json index 17d3b8241176a..d8c62f0055d75 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.assets.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.assets.json @@ -1,7 +1,7 @@ { - "version": "29.0.0", + "version": "30.1.0", "files": { - "8bf01e42edcc7e9cd4c65b9db9e52d2d6564f931bc84e7f564a1a4c43e499d6e": { + "0d4e060fe5da6b164b9df46b0dc0cd20e7962c6cb531ffe08e6e5b99418f13de": { "source": { "path": "integ-servicecatalogappregistry-application.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "8bf01e42edcc7e9cd4c65b9db9e52d2d6564f931bc84e7f564a1a4c43e499d6e.json", + "objectKey": "0d4e060fe5da6b164b9df46b0dc0cd20e7962c6cb531ffe08e6e5b99418f13de.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.template.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.template.json index 34343c5e60207..f6ac10354ea89 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.template.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.template.json @@ -4,7 +4,7 @@ "Type": "AWS::ServiceCatalogAppRegistry::Application", "Properties": { "Name": "TestApplication", - "Description": "Test application description" + "Description": "My application description" } }, "TestApplicationResourceAssociationd232b63e52a8414E905D": { diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ.json index f211b281f65e2..519ddfd3c055c 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "29.0.0", + "version": "30.1.0", "testCases": { "integ.application": { "stacks": [ diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/manifest.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/manifest.json index 431629ee09836..982ee193a4f57 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "29.0.0", + "version": "30.1.0", "artifacts": { "integ-servicecatalogappregistry-application.assets": { "type": "cdk:asset-manifest", @@ -17,7 +17,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/8bf01e42edcc7e9cd4c65b9db9e52d2d6564f931bc84e7f564a1a4c43e499d6e.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/0d4e060fe5da6b164b9df46b0dc0cd20e7962c6cb531ffe08e6e5b99418f13de.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/tree.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/tree.json index e1dc8a2ae0954..8ed129f0c0e65 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/tree.json @@ -19,7 +19,7 @@ "aws:cdk:cloudformation:type": "AWS::ServiceCatalogAppRegistry::Application", "aws:cdk:cloudformation:props": { "name": "TestApplication", - "description": "Test application description" + "description": "My application description" } }, "constructInfo": { @@ -249,7 +249,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.209" + "version": "10.1.252" } } }, diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.ts b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.ts index 7f952e6c05b8a..9635a126e2b05 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.ts +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.ts @@ -7,7 +7,7 @@ const stack = new cdk.Stack(app, 'integ-servicecatalogappregistry-application'); const application = new appreg.Application(stack, 'TestApplication', { applicationName: 'TestApplication', - description: 'Test application description', + description: 'My application description', }); const attributeGroup = new appreg.AttributeGroup(stack, 'TestAttributeGroup', { From fe247c8bcbd147e2acce22a05692eec309f5b225 Mon Sep 17 00:00:00 2001 From: Santanu Ghosh Date: Wed, 1 Mar 2023 09:53:57 -0800 Subject: [PATCH 5/6] Associate application to attribute group --- packages/@aws-cdk/aws-servicecatalogappregistry/README.md | 6 +++--- .../aws-servicecatalogappregistry/lib/application.ts | 2 +- .../aws-servicecatalogappregistry/lib/attribute-group.ts | 2 +- .../test/application-associator.test.ts | 2 +- .../test/attribute-group.test.ts | 2 +- ...eg-servicecatalogappregistry-attribute-group.assets.json | 4 ++-- ...-servicecatalogappregistry-attribute-group.template.json | 2 +- .../test/integ.attribute-group.js.snapshot/manifest.json | 2 +- .../test/integ.attribute-group.js.snapshot/tree.json | 2 +- .../test/integ.attribute-group.ts | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/README.md b/packages/@aws-cdk/aws-servicecatalogappregistry/README.md index 9395f2b477cfe..6c2ce7bf8d1d2 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/README.md +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/README.md @@ -134,7 +134,7 @@ const associatedApp = new appreg.ApplicationAssociator(app, 'AssociatedApplicati }); // Associate application to the attribute group. -customAttributeGroup.attributeGroup.associateApplicationWithAttributeGroup(associatedApp.appRegistryApplication()); +customAttributeGroup.attributeGroup.associateWith(associatedApp.appRegistryApplication()); ``` @@ -232,12 +232,12 @@ application.associateAttributeGroup(attributeGroup); ### Associating an attribute group with application -You can associate an application with an attribute group with `associateApplicationWithAttributeGroup`: +You can associate an application with an attribute group with `associateWith`: ```ts declare const application: appreg.Application; declare const attributeGroup: appreg.AttributeGroup; -attributeGroup.associateApplicationWithAttributeGroup(application); +attributeGroup.associateWith(application); ``` ### Associating application with a Stack diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/lib/application.ts b/packages/@aws-cdk/aws-servicecatalogappregistry/lib/application.ts index dc39c12037ec4..81f5584e6719f 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/lib/application.ts +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/lib/application.ts @@ -101,7 +101,7 @@ abstract class ApplicationBase extends cdk.Resource implements IApplication { * Associate an attribute group with application * If the attribute group is already associated, it will ignore duplicate request. * - * @deprecated Use `AttributeGroup.associateApplicationWithAttributeGroup` instead. + * @deprecated Use `AttributeGroup.associateWith` instead. */ public associateAttributeGroup(attributeGroup: IAttributeGroup): void { if (!this.associatedAttributeGroups.has(attributeGroup.node.addr)) { diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/lib/attribute-group.ts b/packages/@aws-cdk/aws-servicecatalogappregistry/lib/attribute-group.ts index 5dcdb32dbcb3b..b7dbfc49d5efa 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/lib/attribute-group.ts +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/lib/attribute-group.ts @@ -65,7 +65,7 @@ abstract class AttributeGroupBase extends cdk.Resource implements IAttributeGrou * Associate an application with attribute group * If the attribute group is already associated, it will ignore duplicate request. */ - public associateApplicationWithAttributeGroup(application: IApplication): void { + public associateWith(application: IApplication): void { if (!this.associatedApplications.has(application.node.addr)) { const hashId = this.generateUniqueHash(application.node.addr); new CfnAttributeGroupAssociation(this, `ApplicationAttributeGroupAssociation${hashId}`, { diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/application-associator.test.ts b/packages/@aws-cdk/aws-servicecatalogappregistry/test/application-associator.test.ts index c155d7b7114a8..da882d28d06ce 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/application-associator.test.ts +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/application-associator.test.ts @@ -57,7 +57,7 @@ describe('Associate attribute group with Application', () => { })], }); - customAttributeGroup.attributeGroup.associateApplicationWithAttributeGroup(appAssociator.appRegistryApplication()); + customAttributeGroup.attributeGroup.associateWith(appAssociator.appRegistryApplication()); Template.fromStack(customAttributeGroup.attributeGroup.stack).resourceCountIs('AWS::ServiceCatalogAppRegistry::AttributeGroupAssociation', 1); Template.fromStack(customAttributeGroup.attributeGroup.stack).hasResourceProperties('AWS::ServiceCatalogAppRegistry::AttributeGroupAssociation', { Application: 'TestAssociatedApplication', diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/attribute-group.test.ts b/packages/@aws-cdk/aws-servicecatalogappregistry/test/attribute-group.test.ts index 361714f1cc7ab..8d7a984cf48a9 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/attribute-group.test.ts +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/attribute-group.test.ts @@ -190,7 +190,7 @@ describe('Attribute Group', () => { const application = new appreg.Application(stack, 'MyApplication', { applicationName: 'MyTestApplication', }); - attributeGroup.associateApplicationWithAttributeGroup(application); + attributeGroup.associateWith(application); Template.fromStack(stack).hasResourceProperties('AWS::ServiceCatalogAppRegistry::AttributeGroupAssociation', { Application: { 'Fn::GetAtt': ['MyApplication5C63EC1D', 'Id'] }, AttributeGroup: { 'Fn::GetAtt': ['MyAttributeGroupForAssociation6B3E1329', 'Id'] }, diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/integ-servicecatalogappregistry-attribute-group.assets.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/integ-servicecatalogappregistry-attribute-group.assets.json index fe0371124386a..7f5d7d67860d6 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/integ-servicecatalogappregistry-attribute-group.assets.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/integ-servicecatalogappregistry-attribute-group.assets.json @@ -1,7 +1,7 @@ { "version": "30.1.0", "files": { - "eceea7410a36f9390f3bde280de21a8cf782a5552f62b847978c3106e40e8f7c": { + "9d37fdefa4311937f8f73f9556f1d9a03a2874545a0a262fd42bfde3823ab551": { "source": { "path": "integ-servicecatalogappregistry-attribute-group.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "eceea7410a36f9390f3bde280de21a8cf782a5552f62b847978c3106e40e8f7c.json", + "objectKey": "9d37fdefa4311937f8f73f9556f1d9a03a2874545a0a262fd42bfde3823ab551.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/integ-servicecatalogappregistry-attribute-group.template.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/integ-servicecatalogappregistry-attribute-group.template.json index 93489a8e1fbf1..58e8215d70828 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/integ-servicecatalogappregistry-attribute-group.template.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/integ-servicecatalogappregistry-attribute-group.template.json @@ -15,7 +15,7 @@ "beta": "time2" } }, - "Name": "myAttributeGroup", + "Name": "myFirstAttributeGroup", "Description": "test attribute group description" } }, diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/manifest.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/manifest.json index 939bd65890f26..a894caeb670cf 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/manifest.json @@ -17,7 +17,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/eceea7410a36f9390f3bde280de21a8cf782a5552f62b847978c3106e40e8f7c.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/9d37fdefa4311937f8f73f9556f1d9a03a2874545a0a262fd42bfde3823ab551.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/tree.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/tree.json index b5fa95f82e73b..3f1adfd676bd6 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.js.snapshot/tree.json @@ -30,7 +30,7 @@ "beta": "time2" } }, - "name": "myAttributeGroup", + "name": "myFirstAttributeGroup", "description": "test attribute group description" } }, diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.ts b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.ts index e671633591496..10835b204bdfe 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.ts +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.attribute-group.ts @@ -6,7 +6,7 @@ const app = new cdk.App(); const stack = new cdk.Stack(app, 'integ-servicecatalogappregistry-attribute-group'); const attributeGroup = new appreg.AttributeGroup(stack, 'TestAttributeGroup', { - attributeGroupName: 'myAttributeGroup', + attributeGroupName: 'myFirstAttributeGroup', description: 'test attribute group description', attributes: { stage: 'alpha', From 7a2804c821d3ed6c0a5692482a911c0681a4b3c9 Mon Sep 17 00:00:00 2001 From: Santanu Ghosh Date: Fri, 3 Mar 2023 10:20:14 -0800 Subject: [PATCH 6/6] Fixing the test --- .../integ-servicecatalogappregistry-application.template.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.template.json b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.template.json index 76f29ee52c0d5..f6ac10354ea89 100644 --- a/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.template.json +++ b/packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.template.json @@ -132,7 +132,7 @@ { "Ref": "AWS::Region" }, - ".console.aws.amazon.com/systems-manager/appmanager/application/AWS_AppRegistry_Application-MyTestApplication" + ".console.aws.amazon.com/systems-manager/appmanager/application/AWS_AppRegistry_Application-TestApplication" ] ] }