Skip to content

Commit 9222f21

Browse files
fix(servicecatalogappregistry): Remove deprecated resource in Application Construct (#25095)
BREAKING CHANGE: this change will deprecated **associateStack** and **associateAttributeGroup** in Application Construct. The user who are using these two method need to update to use alternative method. For associateStack, the alternative method is **associateApplicationWithStack** For associateAttributeGroup, the alternative method is **AttributeGroup.associateWith** The user who are using these two method need to update to use alternative method. For associateStack, the alternative method is **associateApplicationWithStack** For associateAttributeGroup, the alternative method is **AttributeGroup.associateWith** Purpose of this PR: we need to remove deprecated resource before we moving into stable version The method that we remove is: associateStack and associateAttributeGroup CHANGES: 1. in lib/application.ts, we remove these two methods and update their corresponding interface 2. in test/ application.test.ts & test/integ.application.ts, we update application.test.ts and integ.application.ts to remove these two methods' related test *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent d3da4c0 commit 9222f21

File tree

7 files changed

+43
-338
lines changed

7 files changed

+43
-338
lines changed

packages/@aws-cdk/aws-servicecatalogappregistry-alpha/lib/application.ts

-52
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,13 @@ export interface IApplication extends cdk.IResource {
5656
*/
5757
readonly applicationName?: string;
5858

59-
/**
60-
* Associate this application with an attribute group.
61-
*
62-
* @param attributeGroup AppRegistry attribute group
63-
*/
64-
associateAttributeGroup(attributeGroup: IAttributeGroup): void;
65-
6659
/**
6760
* Create an attribute group and associate this application with the created attribute group.
6861
*
6962
* @param id name of the AttributeGroup construct to be created.
7063
* @param attributeGroupProps AppRegistry attribute group props
7164
*/
7265
addAttributeGroup(id: string, attributeGroupProps: AttributeGroupAssociationProps): IAttributeGroup;
73-
74-
/**
75-
* Associate this application with a CloudFormation stack.
76-
*
77-
* @deprecated Use `associateApplicationWithStack` instead.
78-
* @param stack a CFN stack
79-
*/
80-
associateStack(stack: cdk.Stack): void;
81-
8266
/**
8367
* Associate a Cloudformation statck with the application in the given stack.
8468
*
@@ -128,23 +112,6 @@ abstract class ApplicationBase extends cdk.Resource implements IApplication {
128112
private readonly associatedAttributeGroups: Set<string> = new Set();
129113
private readonly associatedResources: Set<string> = new Set();
130114

131-
/**
132-
* Associate an attribute group with application
133-
* If the attribute group is already associated, it will ignore duplicate request.
134-
*
135-
* @deprecated Use `AttributeGroup.associateWith` instead.
136-
*/
137-
public associateAttributeGroup(attributeGroup: IAttributeGroup): void {
138-
if (!this.associatedAttributeGroups.has(attributeGroup.node.addr)) {
139-
const hashId = this.generateUniqueHash(attributeGroup.node.addr);
140-
new CfnAttributeGroupAssociation(this, `AttributeGroupAssociation${hashId}`, {
141-
application: this.applicationId,
142-
attributeGroup: attributeGroup.attributeGroupId,
143-
});
144-
this.associatedAttributeGroups.add(attributeGroup.node.addr);
145-
}
146-
}
147-
148115
/**
149116
* Create an attribute group and associate this application with the created attribute group.
150117
*/
@@ -162,25 +129,6 @@ abstract class ApplicationBase extends cdk.Resource implements IApplication {
162129
return attributeGroup;
163130
}
164131

165-
/**
166-
* Associate a stack with the application
167-
* If the resource is already associated, it will ignore duplicate request.
168-
* A stack can only be associated with one application.
169-
*
170-
* @deprecated Use `associateApplicationWithStack` instead.
171-
*/
172-
public associateStack(stack: cdk.Stack): void {
173-
if (!this.associatedResources.has(stack.node.addr)) {
174-
const hashId = this.generateUniqueHash(stack.node.addr);
175-
new CfnResourceAssociation(this, `ResourceAssociation${hashId}`, {
176-
application: this.applicationId,
177-
resource: stack.stackId,
178-
resourceType: 'CFN_STACK',
179-
});
180-
this.associatedResources.add(stack.node.addr);
181-
}
182-
}
183-
184132
/**
185133
* Associate stack with the application in the stack passed as parameter.
186134
*

packages/@aws-cdk/aws-servicecatalogappregistry-alpha/test/application.test.ts

-86
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,6 @@ describe('Application', () => {
146146
});
147147
});
148148

149-
test('associate attribute group', () => {
150-
const attributeGroup = new appreg.AttributeGroup(stack, 'AttributeGroup', {
151-
attributeGroupName: 'AttributeGroupName',
152-
attributes: {},
153-
});
154-
155-
application.associateAttributeGroup(attributeGroup);
156-
157-
Template.fromStack(stack).hasResourceProperties('AWS::ServiceCatalogAppRegistry::AttributeGroupAssociation', {
158-
Application: { 'Fn::GetAtt': ['MyApplication5C63EC1D', 'Id'] },
159-
AttributeGroup: { 'Fn::GetAtt': ['AttributeGroup409C6335', 'Id'] },
160-
});
161-
}),
162-
163149
test('associate new attribute group', () => {
164150
application.addAttributeGroup('AttributeGroup', {
165151
attributeGroupName: 'AttributeGroupName',
@@ -183,78 +169,6 @@ describe('Application', () => {
183169
},
184170
},
185171
});
186-
}),
187-
188-
test('duplicate attribute group association are idempotent', () => {
189-
const attributeGroup = new appreg.AttributeGroup(stack, 'AttributeGroup', {
190-
attributeGroupName: 'attributeGroupName',
191-
attributes: { key: 'value' },
192-
});
193-
194-
// If these were not idempotent, the second call would produce an error for duplicate construct ID.
195-
application.associateAttributeGroup(attributeGroup);
196-
application.associateAttributeGroup(attributeGroup);
197-
198-
Template.fromStack(stack).resourceCountIs('AWS::ServiceCatalogAppRegistry::AttributeGroupAssociation', 1);
199-
}),
200-
201-
test('multiple applications and attribute groups can associate', () => {
202-
const application2 = new appreg.Application(stack, 'MyApplication2', {
203-
applicationName: 'MyApplication2',
204-
});
205-
206-
const attributeGroup1 = new appreg.AttributeGroup(stack, 'AttributeGroup', {
207-
attributeGroupName: 'attributeGroupName',
208-
attributes: { key: 'value' },
209-
});
210-
211-
const attributeGroup2 = new appreg.AttributeGroup(stack, 'AttributeGroup2', {
212-
attributeGroupName: 'attributeGroupName2',
213-
attributes: { key: 'value' },
214-
});
215-
216-
application.associateAttributeGroup(attributeGroup1);
217-
application.associateAttributeGroup(attributeGroup2);
218-
219-
application2.associateAttributeGroup(attributeGroup1);
220-
application2.associateAttributeGroup(attributeGroup2);
221-
222-
Template.fromStack(stack).resourceCountIs('AWS::ServiceCatalogAppRegistry::AttributeGroupAssociation', 4);
223-
}),
224-
225-
test('associate resource', () => {
226-
const resource = new cdk.Stack(stack, 'MyStack');
227-
228-
application.associateStack(resource);
229-
230-
Template.fromStack(stack).hasResourceProperties('AWS::ServiceCatalogAppRegistry::ResourceAssociation', {
231-
Application: { 'Fn::GetAtt': ['MyApplication5C63EC1D', 'Id'] },
232-
Resource: { 'Fn::ImportValue': 'MyStack:ExportsOutputRefAWSStackIdB2DD5BAA' },
233-
});
234-
}),
235-
236-
test('associate resource on imported application', () => {
237-
const resource = new cdk.Stack(stack, 'MyStack');
238-
239-
const importedApplication = appreg.Application.fromApplicationArn(stack, 'ImportedApplication',
240-
'arn:aws:servicecatalog:us-east-1:123456789012:/applications/0bqmvxvgmry0ecc4mjhwypun6i');
241-
242-
importedApplication.associateStack(resource);
243-
244-
Template.fromStack(stack).hasResourceProperties('AWS::ServiceCatalogAppRegistry::ResourceAssociation', {
245-
Application: '0bqmvxvgmry0ecc4mjhwypun6i',
246-
Resource: { 'Fn::ImportValue': 'MyStack:ExportsOutputRefAWSStackIdB2DD5BAA' },
247-
});
248-
}),
249-
250-
test('duplicate resource assocations are idempotent', () => {
251-
const resource = new cdk.Stack(stack, 'MyStack');
252-
253-
// If these were not idempotent, the second call would produce an error for duplicate construct ID.
254-
application.associateStack(resource);
255-
application.associateStack(resource);
256-
257-
Template.fromStack(stack).resourceCountIs('AWS::ServiceCatalogAppRegistry::ResourceAssociation', 1);
258172
});
259173
});
260174

packages/@aws-cdk/aws-servicecatalogappregistry-alpha/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.assets.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"version": "31.0.0",
33
"files": {
4-
"461d235e9497deb16b9209be4a927c7d0dc7aa06d668e38bfb19a90db8e4a4b2": {
4+
"f33c45795986ec36a911c738213b5076f0382d4e57e6ed43ea411e2014880ae2": {
55
"source": {
66
"path": "integ-servicecatalogappregistry-application.template.json",
77
"packaging": "file"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "461d235e9497deb16b9209be4a927c7d0dc7aa06d668e38bfb19a90db8e4a4b2.json",
12+
"objectKey": "f33c45795986ec36a911c738213b5076f0382d4e57e6ed43ea411e2014880ae2.json",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}

packages/@aws-cdk/aws-servicecatalogappregistry-alpha/test/integ.application.js.snapshot/integ-servicecatalogappregistry-application.template.json

-55
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,6 @@
77
"Description": "My application description"
88
}
99
},
10-
"TestApplicationResourceAssociationd232b63e52a8414E905D": {
11-
"Type": "AWS::ServiceCatalogAppRegistry::ResourceAssociation",
12-
"Properties": {
13-
"Application": {
14-
"Fn::GetAtt": [
15-
"TestApplication2FBC585F",
16-
"Id"
17-
]
18-
},
19-
"Resource": {
20-
"Ref": "AWS::StackId"
21-
},
22-
"ResourceType": "CFN_STACK"
23-
}
24-
},
25-
"TestApplicationAttributeGroupAssociation4ba7f5842818B8EE1C6F": {
26-
"Type": "AWS::ServiceCatalogAppRegistry::AttributeGroupAssociation",
27-
"Properties": {
28-
"Application": {
29-
"Fn::GetAtt": [
30-
"TestApplication2FBC585F",
31-
"Id"
32-
]
33-
},
34-
"AttributeGroup": {
35-
"Fn::GetAtt": [
36-
"TestAttributeGroupB1CB284F",
37-
"Id"
38-
]
39-
}
40-
}
41-
},
4210
"TestApplicationmyAnotherAttributeGroup375F79DB": {
4311
"Type": "AWS::ServiceCatalogAppRegistry::AttributeGroup",
4412
"Properties": {
@@ -105,29 +73,6 @@
10573
]
10674
}
10775
},
108-
"TestAttributeGroupB1CB284F": {
109-
"Type": "AWS::ServiceCatalogAppRegistry::AttributeGroup",
110-
"Properties": {
111-
"Attributes": {
112-
"stage": "alpha",
113-
"teamMembers": [
114-
"markI",
115-
"markII",
116-
"markIII"
117-
],
118-
"public": false,
119-
"publishYear": 2021,
120-
"plannedRoadMap": {
121-
"alpha": "some time",
122-
"beta": "another time",
123-
"gamma": "penultimate time",
124-
"release": "go time"
125-
}
126-
},
127-
"Name": "myAttributeGroup",
128-
"Description": "my attribute group description"
129-
}
130-
},
13176
"MyRoleF48FFE04": {
13277
"Type": "AWS::IAM::Role",
13378
"Properties": {

packages/@aws-cdk/aws-servicecatalogappregistry-alpha/test/integ.application.js.snapshot/manifest.json

+28-19
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"validateOnSynth": false,
1818
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
1919
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
20-
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/461d235e9497deb16b9209be4a927c7d0dc7aa06d668e38bfb19a90db8e4a4b2.json",
20+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/f33c45795986ec36a911c738213b5076f0382d4e57e6ed43ea411e2014880ae2.json",
2121
"requiresBootstrapStackVersion": 6,
2222
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
2323
"additionalDependencies": [
@@ -39,18 +39,6 @@
3939
"data": "TestApplication2FBC585F"
4040
}
4141
],
42-
"/integ-servicecatalogappregistry-application/TestApplication/ResourceAssociationd232b63e52a8": [
43-
{
44-
"type": "aws:cdk:logicalId",
45-
"data": "TestApplicationResourceAssociationd232b63e52a8414E905D"
46-
}
47-
],
48-
"/integ-servicecatalogappregistry-application/TestApplication/AttributeGroupAssociation4ba7f5842818": [
49-
{
50-
"type": "aws:cdk:logicalId",
51-
"data": "TestApplicationAttributeGroupAssociation4ba7f5842818B8EE1C6F"
52-
}
53-
],
5442
"/integ-servicecatalogappregistry-application/TestApplication/myAnotherAttributeGroup/Resource": [
5543
{
5644
"type": "aws:cdk:logicalId",
@@ -69,12 +57,6 @@
6957
"data": "TestApplicationMyShareIdE1044482"
7058
}
7159
],
72-
"/integ-servicecatalogappregistry-application/TestAttributeGroup/Resource": [
73-
{
74-
"type": "aws:cdk:logicalId",
75-
"data": "TestAttributeGroupB1CB284F"
76-
}
77-
],
7860
"/integ-servicecatalogappregistry-application/MyRole/Resource": [
7961
{
8062
"type": "aws:cdk:logicalId",
@@ -92,6 +74,33 @@
9274
"type": "aws:cdk:logicalId",
9375
"data": "CheckBootstrapVersion"
9476
}
77+
],
78+
"TestApplicationResourceAssociationd232b63e52a8414E905D": [
79+
{
80+
"type": "aws:cdk:logicalId",
81+
"data": "TestApplicationResourceAssociationd232b63e52a8414E905D",
82+
"trace": [
83+
"!!DESTRUCTIVE_CHANGES: WILL_DESTROY"
84+
]
85+
}
86+
],
87+
"TestApplicationAttributeGroupAssociation4ba7f5842818B8EE1C6F": [
88+
{
89+
"type": "aws:cdk:logicalId",
90+
"data": "TestApplicationAttributeGroupAssociation4ba7f5842818B8EE1C6F",
91+
"trace": [
92+
"!!DESTRUCTIVE_CHANGES: WILL_DESTROY"
93+
]
94+
}
95+
],
96+
"TestAttributeGroupB1CB284F": [
97+
{
98+
"type": "aws:cdk:logicalId",
99+
"data": "TestAttributeGroupB1CB284F",
100+
"trace": [
101+
"!!DESTRUCTIVE_CHANGES: WILL_DESTROY"
102+
]
103+
}
95104
]
96105
},
97106
"displayName": "integ-servicecatalogappregistry-application"

0 commit comments

Comments
 (0)