Are there any plans to update the built-in typescr...
# typescript
l
Are there any plans to update the built-in typescript support?
According to https://www.pulumi.com/docs/intro/languages/javascript/#disabling-built-in-typescript-support we're stuck with target: es6 and module: commonjs for now.
I'd quite like top-level await, to help deal with the dreaded awsx.ec2.Vpc -> subnets issue.
But that requires target: es2017 and module: esnext.
b
could you please provide more information about the subnets issue?
l
It's impossible to export a subnetId from a stack, if you're starting from a vpcId.
awsx.ec2.Vpc.fromExistingIds()
gives double-wrapped subnet ids, and there's no way (afaik) to make one of those subnet IDs available to a top-level
export
.
Right now I'm dealing with needing an array of all private subnet IDs, and a single subnet ID, in the same block of code. I've gone back and forth countless times. I can't see how to do it, short of hardcoding a subnet ID in my config file.
I've even resorted to the rather-nasty
Copy code
declare module '@pulumi/pulumi' {
  export interface OutputInstance<T> {
    promise(withUnknowns?: boolean): Promise<T>;
  }
}
but that introduces all sorts of issues when pulumi.Input is used in the same file, because Outputs start auto-converting themselves to Promises...
b
thank you
I use awsx.Vpc in one of my stacks and there are subnetIds in stack outputs, but maybe our use cases are quite different
not sure what does that mean > if you're starting from a vpcId
l
I have a vpcId, imported from another stack. I want to pass a
pulumi.Input<pulumi.Input<string>[]>
of subnet IDs to the constructor of aws.alb.LoadBalancer, and I want to pass a
pulumi.Input<string>
to the constructor of aws.ec2.Instance. I don't want to call any constructors inside a then or apply, as per Pulumi recommendations. How do I do this?
b
ah, it's imported, got it
could you also export subnetids in the same imported stack?
l
Same problem though. At a single level, I can unwrap once, or I can unwrap twice, but not both. At least, not without repeating a significant chunk of code, verbosely and inelegantly.
Right now, I'm getting the
pulumi.Input<pulumi.Input<string>[]>
array of private subnet IDs from the VPC, and I'm passing the
pulumi.Input<string>
as a config parameter to the stack. This makes for the cleanest code, with no duplication. I'd like to improve that, because I could just pick a random subnet ID from that array.. but I haven't been able to find a way to do it.
b
what I do: I export a vpc id and the associated networks ids in a stack which uses awsx.Vpc and use these values in other stacks, I don't seem to remember any code duplication related to that but probably I do not fully understand your problem, so I can't help you further
so here is a simplified output example
Copy code
vpcs   : {
                eu-central-1: [
                    [0]: {
                        id            : "vpc-xxx"
                        name          : "main"
                        subnetIds       : [
                            [0]: "subnet-xxx"
                            [1]: "subnet-yyy"
                            [2]: "subnet-zzz"
                        ]
                    }
                ]
            }
p
@bored-river-53178 what does your import look like?