0

The documentation on AWS-CDK has examples of setting it up as a standalone application with support in multiple languages.

I have the following questions regarding the same:

  • Is it possible to use it within a separate app (written in .NET Core or Angular) like a library?
  • By above I mean being able to instantiate the construct classes within my app's services and create stacks in my AWS account.
  • If yes, how does it affect the deployment process? Will invoking the synth() function, generate the cloud-formation templates as expected?

Apologies if my question is vague. I am just getting started with this and am willing to provide necessary details if needed.

I appreciate any help in this regard. Thank you.

Swasti Gupta
  • 187
  • 1
  • 12

1 Answers1

0

I've tried using cdk as a library, but had a few issues and started calling it from another app by using a cli call.

I was using typescript and basically what I did was to call the synth method on the app construct:

import * as cdk from '@aws-cdk/core';

const app = new cdk.App();
... // do something
const cf = app.synth(); // here you get the cloud assembly
cf.something() // you can manipulate the results here

A few issues I found was to get errors during synth as they were not proper bubbled up. I couldn't find a way to deal with the assets either...

In summary, I didn't explore it much further than that, but I think cdk might need more development to be able to use all its features when importing as a library.

Pedreiro
  • 1,641
  • 2
  • 18
  • 28
  • Thank you for your reply. Yes, I agree that the CDK needs some more improvements to be able to use it as a lib. But could you elaborate on the "calling it from another app by cli" part ? – Swasti Gupta Jul 02 '20 at 04:44
  • 1
    I mean by using an exec library to call the cdk cli tool from within the ts code as you can do with any executable https://stackoverflow.com/questions/19762350/execute-an-exe-file-using-node-js – Pedreiro Jul 03 '20 at 11:06
  • Thank you for your reply. I will try it out. – Swasti Gupta Jul 07 '20 at 06:25