-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(servicecatalogappregistry): add attribute groups to an application #24672
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
570c77e
Add associateNewAttributeGroup to create and associate the attribute …
liwewang-amazon ddd8fab
Support create & associate attribute group in `Application` construct
liwewang-amazon aa97fd7
Change addAG param name
liwewang-amazon 540af2e
fix readme
liwewang-amazon 80496d1
Updating samples with new input
liwewang-amazon 1dafe29
Add id into `addAttributeGroup` input to provide to AttributeGroup co…
liwewang-amazon f21f11b
Change doc for addAttributeGroup method.
liwewang-amazon d4753c6
Make attribute group name as required.
liwewang-amazon 07c0a1e
n to N
liwewang-amazon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ import * as cdk from '@aws-cdk/core'; | |
import { Names } from '@aws-cdk/core'; | ||
import { Construct } from 'constructs'; | ||
import { StageStackAssociator } from './aspects/stack-associator'; | ||
import { IAttributeGroup } from './attribute-group'; | ||
import { AttributeGroup, IAttributeGroup } from './attribute-group'; | ||
import { getPrincipalsforSharing, hashValues, ShareOptions, SharePermission } from './common'; | ||
import { isAccountUnresolved } from './private/utils'; | ||
import { InputValidator } from './private/validation'; | ||
|
@@ -12,6 +12,29 @@ import { CfnApplication, CfnAttributeGroupAssociation, CfnResourceAssociation } | |
const APPLICATION_READ_ONLY_RAM_PERMISSION_ARN = 'arn:aws:ram::aws:permission/AWSRAMPermissionServiceCatalogAppRegistryApplicationReadOnly'; | ||
const APPLICATION_ALLOW_ACCESS_RAM_PERMISSION_ARN = 'arn:aws:ram::aws:permission/AWSRAMPermissionServiceCatalogAppRegistryApplicationAllowAssociation'; | ||
|
||
/** | ||
* Properties for a Service Catalog AppRegistry Attribute Group | ||
*/ | ||
export interface AttributeGroupAssociationProps { | ||
/** | ||
* Name for attribute group. | ||
* | ||
*/ | ||
readonly attributeGroupName: string; | ||
|
||
/** | ||
* Description for attribute group. | ||
* @default - No description provided | ||
*/ | ||
readonly description?: string; | ||
|
||
/** | ||
* A JSON of nested key-value pairs that represent the attributes in the group. | ||
* Attributes maybe an empty JSON '{}', but must be explicitly stated. | ||
liwewang-amazon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
readonly attributes: { [key: string]: any }; | ||
} | ||
|
||
/** | ||
* A Service Catalog AppRegistry Application. | ||
*/ | ||
|
@@ -41,6 +64,14 @@ export interface IApplication extends cdk.IResource { | |
*/ | ||
associateAttributeGroup(attributeGroup: IAttributeGroup): void; | ||
|
||
/** | ||
* Create an attribute group and associate this application with the created attribute group. | ||
* | ||
* @param id name of the AttributeGroup construct to be created. | ||
* @param attributeGroupProps AppRegistry attribute group props | ||
*/ | ||
addAttributeGroup(id: string, attributeGroupProps: AttributeGroupAssociationProps): IAttributeGroup; | ||
|
||
/** | ||
* Associate this application with a CloudFormation stack. | ||
* | ||
|
@@ -114,6 +145,23 @@ abstract class ApplicationBase extends cdk.Resource implements IApplication { | |
} | ||
} | ||
|
||
/** | ||
* Create an attribute group and associate this application with the created attribute group. | ||
*/ | ||
public addAttributeGroup(id: string, props: AttributeGroupAssociationProps): IAttributeGroup { | ||
const attributeGroup = new AttributeGroup(this, id, { | ||
attributeGroupName: props.attributeGroupName, | ||
attributes: props.attributes, | ||
description: props.description, | ||
}); | ||
new CfnAttributeGroupAssociation(this, `AttributeGroupAssociation${this.generateUniqueHash(attributeGroup.node.addr)}`, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
application: this.applicationId, | ||
attributeGroup: attributeGroup.attributeGroupId, | ||
}); | ||
this.associatedAttributeGroups.add(attributeGroup.node.addr); | ||
return attributeGroup; | ||
} | ||
|
||
/** | ||
* Associate a stack with the application | ||
* If the resource is already associated, it will ignore duplicate request. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/cdk.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"version":"30.1.0"} | ||
{"version":"31.0.0"} |
6 changes: 3 additions & 3 deletions
6
...est/integ.application.js.snapshot/integ-servicecatalogappregistry-application.assets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ages/@aws-cdk/aws-servicecatalogappregistry/test/integ.application.js.snapshot/integ.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"version": "30.1.0", | ||
"version": "31.0.0", | ||
"testCases": { | ||
"integ.application": { | ||
"stacks": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this not optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attribute group name is the key to calculate attribute group construct id to make sure that multiple
addAttributeGroup
calls won't generate the same construct ID. Since name is unique, ifaddAttributeGroup
is called twice with the sameattributeGroupName
, construct duplicate error will be thrown. BothNames.uniqueNodeId()
andNames.uniqueResourceName()
generate id from the path of the construct, i.e. path of the application. As a result, twoaddAttributeGroup
calls with different names\attributes\descriptions generate twoAttributeGroup
constructs with the same construct ID.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be required even if we use customer provided construct id for attribute group.
Attribute group name is the key human readable identifier our service offers for customer to find the attribute group, we want to make it explicit, so that it will can make use of the name to look for the attribute group in other platforms like console or SDK client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are aware that 99% of other constructs allow the user to not specify a name and have the system one generate for them?