Reputation: 12295
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?
Upvotes: 16
Views: 15907
Reputation: 22274
cdk init creates a basic structure and a skeleton, such as an app and subdirectory in which it creates a stack.
You can run it in an empty directory, back up the files you will override, and 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.
Upvotes: 11
Reputation: 96
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.
Upvotes: 5