Skip to content
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): stackId construct prop for ApplicationAssociator #22508

Closed
wants to merge 2 commits into from
Closed

feat(servicecatalogappregistry): stackId construct prop for ApplicationAssociator #22508

wants to merge 2 commits into from

Conversation

alexpulver
Copy link
Contributor

@alexpulver alexpulver commented Oct 14, 2022

Add optional stackId construct prop to ApplicationAssociator class and clarify documentation.

Currently, I can't control the stack ID that ApplicationAssociator class defines:

const applicationStack = new cdk.Stack(scope, 'ApplicationAssociatorStack', props.stackProps);

I maintain a certain convention in my projects for the stack ID. For example: <Workload><Component><Suffix> (e.g. UserManagement*Backend*Sandbox). I wanted the stack ID that ApplicationAssociator class defines to align with that convention (e.g. UserManagement*Backend*Application). This way, I control and understand the origin of stack IDs listed in cdk synth output.

With current beahvior, the cdk synth output I get is:

Supply a stack id (ApplicationAssociatorStack, UserManagementBackendSandbox, UserManagementBackendToolchain) to display its template.

The ApplicationAssociatorStack name was surprising for me, as I didn't specify it. I had to look at ApplicationAssociator source code to understand where it's coming from. It also wasn't obvious from the documentation that ApplicationAssociator creates a dedicated stack for the application. I added this clarification.


All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • [ x ] Have you added the new feature to an integration test?
    • [ x ] Did you use yarn integ to deploy the infrastructure and generate the snapshot (i.e. yarn integ without --dry-run)?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Oct 14, 2022

@aws-cdk-automation aws-cdk-automation requested a review from a team October 14, 2022 20:59
@github-actions github-actions bot added p2 repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK labels Oct 14, 2022
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

@aws-cdk-automation aws-cdk-automation dismissed their stale review October 15, 2022 05:05

✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.

* Stack ID.
*
*/
readonly stackId: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this optional instead? In case customers do not want to provide stackId, then we can instead default it to ApplicationAssociator

Copy link
Contributor Author

@alexpulver alexpulver Oct 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the suggestion! It also makes the change incremental and not breaking, which is great 😃. I pushed the update, although used the previous ApplicationAssociatorStack value to avoid introducing a breaking change.

Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

@aws-cdk-automation aws-cdk-automation dismissed their stale review October 15, 2022 09:28

✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.

* @default - ApplicationAssociatorStack
*
*/
readonly stackId?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
readonly stackId?: string;
readonly applicationStackId?: string;

I think that just stackId here may be confusing. Let's make the field name more specific.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also rename stackProps to applicationStackProps then?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so? Given your role, I think you would have a better idea of the user experience here so I'm wondering what your thoughts are on this change. I prefer it for clarity but I don't use this service.

@@ -10,6 +10,7 @@ const stack = new cdk.Stack(app, 'integ-servicecatalogappregistry-application');
new appreg.ApplicationAssociator(app, 'RegisterCdkApplication', {
applicationName: 'AppRegistryAssociatedApplication',
description: 'Testing AppRegistry ApplicationAssociator',
stackId: 'AppRegistryApplicationAssociatorStack',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of just adding this field here, please convert this to the new integ test type and add a second stack with the applicationStackId supplied. The new style of tests allows for multiple test cases.

applicationName: 'MyAssociatedApplication',
stackId: 'MyAssociatedApplicationStack',
stackProps: {
stackName: 'MyAssociatedApplicationStack',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not use stackName for the stackId instead of adding another prop? This seems redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely can, although it will cause stack replacement for existing customers. Given that this is alpha, would you be okay that I'll make that change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheRealAmazonKendra if we use stackName for stack ID, does it require a dedicated test?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking changes are fine, just make sure that the fact that it's breaking shows up in the title. From your perspective, would using the stackName satisfy your use case and also not require extra fields that the user has to care about?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I'd say that as long as the change shows up in integration tests and impacts the outputs in a way we see when you run the tests, I don't think any additional ones should be needed. But, I'd ask that you change the name of the stack in the test below so we can see the impact.

@mergify mergify bot dismissed TheRealAmazonKendra’s stale review October 22, 2022 05:15

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 6e389ed
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

* @default - ApplicationAssociatorStack
*
*/
readonly stackId?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so? Given your role, I think you would have a better idea of the user experience here so I'm wondering what your thoughts are on this change. I prefer it for clarity but I don't use this service.

applicationName: 'MyAssociatedApplication',
stackId: 'MyAssociatedApplicationStack',
stackProps: {
stackName: 'MyAssociatedApplicationStack',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking changes are fine, just make sure that the fact that it's breaking shows up in the title. From your perspective, would using the stackName satisfy your use case and also not require extra fields that the user has to care about?

applicationName: 'MyAssociatedApplication',
stackId: 'MyAssociatedApplicationStack',
stackProps: {
stackName: 'MyAssociatedApplicationStack',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I'd say that as long as the change shows up in integration tests and impacts the outputs in a way we see when you run the tests, I don't think any additional ones should be needed. But, I'd ask that you change the name of the stack in the test below so we can see the impact.

@@ -45,6 +53,8 @@ export interface ApplicationAssociatorProps {
*
* 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.
*
* The construct creates a dedicated stack for the application.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the additional context here.

@alexpulver
Copy link
Contributor Author

Hi @santanugho, should I close this PR in favor of #22644?

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

5 similar comments
@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@alexpulver alexpulver marked this pull request as draft November 3, 2022 08:39
@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@alexpulver
Copy link
Contributor Author

Superceded by #22644

@alexpulver alexpulver closed this Nov 4, 2022
@alexpulver alexpulver deleted the appregistry-stack-id branch November 4, 2022 07:13
mergify bot pushed a commit that referenced this pull request Feb 16, 2023
…ack name for Application stack (#24171)

* Assign value of `stackName` to `stackId` for Application stack, so the stack id will always be the same as stack name. Users wanting to control stack id can do so via `stackName`.

Closes #24160.

Background:
* Customers wish to control or modify the stack id of the Application stack to follow their project conventions within CDK.
* In previous [fix](#23823), we had deprecated the stack id to push users towards using stack name as the main mechanism for stack identification.

Note on backward-compatibility:

After this change, the `stackId` parameter can no longer be used to control the application stack id. The stack id will always match stack name, and the default stack name if not specified will be `Application-${APPLICATION_IDENTIFIER}-Stack`. `${APPLICATION_IDENTIFIER}` is application name for CreateTargetApplication and application id for ExistingTargetApplication.

If you created an application stack prior to aws-cdk [release v2.64.0](https://github.com/aws/aws-cdk/releases/tag/v2.64.0) and did not specify a stack id or name, you may run into the following error during deployment due to the creation attempt of a new stack with the same application:
```log
Resource handler returned message: "You already own an application 'MyApplicationName' (Service: ServiceCatalogAppRegistry, Status Code: 409, Request ID: xxxx)" (RequestToken: yyyy, HandlerErrorCode: InvalidRequest)
```

To address this error, you can set the `stackName` value to match your existing stack. For example:
```typescript
const associatedApp = new ApplicationAssociator(app, 'MyApplicationAssociator', {
  applications: [ TargetApplication.createApplicationStack({
    applicationName: 'MyApplicationName',
    stackName: 'ApplicationAssociatorStack', // Add your existing stack name here
    ...
```
This will result in the existing stack deploying with the previous name, and the id in CDK will reflect this same stack name.

Related links:
* Previous PR: #23823
* Previous GitHub issue: #23861
* Original reason that introduced `stackId`: #22508

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2 repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants