Skip to content

Commit 38b1337

Browse files
author
neha
committed
feat(servicecatalogappregistry-alpha): add attributes property to AttributeGroup import
1 parent 6eb6ce9 commit 38b1337

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

packages/@aws-cdk/aws-servicecatalogappregistry-alpha/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,14 @@ const importedAttributeGroup = appreg.AttributeGroup.fromAttributeGroupArn(
247247
'MyImportedAttrGroup',
248248
'arn:aws:servicecatalog:us-east-1:012345678910:/attribute-groups/0aqmvxvgmry0ecc4mjhwypun6i',
249249
);
250+
251+
252+
const importedAttributeGroupWithAttrs = appreg.AttributeGroup.fromAttributeGroupArn(
253+
this,
254+
'MyImportedAttrGroupWithAttrs',
255+
'arn:aws:servicecatalog:us-east-1:012345678910:/attribute-groups/0aqmvxvgmry0ecc4mjhwypun6i',
256+
{ key1: 'value1', key2: 'value2' }
257+
);
250258
```
251259

252260
## Associations

packages/@aws-cdk/aws-servicecatalogappregistry-alpha/test/attribute-group.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ describe('Attribute Group', () => {
1616
});
1717

1818
test('default attribute group creation', () => {
19-
new appreg.AttributeGroup(stack, 'MyAttributeGroup', {
19+
const attributeGroup = new appreg.AttributeGroup(stack, 'MyAttributeGroup', {
2020
attributeGroupName: 'testAttributeGroup',
2121
attributes: {
2222
key: 'value',
2323
},
2424
});
2525

26+
expect(attributeGroup.attributes).toEqual({ key: 'value' });
27+
2628
Template.fromStack(stack).templateMatches({
2729
Resources: {
2830
MyAttributeGroup99099500: {
@@ -78,6 +80,21 @@ describe('Attribute Group', () => {
7880
expect(attributeGroup.attributeGroupId).toEqual('0aqmvxvgmry0ecc4mjhwypun6i');
7981
}),
8082

83+
test('for an attribute group imported by ARN with attributes', () => {
84+
const attributes = { key1: 'value1', key2: 'value2' };
85+
const attributeGroup = appreg.AttributeGroup.fromAttributeGroupArn(stack, 'MyAttributeGroup',
86+
'arn:aws:servicecatalog:us-east-1:123456789012:/attribute-groups/0aqmvxvgmry0ecc4mjhwypun6i', attributes);
87+
expect(attributeGroup.attributeGroupId).toEqual('0aqmvxvgmry0ecc4mjhwypun6i');
88+
expect(attributeGroup.attributes).toEqual(attributes);
89+
}),
90+
91+
test('for an attribute group imported by ARN without attributes', () => {
92+
const attributeGroup = appreg.AttributeGroup.fromAttributeGroupArn(stack, 'MyAttributeGroup',
93+
'arn:aws:servicecatalog:us-east-1:123456789012:/attribute-groups/0aqmvxvgmry0ecc4mjhwypun6i');
94+
expect(attributeGroup.attributeGroupId).toEqual('0aqmvxvgmry0ecc4mjhwypun6i');
95+
expect(attributeGroup.attributes).toBeUndefined();
96+
}),
97+
8198
test('Associate an application to an imported attribute group', () => {
8299
const attributeGroup = appreg.AttributeGroup.fromAttributeGroupArn(stack, 'MyAttributeGroup',
83100
'arn:aws:servicecatalog:us-east-1:123456789012:/attribute-groups/0aqmvxvgmry0ecc4mjhwypun6i');
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import * as cdk from 'aws-cdk-lib';
2+
import * as appreg from '../lib';
3+
4+
const app = new cdk.App();
5+
const stack = new cdk.Stack(app, 'integ-servicecatalogappregistry-attribute-group-import');
6+
7+
// Test importing AttributeGroup without attributes
8+
const importedAttributeGroup = appreg.AttributeGroup.fromAttributeGroupArn(
9+
stack,
10+
'ImportedAttributeGroup',
11+
'arn:aws:servicecatalog:us-east-1:012345678910:/attribute-groups/test-import-id'
12+
);
13+
14+
// Test importing AttributeGroup with attributes
15+
const importedAttributeGroupWithAttrs = appreg.AttributeGroup.fromAttributeGroupArn(
16+
stack,
17+
'ImportedAttributeGroupWithAttrs',
18+
'arn:aws:servicecatalog:us-east-1:012345678910:/attribute-groups/test-import-id',
19+
{
20+
environment: 'production',
21+
team: 'platform',
22+
version: '1.0.0'
23+
}
24+
);
25+
26+
// Create an application to associate with imported attribute groups
27+
const application = new appreg.Application(stack, 'TestApplication', {
28+
applicationName: 'TestApplication',
29+
description: 'Test application for imported attribute groups',
30+
});
31+
32+
// Associate imported attribute groups with the application
33+
importedAttributeGroup.associateWith(application);
34+
importedAttributeGroupWithAttrs.associateWith(application);
35+
36+
app.synth();

0 commit comments

Comments
 (0)