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

(aws-cdk): Information for Requesting Deno Support #3938

Open
shellscape opened this issue Nov 7, 2021 · 16 comments
Open

(aws-cdk): Information for Requesting Deno Support #3938

shellscape opened this issue Nov 7, 2021 · 16 comments
Labels
effort/large Large work item – several weeks of effort feature-request A feature should be added or improved. p2 package/tools

Comments

@shellscape
Copy link

General Issue

Information for Requesting Deno Support

The Question

I'd like to know what the proper procedures and steps are required to start the discussion around formal support for Deno (https://deno.land). Deno is an alternative to Node that supports TypeScript and ESM natively. While it's a close cousin, many of the mechanisms have significant differences, namely dependency management. Presently, to make use of AWS CDK for Deno apps, users must run Node along side Deno.

I'd like to propose Deno support for AWS CDK, as it's already authored in TypeScript for Node support, but I'm honestly not sure where to begin.

CDK CLI Version

1.131.0

Framework Version

No response

Node.js Version

No response

OS

No response

Language

Typescript

Language Version

No response

Other information

No response

@shellscape shellscape added guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. labels Nov 7, 2021
@PerArneng
Copy link

I would like to add to this. The biggest benefit is the nature of the cdk in that you want infrastructure as code but why do you need to compile code first. Thats just a a side effect of how typescript works with node. With deno you could basically just generate a single TypeScript file, cdk config and a README.md and then you are god to go. No compile step. Dependencies are declared inside the TypeScript file etc. Its the perfect tool for CDK. Deno is also super simple to install. The deno engine could probably be embedded as well. There could be a cdk-ts that basically didn't even need deno installed it just had a TS as input. That would be awesome.

@ryparker
Copy link
Contributor

ryparker commented Nov 18, 2021

Thanks for the issue @shellscape

I'll convert this to a feature request since its requesting new support. Feel free to update your description accordingly.

We prioritize by community feedback so +1 👍🏻 the issue if you'd like to see this worked.

@ryparker ryparker added effort/large Large work item – several weeks of effort feature-request A feature should be added or improved. p2 and removed guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. labels Nov 18, 2021
@rix0rrr
Copy link
Contributor

rix0rrr commented Nov 22, 2021

The biggest benefit is the nature of the cdk in that you want infrastructure as code but why do you need to compile code first.

You do not have to, you can choose to use ts-node as well. This will provide the same benefits.

@rix0rrr rix0rrr removed their assignment Nov 22, 2021
@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot added p1 and removed p2 labels Apr 10, 2022
@kaizencc
Copy link
Contributor

So I see that this has gotten a few +1s. It's one of those long-living tracking issues though, and some of the other issues labeled feature/new-language have hundreds of +1s. It would be incorrect to keep this as a p1, as we are not considering adding new languages to JSII at this time, and even if we were, I'm not sure that this would be the language we pick up.

@kaizencc kaizencc added p2 and removed p1 labels May 17, 2022
@shellscape
Copy link
Author

Odd considering it's probably the easiest lateral move with the least amount of effort needed from the current Node support.

@BrintParisK
Copy link

we are not considering adding new languages to JSII at this time, and even if we were, I'm not sure that this would be the language we pick up.

Can I suggest a bit of a review into it? Deno is literally the successor to Node, written by the same creator (Ryan Dahl), and in a stable form used by an increasingly growing number of developers. And like shellscape pointed out, it's a very, very easy transition. The reason this post got so much attention is because a lot of devs (like myself) are waiting for basically this final piece to start transitioning all of our business apps into Deno.

@sebs
Copy link

sebs commented Jul 1, 2022

if you need help get this running: i am happy to invest some time into it.

@tarcon
Copy link

tarcon commented Jul 11, 2022

I wish I could run cdk using deno. It seems to me that this could slim down the configuration a lot.

@csvn
Copy link

csvn commented Nov 15, 2022

The newly released Deno 1.28 has npm support out of the box. It's incredibly tempting to be able to run CDK without needing to install anything at all. The npm support would probably make it a lot simpler to integrate with CDK.

we are not considering adding new languages to JSII at this time

I'd be hard pressed to call Deno a language. It's Typescript, and even compatible with the web. It has it's own API on the Deno namespace, which is similar to Node's built in modules. Given that the CDK supports Typescript already, a large part should already work as-is.

