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
  • l

    limited-rainbow-51650

    10/27/2021, 9:17 PM
    OK, found this in the docs eventually: https://www.pulumi.com/docs/intro/concepts/resources/#explicit-provider-configuration The example for a
    ComponentResource
    , doesn't pass the
    opts
    to the child resources. It only passes it to
    super
    . I assume the correct explicit provider is used then for the child resources. But if I pass
    transformations
    in
    ComponentResourceOptions
    , are these implicitely passed to all the child resources as well?
    l
    • 2
    • 8
  • c

    clever-painter-96148

    10/27/2021, 10:25 PM
    Hi. I noticed that https://github.com/pulumi/pulumi/pull/8215 got merged and was super happy as I have that issue. So I went trying the patch, but now, I end up with another issue:
    Error: failed to register new resource createTeam [aws:lambda/function:Function]: 2 UNKNOWN: failed to compute asset hash for "node_modules/@theboxescapegame/dhvg-core-types": asset path 'node_modules/@theboxescapegame/dhvg-core-types' is a directory; try using an archive
    (It's an in-house package in our monorepo). Any clue? Cc @prehistoric-kite-30979
    p
    r
    • 3
    • 19
  • e

    elegant-crayon-4967

    10/28/2021, 3:39 PM
    question for the brain trust…I have an SSM Automation Doc. I create the raw yaml, and use handlebars package to inject params from my other pulumi resources. Always worked well until today when I need to use the same convention
    {{ assumeRole }}
    that handlebars uses for automation doc itself to pass variables back and forth. AKA, I can’t figure out how to escape the double braces to have the literal string
    {{ assumerole }}
    without it becoming null because handlebars is reading it. I’ve tried many different escape methods using
    \
    but nothing works. When the template makes it up to AWS all the fields I’ve tried to escape are null
    c
    • 2
    • 5
  • l

    little-cartoon-10569

    10/28/2021, 8:26 PM
    Does any know of a way to easily get the line number of a file as seen in a stack trace? I presume it skips over comments, imports, things like that. My current stack trace is complaining about line 16, but that's a comment in my file.
  • a

    astonishing-afternoon-15745

    11/01/2021, 8:17 PM
    I'm trying to create a TS package as a POC to demonstrate the possibility to split up codebase ownership ( platform team controls the cluster config, application team controls the cluster ). Does anyone have any goed examples for me to look at?
    b
    • 2
    • 2
  • l

    limited-rainbow-51650

    11/02/2021, 11:10 AM
    For unit testing with Mocha, do I explicitly have to use
    pulumi.all(...).apply(callbackFn)
    , or can I also use
    someOutput.apply(callbackFn)
    ?
    l
    • 2
    • 7
  • c

    clever-painter-96148

    11/02/2021, 2:36 PM
    I use Pulumi in a Yarn 3 monorepo. Pulumi doesn't like yarn's package hoisting, so I need to add this to the pulumi program's package.json:
    "installConfig": {"hoistingLimits": "workspace"}
    Not super happy with it as we have dozen of other packages in the monorepo and disabling hoisting make us pay some penalty (mostly longer CI builds and bigger FS usage for node_modules). Yarn 3 has a new feature that replaces node_modules directories completely: https://yarnpkg.com/features/pnp It's amazingly fast! We do not even need to run "yarn install" anymore (cf https://yarnpkg.com/features/zero-installs) To use it, I need to do this before running the Pulumi program:
    require('./.pnp.cjs').setup();
    However, I cannot find a way to do this in a TypeScript program. Guess I should configure TS to allow importing .cjs files and import it using an import statement in the TS file? What about native support for Yarn's PnP in Pulumi? Would you accept such a PR? If so, is this the right place: https://github.com/pulumi/pulumi/blob/master/sdk/nodejs/cmd/run/run.ts#L247 ?
    l
    p
    • 3
    • 4
  • c

    clever-painter-96148

    11/02/2021, 10:23 PM
    When using a ComponentResource in TypeScript, how am I supposed to access outputs registered with https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/#ComponentResource-registerOutputs ? I understand that I call registerOutputs() at runtime and that cannot affect the ComponentResource typing. Are the outputs available despite the lack of typing?
    b
    • 2
    • 5
  • m

    mysterious-wolf-74677

    11/04/2021, 9:01 PM
    So like, using the
    Pulumi Import Resource Operation
    (found here) do we have to include the
    {name: <resource name>}
    in the
    args
    ? Doesn't
    {import: <resource name>}
    take care of that? So you can just do something like
    const foo = new aws.iam.User('foo', {}, { import: 'foo' })
    l
    • 2
    • 5
  • m

    mysterious-wolf-74677

    11/04/2021, 9:01 PM
    it only worked when I had code as:
    const foo = new aws.iam.User('foo', {name: 'foo'}, { import: 'foo' })
    l
    • 2
    • 1
  • e

    echoing-actor-55539

    11/04/2021, 10:20 PM
    does anybody have a recipe for using apiKeyRequired on a route with an aws websocket api-gateway? i dont see any way to setup a usage plan or specify the key
    l
    • 2
    • 2
  • l

    little-whale-73288

    11/05/2021, 3:03 PM
    Hello, I am trying to set tags of an
    aws.lb.ListenerRule
    to the ones set on an
    aws.lb.TargetGroup
    like:
    new aws.lb.ListenerRule(name, {[...], tags: tg.tags})
    but I am getting:
    error TS2322: Type 'Output<{ [key: string]: string; } | undefined>' is not assignable to type 'Input<{ [key: string]: Input<string>; }> | undefined'.
      Type 'OutputInstance<{ [key: string]: string; } | undefined>' is not assignable to type 'Input<{ [key: string]: Input<string>; }> | undefined'.
        Type 'OutputInstance<{ [key: string]: string; } | undefined>' is not assignable to type 'OutputInstance<{ [key: string]: Input<string>; }>'.
          Type '{ [key: string]: string; } | undefined' is not assignable to type '{ [key: string]: Input<string>; }'.
            Type 'undefined' is not assignable to type '{ [key: string]: Input<string>; }'.
    am I missing something obvious or should this just work?
    w
    l
    • 3
    • 12
  • o

    orange-kite-80991

    11/07/2021, 5:29 PM
    Newbie Q: What syntax do I need to load all my Pulumi Config key-value pairs? ... edit ... After a pile of noise, you can load Config as a KV map using
    pulumi.runtime.allConfig()
    The following doesn't work:
    const config = new pulumi.Config()
    const all_envs_str = "'" + 
      Object.entries(config).map(([key, value]) => `${key}=${value}`).join('\n') + "'"
    
    Result:
    name=my_project_name
    BTW my overall objective is sending all the Config key-values, including secrets to Docker. If there's a less hacky way to do this I'm all ears.
    l
    • 2
    • 4
  • o

    orange-kite-80991

    11/08/2021, 12:10 AM
    I'm looking for a data+code structure to read Pulumi Config data without declaring every individual name in code. It seems using --path gets close but all the examples show explicit named fields. My next attempt will be using --path to define an array of [name, value] pairs. regarding Config --path Anyone found a trick for reading all pulumi config data without naming each field in code? ... edit: the trick is to use
    pulumi.runtime.allConfig()
    l
    • 2
    • 11
  • s

    sparse-intern-71089

    11/08/2021, 7:20 PM
    This message was deleted.
    l
    c
    • 3
    • 2
  • l

    limited-rainbow-51650

    11/09/2021, 4:30 PM
    I have a transformation function which extends the
    env
    section of a k8s
    Deployment
    . The value of one of the env variables, set by the transformation function, is an Output. I now want to test that the function added the right key-value pairs. Anyone have an example handy on how to unit test such a transformation function? I struggle again with the async behaviour of Inputs & Outputs.
    l
    • 2
    • 2
  • f

    fast-easter-23401

    11/10/2021, 6:07 PM
    Hi everybody, I wonder if there's a way to spawn a child process from my index.ts. We're using GCP and the cloud_sql_proxy binary to ensure encryption when communicating with our databases. So I need the proxy to be listening locally in order to use the MySQL provider to grant users permissions. The MySQLProvider points to 127.0.0.1:3306, and the proxy is responsible for forwarding communication to the actual instance. Unfortunately, using another authentication method is as of today impossible, so I'm afraid I'm stuck with the proxy. I wish to resolve this in a way that doesn't require orchestration through bash scripts. Any ideas? Thank you for your time.
    m
    • 2
    • 1
  • w

    witty-monitor-18849

    11/10/2021, 6:42 PM
    Hi, Apologies if answered before but how would I go about merging/concating two promise output instance arrays? i.e.
    const ids: Promise<pulumi.Output<string>[]>
    const otherIds: Promise<pulumi.Output<string>[]>
    
    ids.concat(otherIds)
    I've tried with
    then
    and also
    apply
    like;
    pulumi.output(ids).apply()
    etc... To no avail. Any help would be greatly appreciated. 🙏
    l
    • 2
    • 7
  • o

    orange-kite-80991

    11/11/2021, 8:15 PM
    How do I create/update a resource without a unique suffix? I want to create a DNS A-record for my external URL. If the IP changes I want to either update or regen the record. Eg. create myarecord so that myarecord.myservice.com is a working URL. By default Pulumi created myarecord230ed05.
    l
    • 2
    • 3
  • o

    orange-kite-80991

    11/12/2021, 5:39 AM
    I'm trying to access a deeply nested resource value. Specifically, the ingressNginx LoadBalancer IP. Structure is shown below. Suggestions on the proper syntactic magic to get there? Or an alternate means to acquire this info?
    - ingressNginx : {
          - resources: {
              - v1/Service::infra-92vjemsb/ingress-nginx-controller                                    : {
                  - apiVersion: "v1"
                  - id        : "infra-92vjemsb/ingress-nginx-controller"
                  - kind      : "Service"
                  - status    : {
                      - loadBalancer: {
                          - ingress: [
                          -     [0]: {
                                  - ip: "20.112.55.186"
                            } ]
        }   }   }   }   }
    h
    • 2
    • 1
  • p

    prehistoric-kite-30979

    11/12/2021, 12:54 PM
    Hi all is there an easy was to convert
    Output<Object<string>>
    to
    Object<Input<string>>
    without having to explicitly list all the fields?
    h
    • 2
    • 12
  • m

    magnificent-lifeguard-15082

    11/12/2021, 3:05 PM
    Bit of a basic question I think. How do I access registered outputs of a component after constructing it? I have registerOutputs called at the end of my custom component constructor. There does not seem to be a
    getOutput
    or any getter for that matter, on the component type?
    m
    • 2
    • 7
  • p

    prehistoric-kite-30979

    11/12/2021, 9:49 PM
    Just trying to follow along with this module based unit testing example and Im getting:
    Error: Program run without the Pulumi engine available; re-run using the `pulumi` CLI
    I think this is because the function I’m testing instantiates a provider?
    s
    l
    • 3
    • 12
  • b

    busy-magazine-6225

    11/13/2021, 7:31 PM
    I have a problem where I want to create new subnets but some already exist, and I need them to be deleted before the create happens otherwise they will conflict. I found deleteBeforeReplace but don’t think that solves my issue. Is there any way to make delete actions happen on a resource before any creates happen?
    l
    • 2
    • 10
  • m

    miniature-king-36473

    11/15/2021, 2:13 PM
    I went down a bit of a rabbit hole investigating Pulumi Function Serialisation. I have written it up here - https://mark.smithson.me/pulumi-function-serialisation-by-example. I hope it is useful, and would love any feedback or corrections.
    ❤️ 2
    b
    • 2
    • 1
  • l

    little-cartoon-10569

    11/16/2021, 5:00 AM
    I'm having issues with try/catch in Output.. or maybe the AWS SDK. Or both. Apologies if posting in wrong place. This is to do with
    aws.identitystore.getGroup()
    .
    • 1
    • 6
  • r

    rough-hydrogen-27449

    11/16/2021, 4:15 PM
    Hi, I'm trying to get a little bit better understanding of how dynamic providers work. I noticed the following behavior and I'd like to develop a clear explanation for it. I have created a
    Cluster
    resource representing a Kafka cluster in Confluent Cloud:
    class Cluster extends pulumi.dynamic.Resource {
        public readonly endpoint!: pulumi.Output<string>;
    
        constructor(
            name: string,
            props: IClusterInputs,
            opts?: pulumi.CustomResourceOptions,
        ) {
            super(new ClusterProvider(), name, props, opts);
        }
    }
    and I've written a dynamic provider for this resource:
    class ClusterProvider implements pulumi.dynamic.ResourceProvider {
        async create(
            inputs: IClusterProviderInputs
        ): Promise<pulumi.dynamic.CreateResult> {
            const cmd = `kafka cluster create ${inputs.clusterName}`
                + ` --cloud aws`
                + ` --region ${inputs.region}`
                + ` --availability ${inputs.availability}`
                + ` --type ${inputs.clusterType}`
                + ` --environment ${inputs.environmentId}`;
            const result: IClusterCreateResult = await runConfluentCliCommand(cmd, true);
            return {
                id: result.id,
                outs: { // implements IClusterCreateOutputs
                    endpoint: result.endpoint,
                    environmentId: inputs.environmentId,
                },
            };
        }
    
        async update(
            _id: string,
            olds: IClusterProviderInputs,
            _news: IClusterProviderInputs
        ): Promise<pulumi.dynamic.UpdateResult> {
            return {outs: olds}; // FIXME: implement a real update method
        }
    
        async delete(
            id: string,
            props: IClusterCreateOutputs
        ): Promise<void> {
            const cmd = `kafka cluster delete ${id} --environment ${props.environmentId}`;
            return await runConfluentCliCommand(cmd, false);
        }
    }
    Then I construct a
    Cluster
    instance and
    export
    an object as a stack output:
    const cluster = new Cluster("MyCluster", { ... });
    
    export let stackOutputs = {
        cluster_id: cluster.id,
        cluster_endpoint: cluster.endpoint,
    };
    When I spin up this stack and look at the stack outputs, the
    cluster_id
    is present but the
    cluster_endpoint
    is absent. I was able to determine that the
    cluster.endpoint
    value was
    undefined
    . To "fix" this, I did the following:
    export let stackOutputs = {
        cluster_id: cluster.id,
        cluster_endpoint: pulumi.output(cluster.endpoint),
    };
    Now the
    cluster_endpoint
    shows up in my stack outputs!
    Actually I'm not so sure... So, my question is: Why did wrapping this dynamic resource class member reference in a
    pulumi.output(..)
    cause it to be reified to a non
    undefined
    value? What is actually going on here? A corollary question: Why did I not have to also do this for the
    id
    ? EDIT: I was a little confused, actually. My
    pulumi.output(..)
    edit did not, in fact, cause anything to show up in the stack output. The correct fix was to "initialize" the
    endpoint
    with an
    undefined
    in the call to
    super(..)
    in the
    Cluster
    constructor (see thread).
    m
    • 2
    • 9
  • r

    refined-terabyte-65361

    11/17/2021, 12:26 AM
    Hello i am stuck with below error
    could not read plugin [/home/ssm-user/.pulumi/plugins/resource-eks-v0.34.0/pulumi-resource-eks] stdout: EOF
    i tried npm install but dint help how to fix this ?
    b
    • 2
    • 3
  • m

    magnificent-lifeguard-15082

    11/17/2021, 8:45 PM
    Wandering through the source code for pulumi to better understand how I may create some custom component resources which can be used fairly opaquely in both application code and deployment code. For example just like how
    pulumi.cloud.Table()
    will register and deploy resources when run with the cli but is also used as a reference for
    table.get()
    in a serverless function. This is a holy grail and looking forward to seeing more of this from pulumi! My question though is around how would pulumi optimise the bundling of functions to not include all of the deployment runtime & engine? I'm wondering if the module level
    deploymentOnlyModule
    export has anything to do with it and wondering how I would optimise similar code/components in user land? For additional context I have a separate process for bundling and do not want to rely on pulumi inline handlers as they may also be other runtimes (ie. not typescript->nodejs)
    m
    • 2
    • 3
  • p

    purple-application-23904

    11/17/2021, 9:15 PM
    Is there a way to output besides
    export
    ? I've got helper functions to help wrap some common group of resources, but by only using
    export
    I can't programmatically export parts of those resources. The other languages seem to have this (eg. python has
    pulumi.export(name, value)
    )
    b
    o
    • 3
    • 9
