-
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): application-associator L2 Construct #22024
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f3ad2d6
feat(servicecatalogappregistry): adding capability to automatically a…
e180856
Updated Readme file to be in compilable format
6a2727e
Updated L2ConstructName from Automatic Application to Register Applic…
d8ca968
Updated New L2 ConstructName to ApplicationAssociator
2d89062
Merge branch 'main' into automatic_association
mergify[bot] 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ enables organizations to create and manage repositores of applications and assoc | |
## Table Of Contents | ||
|
||
- [Application](#application) | ||
- [Automatic-Application](#automatic-application) | ||
- [Register-Application](#register-application) | ||
- [Attribute-Group](#attribute-group) | ||
- [Associations](#associations) | ||
- [Associating application with an attribute group](#attribute-group-association) | ||
|
@@ -65,33 +65,39 @@ const importedApplication = appreg.Application.fromApplicationArn( | |
); | ||
``` | ||
|
||
## Automatic-Application | ||
## Register-Application | ||
|
||
An AppRegistry L2 construct to automatically create an application with the given name and description. | ||
The application name must be unique at the account level and it's immutable. | ||
`AutomaticApplication` L2 construct will automatically associate all stacks in the given scope, however | ||
in case of a `Pipeline` stack, stage underneath the pipeline will not automatically be associated and | ||
needs to be associated separately. | ||
If cross account stack is detected, then this construct will automatically share the application to consumer accounts. | ||
Cross account feature will only work for non environment agnostic stacks. | ||
|
||
Following will create an Application named `MyAutoApplication` in account `123456789012` and region `us-east-1` | ||
and will associate all stacks in the `App` scope to `MyAutoApplication`. | ||
If you want to create an Application named `MyRegisteredApplication` in account `123456789012` and region `us-east-1` | ||
and want to associate all stacks in the `App` scope to `MyRegisteredApplication`, then use as shown in the example below: | ||
|
||
```ts | ||
const app = new App(); | ||
const autoApp = new appreg.AutomaticApplication(app, 'AutoApplication', { | ||
applicationName: 'MyAutoApplication', | ||
description: 'Testing auto application', | ||
const registeredApp = new appreg.RegisterApplication(app, 'RegisterApplication', { | ||
applicationName: 'MyRegisteredApplication', | ||
description: 'Testing registered application', | ||
stackProps: { | ||
stackName: 'MyAutoApplicationStack', | ||
stackName: 'MyRegisteredApplicationStack', | ||
env: {account: '123456789012', region: 'us-east-1'}, | ||
}, | ||
}); | ||
``` | ||
|
||
In case of a Pipeline stack, you need to pass the reference of `AutomaticApplication` to pipeline stack and associate | ||
each stage as shown below: | ||
If you want to re-use an existing Application with ARN: `arn:aws:servicecatalog:us-east-1:123456789012:/applications/applicationId` | ||
and want to associate all stacks in the `App` scope to your imported application, then use as shown in the example below: | ||
|
||
```ts | ||
const app = new App(); | ||
const registeredApp = new appreg.RegisterApplication(app, 'RegisterApplication', { | ||
applicationArnValue: 'arn:aws:servicecatalog:us-east-1:123456789012:/applications/applicationId', | ||
stackProps: { | ||
stackName: 'MyRegisteredApplicationStack', | ||
}, | ||
}); | ||
``` | ||
|
||
If you are using CDK Pipelines to deploy your application, the application stacks will be inside Stages, and | ||
RegisterApplication 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: | ||
|
||
```ts | ||
import * as cdk from "@aws-cdk/core"; | ||
|
@@ -104,28 +110,28 @@ class ApplicationPipelineStack extends cdk.Stack { | |
constructor(scope: cdk.App, id: string, props: ApplicationPipelineStackProps) { | ||
super(scope, id, props); | ||
|
||
//associate the stage to automatic application. | ||
props.application.associateStage(beta, this.stackName); | ||
//associate the stage to register application. | ||
props.application.associateStage(beta); | ||
pipeline.addStage(beta); | ||
} | ||
}; | ||
|
||
interface ApplicationPipelineStackProps extends cdk.StackProps { | ||
application: appreg.AutomaticApplication; | ||
application: appreg.RegisterApplication; | ||
}; | ||
|
||
const app = new App(); | ||
const autoApp = new appreg.AutomaticApplication(app, 'AutoApplication', { | ||
applicationName: 'MyPipelineAutoApplication', | ||
description: 'Testing pipeline auto app', | ||
const registeredApp = new appreg.RegisterApplication(app, 'RegisterApplication', { | ||
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. I also don't particularly like this new name. It should be a noun.
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.
|
||
applicationName: 'MyPipelineRegisteredApplication', | ||
description: 'Testing pipeline registered app', | ||
stackProps: { | ||
stackName: 'MyPipelineAutoApplicationStack', | ||
stackName: 'MyPipelineRegisteredApplicationStack', | ||
env: {account: '123456789012', region: 'us-east-1'}, | ||
}, | ||
}); | ||
|
||
const cdkPipeline = new ApplicationPipelineStack(app, 'CDKApplicationPipelineStack', { | ||
application: autoApp, | ||
application: registeredApp, | ||
env: {account: '123456789012', region: 'us-east-1'}, | ||
}); | ||
``` | ||
|
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
4 changes: 2 additions & 2 deletions
4
packages/@aws-cdk/aws-servicecatalogappregistry/lib/attribute-group.ts
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.
Hi, I am sure the team thought deeply about a name of this class. Still, I think having a class name expressing an action instead of an object looks unintuitive. Perhaps that should be a factory method on the application class? Something like
appreg.Application.registerStacks(app)
?Related topics in AWS Construct Library Design Guidelines:
P.S.: Another reference can be cdk-nag project.