@rinfield
Copy link

rinfield commented Dec 5, 2022

It seems that a simple CDK project can already be made to work with Deno (including CDK CLI).

// deno.jsonc
{
  "tasks": {
    "cdk": "deno run --allow-all npm:aws-cdk --app 'deno run --allow-all main.ts'",
    "test": "deno test --allow-all",
    "ci": "deno fmt --check && deno lint && deno task test"
  },
  "lint": {
    "files": {
      "exclude": ["cdk.out"]
    }
  },
  "fmt": {
    "files": {
      "exclude": ["cdk.out"]
    }
  }
}
// main.ts
import cdk from "npm:aws-cdk-lib";

const app = new cdk.App();
export const stack = new cdk.Stack(app, "DenoCdkStack");

new cdk.aws_logs.LogGroup(stack, "DenoCdkLogGroup");
// main.test.ts
import { assertSnapshot } from "https://deno.land/std@0.167.0/testing/snapshot.ts";
import { Template } from "npm:aws-cdk-lib/assertions";
import { stack } from "./main.ts";

Deno.test("Snapshot Test", async (t) => {
  await assertSnapshot(t, Template.fromStack(stack).toJSON());
});
$ deno task cdk synth

$ deno task test

[Edit] deno task cdk deploy does not succeed, but it looks close...

@virtuoushub
Copy link

[Edit] deno task cdk deploy does not succeed, but it looks close...

fwiw I got this to work:

...
✅  DenoCdkStack

✨  Deployment time: 31.42s

Stack ARN:
arn:aws:cloudformation:us-east-42:123456789:stack/DenoCdkStack/p0938dc0-7b50-11ed-8365-0ecc2da87269

✨  Total time: 33.75s

// deno.jsonc
...
    "deploy": "deno run --allow-all npm:aws-cdk deploy"
...

then I called it via:

deno task deploy --app cdk.out --profile foo

what worked for me was --profile foo.

Reading the default profile from ~/.aws/ was not working (even though it was configured correctly for the CLI tools to work). Setting env vars like AWS_ACCESS_KEY_ID in the environment or a .env file (loading via import "https://deno.land/std@0.167.0/dotenv/load.ts";) was also not working.

Only thing that worked was copying the default profile to something else (foo) in my case, and explicitly passing it to the cdk cli.

🤷🏻

@TheRealAmazonKendra
Copy link
Contributor

This issue should be tracked in jsii. Please note that although we do not have the bandwidth to take this on, we do accept community contributions so if anyone really wants to see this happen, feel free to start an RFC on this.

@TheRealAmazonKendra TheRealAmazonKendra transferred this issue from aws/aws-cdk Jan 27, 2023
@meije702
Copy link

This issue should be tracked in jsii. Please note that although we do not have the bandwidth to take this on, we do accept community contributions so if anyone really wants to see this happen, feel free to start an RFC on this.

Thanks for your reply and suggestion. Seeing how this thread is going I agree it should be picked up by the Deno community themselves I think. Just a check question: even though Deno supports Typescript natively you think there still should be a separate JSII implementation? What would this add over the existing one for Typescript? I am trying to wrap my head around where this would fit and how we would start on this RFC. :)

@RomainMuller
Copy link
Contributor

There are numerous aspects to this, and this issue could hide multiple things in reality... Most of the comments appear to ask for ability to natively use deno for working with CDK apps written in TypeScript. I don't reckon this requires any material changes from jsii's side, as deno has a compatibility layer that should be all that's needed... That said, there might be something to do with respects to how we are currently targeting CommonJS and not ESM. Dependency management might be another place where things may need to be done, but I'm not sure exactly how much or what.

Now - if there's a broader ask of being able to use deno instead of node as the JS runtime used by foreign interfaces (Java, C#, Go, Python, ...), then yes, this is actually touching into jsii feature land, and might hopefully be relatively easy to do (the runtimes will shell out to node but they could as well shell out to deno instead either in the absence of node, or when a specific environment variable is set).

We are currently busy on other projects, but would welcome community contributions on that front. Note however that it'd be very useful for any work in that space to bring in new integration tests run with deno right off the bat.

@guy-borderless
Copy link

note the asw-cdk package works on deno

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/large Large work item – several weeks of effort feature-request A feature should be added or improved. p2 package/tools
Projects
None yet
Development

No branches or pull requests