Powered by Linen
Title
p

purple-application-23904

11/17/2021, 9:15 PM
Is there a way to output besides
export
? I've got helper functions to help wrap some common group of resources, but by only using
export
I can't programmatically export parts of those resources. The other languages seem to have this (eg. python has
pulumi.export(name, value)
)
b

billowy-army-68599

11/17/2021, 9:32 PM
export const
will do the same thing
p

purple-application-23904

11/17/2021, 9:36 PM
If I had a
Map<string, pulumi.Output<any>>
could I export that?
I'd prefer it to be top-level, but nesting it with some generic name would suffice I suppose (eg
export const vars = output
)
b

billowy-army-68599

11/17/2021, 9:38 PM
yep that should work, you can export any constant, basically
p

purple-application-23904

11/18/2021, 6:08 PM
Hm, this didn't seem to work, it's not displaying the map's variables (it didn't display the exported
vars
at all)
o

orange-kite-80991

11/21/2021, 7:37 AM
For better or worse, Pulumi will accept vars = undefined and then happily not log any undefined values to the console.
p

purple-application-23904

11/22/2021, 5:25 PM
The map isn't undefined, if I
console.log
the value I can see the values, but at the end there's no output.
Not that this is that complicated, but just to be explicit, I'm doing something like this:
const cloudLib = new ...

cloudLib.createWebsocketGateway(...)

export const vars = cloudLib.outputs
console.log("vars", vars)
where outputs is
outputs: Map<string, pulumi.Output<any>> = new Map();
FWIW, to circle back on this - the following did work:
export const vars = Array.from(cloudLib.outputs).reduce((obj, [key, value]) => (
  Object.assign(obj, { [key]: value })
), {});
So it looks like it just doesn't like
Map
but
object
is okay
View count: 1