Hi, I have a rather newbie question, please let me...
# typescript
h
Hi, I have a rather newbie question, please let me know if there's a better place to ask this. I'm trying to find the best dev workflow to run and test certain pulumi SDK API as I'm learning about what the API does. Specifically, how can I add breakpoints to my code, and how can I just run a small code snippets against pulumi SDK easily? For example, ideally I would just like to run the following code:
Copy code
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
import * as pulumi from "@pulumi/pulumi";

const vpcId = "vpc-xxx";
const awsxVpc = new awsx.ec2.Vpc("vpc", {vpcId});
console.log(`subnets: ${await awsxVpc.publicSubnetsIds}`);
console.log(`private: ${await awsxVpc.privateSubnetIds}`);
...
// A bunch of resources generated e.g. new aws.ec2.Instance(...)
IIUC, I can only run the pulumi runtime via pulumi pre to trigger the code above and see the output because the entry point is always index.ts. For new projects this is fine as the overall resources managed is small and this is fast. However, for existing large pulumi projects, this workflow becomes very tedious and annoying because it tries to preview all the other resources that aren't changed.
b
couple things:
I can only run the pulumi runtime via pulumi pre to trigger the code above and see the output because the entry point is always index.ts.
You can use automation API to trigger deployments, but they invoke the pulumi CLI, yes
You can’t
console.log
an output, you need to do that inside an apply
h
Thanks @billowy-army-68599 for the pointer. I will have to check out automations API to see if it's useful. Here's a more recent manifest of an error that I wish there's a better way to debug
Copy code
Diagnostics:
  pulumi:pulumi:Stack (demo)
    error: Running program '...' failed with an unhandled exception:
SyntaxError: Unexpected identifier
b
ooh yeah that doesn’t look fun. Is there a repro?
h
I'm sure it's some typescript error or some misconfigured env. The point of that was to show that it's hard to do debugging when the only entry point available is through pulumi CLI. Because then it makes it difficult to debug something that is just typescript itself. Hence the original question of whether it's possible to add breakpoints.
r
This blog post covers how to achieve that in .NET and Visual Studio. I realise that’s not your stack, but it might offer some inspiration. Can you add a
debugger
statement somewhere in your program?