-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Changes from 3 commits
f3ad2d6
e180856
6a2727e
d8ca968
2d89062
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,12 +21,13 @@ | |
|
||
<!--END STABILITY BANNER--> | ||
|
||
[AWS Service Catalog App Registry](https://docs.aws.amazon.com/servicecatalog/latest/adminguide/appregistry.html) | ||
[AWS Service Catalog App Registry](https://docs.aws.amazon.com/servicecatalog/latest/adminguide/appregistry.html) | ||
enables organizations to create and manage repositores of applications and associated resources. | ||
|
||
## Table Of Contents | ||
|
||
- [Application](#application) | ||
- [Register-Application](#register-application) | ||
- [Attribute-Group](#attribute-group) | ||
- [Associations](#associations) | ||
- [Associating application with an attribute group](#attribute-group-association) | ||
|
@@ -44,11 +45,11 @@ import * as appreg from '@aws-cdk/aws-servicecatalogappregistry'; | |
## Application | ||
|
||
An AppRegistry application enables you to define your applications and associated resources. | ||
The application name must be unique at the account level, but is mutable. | ||
The application name must be unique at the account level and it's immutable. | ||
|
||
```ts | ||
const application = new appreg.Application(this, 'MyFirstApplication', { | ||
applicationName: 'MyFirstApplicationName', | ||
applicationName: 'MyFirstApplicationName', | ||
description: 'description for my application', // the description is optional | ||
}); | ||
``` | ||
|
@@ -64,14 +65,85 @@ const importedApplication = appreg.Application.fromApplicationArn( | |
); | ||
``` | ||
|
||
## Register-Application | ||
|
||
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 registeredApp = new appreg.RegisterApplication(app, 'RegisterApplication', { | ||
applicationName: 'MyRegisteredApplication', | ||
description: 'Testing registered application', | ||
stackProps: { | ||
stackName: 'MyRegisteredApplicationStack', | ||
env: {account: '123456789012', region: 'us-east-1'}, | ||
}, | ||
}); | ||
``` | ||
|
||
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"; | ||
import * as codepipeline from "@aws-cdk/pipelines"; | ||
import * as codecommit from "@aws-cdk/aws-codecommit"; | ||
declare const repo: codecommit.Repository; | ||
declare const pipeline: codepipeline.CodePipeline; | ||
declare const beta: cdk.Stage; | ||
class ApplicationPipelineStack extends cdk.Stack { | ||
constructor(scope: cdk.App, id: string, props: ApplicationPipelineStackProps) { | ||
super(scope, id, props); | ||
|
||
//associate the stage to register application. | ||
props.application.associateStage(beta); | ||
pipeline.addStage(beta); | ||
} | ||
}; | ||
|
||
interface ApplicationPipelineStackProps extends cdk.StackProps { | ||
application: appreg.RegisterApplication; | ||
}; | ||
|
||
const app = new 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: 'MyPipelineRegisteredApplicationStack', | ||
env: {account: '123456789012', region: 'us-east-1'}, | ||
}, | ||
}); | ||
|
||
const cdkPipeline = new ApplicationPipelineStack(app, 'CDKApplicationPipelineStack', { | ||
application: registeredApp, | ||
env: {account: '123456789012', region: 'us-east-1'}, | ||
}); | ||
``` | ||
|
||
## Attribute Group | ||
|
||
An AppRegistry attribute group acts as a container for user-defined attributes for an application. | ||
Metadata is attached in a machine-readble format to integrate with automated workflows and tools. | ||
|
||
```ts | ||
const attributeGroup = new appreg.AttributeGroup(this, 'MyFirstAttributeGroup', { | ||
attributeGroupName: 'MyFirstAttributeGroupName', | ||
attributeGroupName: 'MyFirstAttributeGroupName', | ||
description: 'description for my attribute group', // the description is optional, | ||
attributes: { | ||
project: 'foo', | ||
|
@@ -104,7 +176,7 @@ Resources are CloudFormation stacks that you can associate with an application t | |
stacks together to enable metadata rich insights into your applications and resources. | ||
A Cloudformation stack can only be associated with one appregistry application. | ||
If a stack is associated with multiple applications in your app or is already associated with one, | ||
CDK will fail at deploy time. | ||
CDK will fail at deploy time. | ||
|
||
### Associating application with an attribute group | ||
|
||
|
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.