Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS CDK Init for an existing project

I'm trying to initialize the AWS CDK on a new website I just created via Visual Studio.

But when I run the init commmand I get the error: cdk init cannot be run in a non-empty directory

❯ cdk init app --language=csharp
`cdk init` cannot be run in a non-empty directory!

The CDK Workshop uses the example of starting from scrach (in an empty directory).

Is it possible to initialize the CDK inside an existing solution/project?

like image 717
Philip Pittle Avatar asked Aug 10 '20 21:08

Philip Pittle


2 Answers

cdk init creats a basic structure and skelton such as app and sub directory in which it create a stack.

You can run it in a empty directory and then back up the files you will override, then copy an actual cdk application/project (such as workshop one) into it.

I use this way to create another CDK project when I re-use the existing one.

like image 73
mon Avatar answered Oct 17 '22 01:10

mon


At the moment there is no way to execute cdk init in a non-empty directory. This is a safety net against cluttering a directory with the CDK files where they might not be wanted.

That said, there is no practical reason a command flag to override this protection couldnt be added. You could consider putting in a feature-request on the repo.

like image 24
Noah Litov Avatar answered Oct 17 '22 02:10

Noah Litov