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

Allow an app alias to be set in cdk.json #4543

Open
1 of 2 tasks
aaronsturm opened this issue Oct 16, 2019 · 12 comments
Open
1 of 2 tasks

Allow an app alias to be set in cdk.json #4543

aaronsturm opened this issue Oct 16, 2019 · 12 comments
Labels
effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. management/devenv Related to CDK development/build environment p1 package/tools Related to AWS CDK Tools or CLI

Comments

@aaronsturm
Copy link

aaronsturm commented Oct 16, 2019

I did try and search for open issues on this. My apologies if one already exists.
I would like the cdk.json file to allow for multiple app entries. Currently it defaults to only "app" in cdk.json and if I want to override that, I need to remember a long string:
cdk --app "npx ts-node bin/hello-cdk.ts" ls. I propose that a custom alias can be set in the cdk.json file.

Use Case

This would allow me to separate and process my stacks using a memorable alias vs the whole command.

Proposed Solution

I propose that an app alias can also be specified in cdk.json. As an example:

{
  "app": "npx ts-node bin/cdk.ts",
  "helloWorld": "npx ts-node bin/hello-cdk.ts"
}

which would allow me to call
cdk --app helloWorld ls.

Other

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

This is a 🚀 Feature Request

@aaronsturm aaronsturm added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Oct 16, 2019
@eladb
Copy link
Contributor

eladb commented Oct 17, 2019

I like this idea!

@SomayaB SomayaB added the management/devenv Related to CDK development/build environment label Oct 17, 2019
@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Oct 17, 2019
@rix0rrr
Copy link
Contributor

rix0rrr commented Dec 2, 2019

Can I ask what the different apps do, and why you don't want to combine them into a single app?

@aaronsturm
Copy link
Author

@rix0rrr - We have our core application CDK file, and then we have CDK files that are related to the application, but not directly. As an example, app.ts is for the application's infracture and then users.ts for our internal users and their respective permissions for console/API access. If we have a change in our staff, I update users.ts and deploy that stack change specifically.

As to why I don't combine them, they're logically separate in my mind so it makes sense to me for the files/entrypoint to be different vs having one large cdk.ts.

I hope that helps clarify my thought processes. Let me know if you have additional questions. Thanks!

@rix0rrr rix0rrr added the package/tools Related to AWS CDK Tools or CLI label Jan 23, 2020
@rix0rrr rix0rrr assigned shivlaks and unassigned rix0rrr Jan 23, 2020
@shivlaks shivlaks added the effort/medium Medium work item – several days of effort label Feb 24, 2020
@DJAlPee
Copy link

DJAlPee commented Jul 24, 2020

I have another use case for a feature like that:

For rolling out a static (SPA) website, we need to create resources in two regions (ACM certs / Lambda@Edge in us-east-1 for CloudFront and everything else like S3, etc. in our region). Because CDK (and CloudFormation) can't pass references across stacks, which are across different regions, I would split these resources into two different apps and handle passing the references somehow else.

@shivlaks shivlaks added the p2 label Aug 7, 2020
@NGL321 NGL321 assigned rix0rrr and unassigned shivlaks Jan 25, 2021
@rix0rrr rix0rrr removed their assignment Jun 3, 2021
@g360Joshua
Copy link

any update on this?

@rix0rrr rix0rrr added p1 and removed p2 labels Mar 16, 2022
@TheRealAmazonKendra TheRealAmazonKendra added p2 and removed p1 labels Jan 25, 2023
@TheRealAmazonKendra
Copy link
Contributor

Related: #9346

@github-actions github-actions bot added p1 and removed p2 labels Jan 29, 2023
@github-actions
Copy link

This issue has received a significant amount of attention so we are automatically upgrading its priority. A member of the community will see the re-prioritization and provide an update on the issue.

@jdpst
Copy link

jdpst commented Feb 5, 2023

This would be a very useful feature for managing logically distinct applications from the same repo. Our use case is that we have several web applications that are deployed from within a monorepo. Because we are leveraging the Asset constructs for S3 and lambda deployments, synthing requires the build artifacts. Having a single cdk executable would force us to build every site to deploy any of them, which is expensive (CI minutes aren't free!).

To work around this, we have a single stack that defines the infra and we deploy it using environment variables to specify which site to deploy. This works because the sites all have the same basic infra requirements, but it is not very transparent or elegant–our config settings are spread out across (in our case GitHub actions) CI scripts instead of in our CDK app.

With this solution we would be able to manage this situation much more explicitly with a different cdk executable file per logically separate application.

@ajhool
Copy link

ajhool commented Feb 6, 2023

Another use case:

We would like to deploy one "baseline" app into each AWS account that defines expensive resources (eg. VPC, RDS, etc.) that are shared across cheap feature environments in the account (eg. 5 feature-branch API gateways or websites might share the same backend database).

  1. CDK Baseline App | VPC + Database | 1 app deployment per account named "Baseline"
  2. CDK feature branch| API Gateway + Website | N apps named "Application-FEATURE_A" ... "Application-FEATURE_N".

The multi-region use-case is also important for us!

Those could be managed in separate repos and packages, but monorepos with a single package.json save some complexity on smaller projects. And, in theory, we could just use NestedStacks and CloudFormation to logically separate our apps -- but we'd rather not because escaping a CloudFormation issue with an API Gateway deployment is much less of a headache if databases / VPCs / stateful resources aren't involved (probably preaching to the choir here).

@billyjbryant
Copy link

My use case for this feature is housing multiple CDK Applications in a single code repository and being able to deploy them using cdk deploy from the root directory. This allows my team to manage all of its dependent applications, which are really just configurations for services like AWS Config, GuardDuty, ControlTower and other various small tools, in a single location and not have to maintain multiple code repositories.

@sciutand
Copy link

sciutand commented Oct 14, 2023

When we deploy to multiple accounts different stacks some stacks are not relevant to all accounts and often defining all stacks in the same file cause issues when trying to access secrets, vpc, stack outputs etc.
So my use case would be let's say.

bin/
     infra.ts
     workload-prod.ts
     sandbox.ts
     workload-dev.ts

and do
cdk deploy --app infra TransitGatewayStack
cdk deploy --app workload-prod WorkloadVpcStack
cdk deploy --app workload-dev WorkloadVpcStack

In essence being able to either define different app in the cdk.json file or being able to load/specify different json files.
I could achieve similar with a monorepo and something like:

packages/
      core
      infra-cdk
      workload-prod-cdk
      sandbox-cdk
      ...

but it would be a lot cleaner if cdk supported multiple apps a bit better than the current --app option

@sigpop
Copy link

sigpop commented Feb 9, 2024

We would like to deploy one "baseline" app into each AWS account that defines expensive resources (eg. VPC, RDS, etc.) that are shared across cheap feature environments in the account (eg. 5 feature-branch API gateways or websites might share the same backend database).

I have a similar use case. Having app be aliased would be useful for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. management/devenv Related to CDK development/build environment p1 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

No branches or pull requests