https://pulumi.com logo
Join the conversationJoin Slack
Channels
announcements
automation-api
aws
azure
blog-posts
built-with-pulumi
cloudengineering
cloudengineering-support
content-share
contribex
contribute
docs
dotnet
finops
general
getting-started
gitlab
golang
google-cloud
hackathon-03-19-2020
hacktoberfest
install
java
jobs
kubernetes
learn-pulumi-events
linen
localstack
multi-language-hackathon
office-hours
oracle-cloud-infrastructure
plugin-framework
pulumi-cdk
pulumi-crosscode
pulumi-deployments
pulumi-kubernetes-operator
pulumi-service
pulumiverse
python
registry
status
testingtesting123
testingtesting321
typescript
welcome
workshops
yaml
Powered by Linen
typescript
  • s

    salmon-ghost-86211

    03/24/2021, 4:15 PM
    I have to say that sometimes getting to a pulumi output value and passing it to other things can be maddening. I am retrieving all of the usernames from an AWS IAM group to use in other places.
    const iamGroup = pulumi.output(aws.iam.getGroup({
        groupName: "myGroup",
    }, { async: true }));
    
    const usernames = iamGroup.apply(group => group.users.map(user => user.userName));
    If I
    export
    const usernames, I see
    Outputs:
        usernames: [
            [0]: "username1"
            [1]: "username2"
            [2]: "username3"
        ]
    However, later when attempting to use both
    .filter
    and
    .map
    on the
    usernames
    list, I get
    TSError: ⨯ Unable to compile TypeScript:
        index.ts(312,13): error TS2488: Type 'Output<string[]>' must have a '[Symbol.iterator]()' method that returns an iterator.
        index.ts(469,42): error TS2339: Property 'map' does not exist on type 'Output<string[]>'.
    I have tried many variations of
    .apply
    but am so far unable to use the above methods or return this list from the function it is in. I have read the Inputs and Outputs doc many times but it is still painful to figure out how to make it work.
    w
    • 2
    • 3
  • m

    microscopic-dress-1605

    03/24/2021, 5:22 PM
    I’ve created a reusable Nodejs package
    aws-resource
    for creating AWS resources. The package
    aws-resource
    is used inside a Pulumi stack. When I execute the unit tests of the Pulumi stack, it complains with ‘_Error: Program run without the Pulumi engine available; re-run using the
    pulumi
    CLI_’. Although the unit tests of the stack contain the mocking code for Pulumi resources.
    pulumi.runtime.setMocks({
      newResource: function(...) { ... }
    });
    I guess the pulumi API calls inside the Nodejs package
    aws-resource
    don’t get mocked. What should I do to also have the resources created by the package
    aws-resource
    mocked?
    l
    • 2
    • 9
  • b

    better-shampoo-48884

    03/27/2021, 12:07 PM
    What's the prefered method of running typescript in node nowadays? and is there any difference? Docs state ts-node and tsc variants - any thoughts?
  • b

    better-shampoo-48884

    03/27/2021, 12:10 PM
    ...and what does pulumi use internally? 😉
    d
    • 2
    • 2
  • m

    mysterious-wolf-74677

    03/30/2021, 3:31 PM
    Is there a way to use
    pulumi import
    without updating state possibly?
    b
    b
    • 3
    • 8
  • l

    little-cartoon-10569

    03/30/2021, 10:06 PM
    Has anyone got a functional launch.json or similar, to get debugging working with Pulumi?
    a
    l
    • 3
    • 6
  • g

    gifted-island-55702

    04/02/2021, 10:18 AM
    Hi! I have a Typescript newbie question about Pulumi outputs and promises. I would expect the following to work but I'm getting a type error:
    const promise = new Promise<Map<string, string>>((resolve, reject) => new Map<string, string>());
    const output: pulumi.Output<Map<string, string>> = pulumi.output(promise);
    as it fails with:
    TS2322: Type 'Output<UnwrappedObject<Map<string, string>>>' is not assignable to type 'Output<Map<string, string>>'.   Type 'Output<UnwrappedObject<Map<string, string>>>' is not assignable to type 'OutputInstance<Map<string, string>>'.     Types of property 'apply' are incompatible.       Type '{ <U>(func: (t: UnwrappedObject<Map<string, string>>) => Promise<U>): Output<U>; <U>(func: (t: UnwrappedObject<Map<string, string>>) => OutputInstance<...>): Output<...>; <U>(func: (t: UnwrappedObject<...>) => U): Output<...>; }' is not assignable to type '{ <U>(func: (t: Map<string, string>) => Promise<U>): Output<U>; <U>(func: (t: Map<string, string>) => OutputInstance<U>): Output<U>; <U>(func: (t: Map<...>) => U): Output<...>; }'.         Types of parameters 'func' and 'func' are incompatible.           Types of parameters 't' and 't' are incompatible.             Type 'UnwrappedObject<Map<string, string>>' is missing the following properties from type 'Map<string, string>': [Symbol.iterator], [Symbol.toStringTag]
    Am I missing something? I thought that I can "repackage" whatever I have in the promise object into an output object.
    l
    • 2
    • 5
  • g

    gifted-island-55702

    04/09/2021, 12:01 PM
    Hi! I'm using aws sdk for secrets manager and I'm getting issue like this: https://github.com/aws/aws-sdk-js-v3/issues/1919
  • g

    gifted-island-55702

    04/09/2021, 12:01 PM
    Is there any way to use TypeScript 4.x with Pulumi?
    b
    • 2
    • 7
  • a

    acceptable-army-69872

    04/09/2021, 8:59 PM
    I noticed typescript aws.ec2.wafv2 has no examples, which I think means that it's not gotten a lot of qa and love. Other than that, should I expect it to work? it is not a hot button issue in the issues tracker
    is:issue waf is:closed
    is 1 issue.
    b
    • 2
    • 2
  • m

    mysterious-oyster-86659

    04/12/2021, 5:01 PM
    Hi Everyone😃 Our stack is currently written with TypeScript (TS) and have implemented Airflow in AWS. Now, we need to dynamically reference TS resources in Python and have no idea how to do that in manageable way (without just hard-coding them). Is there a way to do this?
    c
    • 2
    • 2
  • s

    stocky-address-37940

    04/12/2021, 6:52 PM
    Made a small PR against one of the example repositories to help with an issue presented here: https://pulumi-community.slack.com/archives/C84L4E3N1/p1618199806445700
  • s

    stocky-address-37940

    04/12/2021, 6:52 PM
    https://github.com/pulumi/examples/pull/962
  • p

    purple-train-14007

    04/13/2021, 9:47 PM
    Dear typescript, please let me be lazy I dont wanna type the full word boolean instead of the short form bool. Please stop making me a better dev I dont wanna.
    l
    • 2
    • 4
  • p

    purple-train-14007

    04/13/2021, 10:26 PM
    Does anyone know how I can extract subnetId from my network I am instantiating? There is a resource Azure AD Domain Services which requires a subnetId to be passed to it. https://www.pulumi.com/docs/reference/pkg/azure-native/aad/domainservice/
    • 1
    • 2
  • a

    alert-oyster-87530

    04/13/2021, 11:36 PM
    Hello! I'm new to Pulumi and trying to follow this tutorial for a JS setup. Is this the right spot to ask some questions? https://www.pulumi.com/docs/guides/testing/integration/
    l
    • 2
    • 6
  • p

    purple-train-14007

    04/14/2021, 1:41 AM
    Alright, I tried. I dont seem to understand how to output this subnetsId. If someone can help point me in the right direction, I would greatly appreciate it. here is my code so far.
    g
    • 2
    • 8
  • p

    purple-train-14007

    04/14/2021, 1:41 AM
    Untitled
  • p

    prehistoric-ocean-52185

    04/14/2021, 5:27 AM
    What's the best way to decrypt pulumi secret?
    l
    • 2
    • 1
  • c

    cuddly-dusk-95227

    04/14/2021, 11:36 AM
    does pulumi offer any functions to generate kubeconfig's ? I have an existing kubernetes cluster, and I want to try and connect to it using pulumi + typescript, the provider can accept a kubeconfig (https://www.pulumi.com/docs/reference/pkg/kubernetes/provider/) which is easy if i'd created the cluster using
    pulumi-eks
    . what am I missing?
    b
    • 2
    • 3
  • p

    purple-train-14007

    04/15/2021, 6:05 PM
    So I have some Subnets built and a SecurityGroup. I dont see anywhere in the docs for NSG stating how you go about attaching this to a subnet. Here is my code so far
    const USNetWork = new azure_native.network.VirtualNetwork(usNetName, {
        resourceGroupName: RG,
        location: "WestUS",
        virtualNetworkName: usNetName,
        addressSpace: {
            addressPrefixes: [usAddr],
        },
    
    });
    
    const domainSubnetUSA = new azure_native.network.Subnet(usADDSSubnetName, {
        resourceGroupName: RG,
        subnetName: usADDSSubnetName,
        virtualNetworkName: USNetWork.name,
        addressPrefix: usADDSSubnetaddr,
      });
    
      const meshSubnetUSA = new azure_native.network.Subnet(usMESHSubnetName, {
        resourceGroupName: RG,
        subnetName: usMESHSubnetName,
        virtualNetworkName: USNetWork.name,
        addressPrefix: usMESHSubnetaddr,
      });
    
      const InboundSGUSA = new azure_native.network.NetworkSecurityGroup("InboundSG", {
        location: "WestUS",
        networkSecurityGroupName: "Test",
        resourceGroupName: RG,
        securityRules: [allowPSRM,allowRDP],
    });
    l
    c
    • 3
    • 7
  • w

    worried-queen-62794

    04/18/2021, 9:41 AM
    OutputInstance
    defines these:
    apply<U>(func: (t: T) => Promise<U>): Output<U>;
        apply<U>(func: (t: T) => OutputInstance<U>): Output<U>;
        apply<U>(func: (t: T) => U): Output<U>;
    Shouldn't they be?
    apply<U>(func: (t: T) => Promise<U> | OutputInstance<U> | U): Output<U>;
    Otherwise if
    func
    is something like
    string => number | Promise<number>
    then it returns
    Output<number | Promise<number>>
    rather than
    Output<number>
    . Unless that was intentional?
  • m

    melodic-easter-82419

    04/20/2021, 7:35 PM
    Is there any update on pulumi supporting yarn 2?
    l
    • 2
    • 1
  • m

    melodic-easter-82419

    04/20/2021, 8:38 PM
    I was also curious, why are there so many variations for types? I seems to really slow down vscode.
    l
    r
    l
    • 4
    • 12
  • c

    colossal-australia-65039

    04/20/2021, 11:20 PM
    After upgrading to pulumi v3.0.0 and upgrading all my pulumi npm packages, I am seeing this. I've never had to install a plugin manually before. Anyone know why I'm getting this?
    $ pulumi up
    Previewing update (eks-dev):
    [resource plugin kubernetes-2.8.2] installing
    Downloading plugin: 0 B / 28.83 MiB [----------------------------------]   0.00%[resource plugin aws-3.31.0] installing
    Downloading plugin: 28.83 MiB / 28.83 MiB [=========================] 100.00% 2s
    Downloading plugin: 74.84 MiB / 74.84 MiB [=========================] 100.00% 4s
         Type                     Name                    Plan     Info
         pulumi:pulumi:Stack      infrastructure-eks-dev           
         └─ pulumi:providers:eks  default                          1 error
     
    Diagnostics:
      pulumi:providers:eks (default):
        error: no resource plugin 'eks' found in the workspace or on your $PATH
    b
    • 2
    • 4
  • e

    elegant-pager-5412

    04/22/2021, 5:11 AM
    Hey Guys! If I’m using TypeScript with Pulumi, what is the latest 
    target
     I can use? Currently the default seems to be 
    es2016
    . Is there any reason why won’t I bump it to 
    es2020
    ? Also, as for the 
    module
     definition, can I use 
    ES2020
     or 
    ESNext
    ?
    l
    b
    • 3
    • 17
  • e

    elegant-pager-5412

    04/22/2021, 5:41 AM
    What are the best practices for TS Pulumi app structure?
  • l

    little-cartoon-10569

    04/27/2021, 12:38 AM
    Has anyone written unit tests that include the bundling of async code for things like Lambdas? I'm trying to find a way around https://github.com/pulumi/pulumi/issues/5832 but I'm continually hitting
    unhandled rejection: CONTEXT(3262): transferDeps( ...
    c
    • 2
    • 5
  • e

    elegant-pager-5412

    04/28/2021, 9:28 AM
    Why can’t we use
    target: "es2020"
    in our
    tsconfig.json
    file? Why are we locked to
    es2016
    ?
  • e

    elegant-pager-5412

    04/28/2021, 9:32 AM
    Or rather, how can I use
    target: "es2020"
    and compile the project myself, piping the output JS to Pulumi?
    b
    l
    • 3
    • 21
Powered by Linen
Title
e

elegant-pager-5412

04/28/2021, 9:32 AM
Or rather, how can I use
target: "es2020"
and compile the project myself, piping the output JS to Pulumi?
b

billowy-army-68599

04/28/2021, 2:50 PM
pulumi uses ts-node to automatically run `tsc`: https://github.com/TypeStrong/ts-node if you want to compile the JS yourself, you can set the following in your
Pulumi.yaml
options
  typescript: false
https://www.pulumi.com/docs/reference/pulumi-yaml/
l

lemon-monkey-228

04/28/2021, 3:25 PM
How do we then leverage this to deploy/
Manually compile and
pulumi up
?
name: creatio-sync
description: Creatio Sync
runtime: nodejs
options:
  typescript: false
is my
Pulumi.yaml
If I run
npx tsc index.ts
it compiles the
index.js
But
pulumi up
still seems to be trying to use it
Do I need a change in my
package.json
or something too?
Either the options changed recently or I’m stupid, but it’s now
runtime:
  name: nodejs
  options:
    typescript: false
but still no dice
b

billowy-army-68599

04/28/2021, 3:33 PM
when you say
pulumi up
seems to be trying to use it, do you mean your index.ts ?
e

elegant-pager-5412

04/28/2021, 3:41 PM
I managed to get it working, but it is not that straight forward. my
tsconfig.json
specifies that the output dir should be
dist
which is ignored in
.gitignore
. Then I needed to tell Pulumi to use the JS file, which we can do so by adding the
main
property to the
package.json
. The thing is that unless we use
amd
as the
module
definition in
tsconfig
, TSC cannot combine all files into a single
index.js
file. To solve this, I did some bash magic and created the following command:
"scripts": {
    "deploy": "tsc && sed -i '' \"s#\\\"main\\\": \\\".*,#\\\"main\\\": \\\"$(find dist -name 'index.js' -print -maxdepth 3 -quit)\\\",#\" package.json && pulumi up"
  },
l

lemon-monkey-228

04/28/2021, 3:41 PM
sorry, yeah, and I’m assuming it is
e

elegant-pager-5412

04/28/2021, 3:41 PM
This works for me, I guess the script should be slightly modified for others
my `tsconfig.json`:
{
  "compilerOptions": {
    "strict": true,
    "outDir": "dist",
    "target": "es2020",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "pretty": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitReturns": true,
    "strictNullChecks": true,
    "noImplicitAny": true,
    "noImplicitThis": true,
    "alwaysStrict": true,
    "strictPropertyInitialization": false,
    "forceConsistentCasingInFileNames": true,
    "removeComments": true
  }
}
l

lemon-monkey-228

04/28/2021, 3:46 PM
My exact issue is
Diagnostics:
  pulumi:pulumi:Stack (creatio-sync-production):
    error: Running program '/Users/james/projects/creatio/creatio-sync/deploy' failed with an unhandled exception:
    /Users/james/projects/creatio/creatio-sync/deploy/node_modules/@devops/pulumi-utils/index.ts:1
    import * as fs from 'fs'
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module
I’d have thought it’d blown up at
npx tsc
if the settings were till wrong (feel free to correct me if I’m wrong)
e

elegant-pager-5412

04/28/2021, 3:51 PM
Try setting the module to “commonjs”
l

lemon-monkey-228

04/28/2021, 4:38 PM
{
  "compilerOptions": {
    "strict": true,
    "outDir": "bin",
    "target": "es2020",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "pretty": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitReturns": true,
    "forceConsistentCasingInFileNames": true
  }
}
{
  "name": "creatio-sync",
  "main": "bin/index.js",
  "devDependencies": {
    "@types/node": "^10.0.0"
  },
  "dependencies": {
    "@devops/pulumi-utils": "^0.1.2",
    "@pulumi/kubernetes": "^2.0.0",
    "@pulumi/kubernetesx": "^0.1.1",
    "@pulumi/pulumi": "^2.0.0"
  }
}
It's a dependency that's causing the issue
feels like I need to cascade the
tsc
call to the library too
Fixed the issue. Turns out my inexperience with TS meant I was packaging a helper as TS and not the transpiled JS
View count: 1