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

servicecatalogappregistry: Allow users to set ApplicationAssociator stack ID #24160

Closed
2 tasks
alexpulver opened this issue Feb 14, 2023 · 1 comment · Fixed by #24171 · 4 remaining pull requests
Closed
2 tasks

servicecatalogappregistry: Allow users to set ApplicationAssociator stack ID #24160

alexpulver opened this issue Feb 14, 2023 · 1 comment · Fixed by #24171 · 4 remaining pull requests
Labels
@aws-cdk/aws-servicecatalogappregistry effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Comments

@alexpulver
Copy link
Contributor

Describe the feature

Allow users to set ApplicationAssociator stack ID to maintain project naming convention for stack IDs in AWS CDK Toolkit output.

Use Case

I maintain a certain convention in my projects for the stack ID. For example: (e.g. UserManagementBackendSandbox). I wanted the stack ID that ApplicationAssociator class defines to align with that convention (e.g. UserManagementBackendApplication). This way, I control and understand the origin of stack IDs listed in AWS CDK Toolkit output (e.g. cdk synth).

With current behavior, 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.

Proposed Solution

Match stack ID to stack name or allow to specify it directly as it possible today with stack ID property:

const stackId = this.applicationOptions.stackId ?? 'ApplicationAssociatorStack';

If the plan is to still deprecate the stack ID property, I think the stack ID value should match the stack name exactly to allow users control over the generated stack ID. In regular stacks, users provide the construct ID for the stack, which becomes the stack ID. Any default value without allowing users to influence stack ID would remove that flexibility.

Other Information

Related pull request: #22508
Related issue: #23861

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.64.0

Environment details (OS name and version, etc.)

macOS Monterey

@alexpulver alexpulver added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Feb 14, 2023
@pahud pahud added p2 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Feb 16, 2023
@mergify mergify bot closed this as completed in #24171 Feb 16, 2023
mergify bot pushed a commit that referenced this issue 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*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment