https://pulumi.com logo
Docs
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
  • m

    many-yak-61188

    02/02/2022, 8:51 PM
    hello 👋 quick question - we use the crosswalk apit to set up a ALB with a target group, listner and fargate service as
    const lbx = new awsx.lb.ApplicationLoadBalancer(`api-lb-${stack}`, {
      vpc: vpc,
      subnets: vpc.publicSubnetIds,
      securityGroups: [lbSecurityGroup],
    });
    
    const apiTgx = new awsx.lb.ApplicationTargetGroup(`api-tg-${stack}`, {
      vpc: vpc,
      port: 80,
      protocol: 'HTTP',
      healthCheck: {
        path: '/healthcheck',
      },
    });
    
    const listener = lbx.createListener(`api-web-${stack}`, {
      protocol: 'HTTPS',
      targetGroup: apiTgx,
      vpc: vpc,
      certificateArn,
    });
    I'd like to add an additional TG and fargate cluster and do path based routing as described here https://docs.aws.amazon.com/elasticloadbalancing/latest/application/tutorial-application-load-balancer-cli.html#path-based-routing-aws-cli Can someone point me to an example / docs on how to do this please? Much appreciated 🙏
    l
    • 2
    • 10
  • d

    damp-byte-39631

    02/03/2022, 2:02 AM
    Hey everyone, moving from AWS CDK to Pulumi and I've been having trouble trying to replicate the ApplicationLoadBalancedFargateService construct from the CDK. The biggest problem is the ports. I'd prefer to do this the "correct" way using awsx, but all of the examples from the docs rely on the container port being 80. How can I specify a different port?
    const lb = new awsx.lb.ApplicationListener("nginx", { port: 80 });
    const nginx = new awsx.ecs.FargateService("nginx", {
        taskDefinitionArgs: {
            containers: {
                nginx: {
                    image: "nginx",
                    memory: 128,
                    portMappings: [ lb ], // I'd like to specify a different
                                          // container port here
                },
            },
        },
        desiredCount: 2,
    });
    c
    • 2
    • 9
  • w

    witty-park-12681

    02/03/2022, 8:40 PM
    Howdy everyone, I'm trying to determine if an issue I have is a bug within the typescript packages of Pulumi, I notice some inconstancy between
    RDS
    and
    Elasticache
    I posted the details here because I was unsure: https://github.com/pulumi/pulumi-aws/issues/1783 What I notice is that
    RDS
    automatically unwraps the underlying value of its endpoint, while
    Elasticache
    does not. So for
    Elasticache
    one needs to use the
    apply
    operator again in order to use the underlying value of
    cacheNodes
    and get the actual endpoint. This seem like a bug to me - it seems to me that the outputs should be handled in the same way across packages 🤷‍♀️ Regardless I was able to come up with a workable solution but any comment or feedback is appreciated.
    l
    • 2
    • 4
  • h

    high-grass-3103

    02/05/2022, 9:33 PM
    Looks like I just lost the ability to import resources from other files in the project. Any resources that are imported are now ignored, unless I export them from the main index.ts 😕 Edit: Before yesterday I was able to do
    export * from 'file'
    and it imported the file and reexported its exports. Now I have to change it all to
    import 'file'; export {ex1,ex2} from 'file';
    But I can't pinpoint which components change is responsible for it
    l
    • 2
    • 3
  • r

    rough-intern-34947

    02/07/2022, 4:26 PM
    What are your experiences with using TypeScript vs plain JS? (with Pulumi of course) I honestly don’t like introducing TypeScript into projects - adds to much bloat and maintenance overhead, and it doesn’t provide any runtime type safety. In my previous projects I didn’t feel that the PROs outweigh the CONs. Also, I want my Serverless Functions to be as lean as possible, and I want the code to be as simple as it can get. I know that the author of Pulumi might have a personal bias towards TypeScript because he helped design it, but I’m not sure if that puts regular JavaScript in a disadvantage here. Thanks 👍
    m
    m
    l
    • 4
    • 8
  • m

    magnificent-address-3498

    02/08/2022, 3:47 PM
    Hi, I am trying to create a Kubernetes cluster on top of Hetzner Cloud
    @pulumi/hcloud
    using Typescript and k0sproject. To set up the cluster I need to generate a yaml file containing data from a list of created servers (primaryly the internal IP address of each server) and I am struggling to incorporate the outputs. Does anybody have a pointer on how to locally generate a file using data from outputs?
  • m

    magnificent-address-3498

    02/08/2022, 3:48 PM
    Several approaches have failed up to now, e.g. ``````
  • m

    magnificent-address-3498

    02/08/2022, 3:48 PM
    const k0sconfig = pulumi.all(nodes).apply((nodes) =>{
        return {
            apiVersion: k0sctrl.apiVersion,
            kind: k0sctrl.kind,
            metadata: {
                name: "scip",
            },
            spec: {
                hosts: nodes.map((n) => {
                    return {
                        role: n.role,
                        ssh: {
                            address: n.ip,
                            keyPath: "~/.ssh/id_ed25519",
                        }
                    };
                })
            }
        };
    })
    
    k0sconfig.apply((cfg) => <http://pulumi.log.info|pulumi.log.info>(stringify(cfg)))
  • m

    magnificent-address-3498

    02/08/2022, 3:49 PM
    Results in the usual
    Calling [toJSON] on an [Output<T>] is not supported.
    
    
                To get the value of an Output as a JSON value or JSON string consider either:
                    1: o.apply(v => v.toJSON())
                    2: o.apply(v => JSON.stringify(v))
    
                See <https://pulumi.io/help/outputs> for more details.
    
                This function may throw in a future version of @pulumi/pulumi.
    l
    o
    • 3
    • 12
  • m

    magnificent-address-3498

    02/08/2022, 3:52 PM
    Other approaches like utilizing a dynamic resource and creating the yaml inside the
    create
    method of the provider fail to import code from `yaml`:
    error: Package subpath './dist/index.js' is not defined by "exports" in …node_modules/yaml/package.json
    (which might be caused bythe function serialization?)
    m
    • 2
    • 1
  • m

    mammoth-art-6111

    02/08/2022, 4:10 PM
    anyone have any issues packaging with pnpm? I wasn't able to use any other packages besides the pulumi set using pnpm; switching to npm or yarn, it works
    o
    c
    • 3
    • 4
  • w

    wet-soccer-72485

    02/09/2022, 2:45 AM
    Is there a Typescript Generic Type that will normalize promises out of Inputs/Outputs definitions?
    • 1
    • 7
  • a

    ancient-eve-13947

    02/09/2022, 9:41 AM
    I'm trying to build docker images using an intermediary builder image. But even though I make the builder image a
    dependsOn
    dependency of the other images, Pulumi doesn't wait to build the other images until the builder is done, instead tries to run them in parallel and of course fails for the other images. I can't see what I'm doing wrong - anyone any idea? I'll attach code-snippets of the relevant pulumi code passage and the dockerfiles in the thread
    q
    • 2
    • 35
  • g

    great-sunset-355

    02/17/2022, 8:11 AM
    Hi, can anyone tell me how to render cloud-init user data (yaml) from TS objects, including outputs?
    ✅ 1
    l
    • 2
    • 2
  • m

    mammoth-art-6111

    02/18/2022, 3:13 PM
    anyone have any luck using jest w/ pulumi? i've noticed that i get multiple error messages per test fail if i try to follow the style as-presented in the examples (which uses mocha). the docs have a different pattern, which just uses done (i.e. raising an error if an assertion fails, and calling the function if it passes), but it sacrifices the rich assertion matchers present in jest and requires a branch on every test assertion; kinda wondering if there's a better way, or if i should just fall back to mocha here
  • m

    mammoth-art-6111

    02/18/2022, 4:53 PM
    actually it seems like this is also the case w/ mocha
  • m

    mammoth-art-6111

    02/18/2022, 4:57 PM
    is there a way to unit test and use the "regular" matching functions? seems a shame that Output<T> makes reasonable unit testing difficult
    l
    • 2
    • 31
  • b

    busy-journalist-6936

    02/20/2022, 12:05 AM
    I have a parent helm chart which creates service:
    controlplane-dktkocdx-kong-cluster
    I gave it the label:
    <http://konghq.com/service=cluster|konghq.com/service=cluster>
    I can find the service name with the command:
    kubectl get services -nkong --selector '<http://konghq.com/service=cluster|konghq.com/service=cluster>' -ojsonpath='{.items[*].metadata.name}'
    I need this name before I render a child helm chart so I can inject the service name. How do I write a const which looks up this name so I can use it in the child chart?
    • 1
    • 2
  • r

    refined-terabyte-65361

    02/20/2022, 5:40 PM
    Hello i have 2 stacks 1) to create s3 bucket 2) to create a lambda function package for lambda function is available in s3 bucket is it possible to get s3 bucket id from stack1 to stack2 ?
    l
    • 2
    • 1
  • r

    refined-terabyte-65361

    02/21/2022, 4:15 PM
    Hello i am trying to add eventbridge rule as trigger to lambda function using this example https://www.pulumi.com/registry/packages/aws/api-docs/lambda/permission/#example-usage but trigger is not added to lambda shorturl.at/dgxBP Thanks
    r
    m
    • 3
    • 6
  • b

    busy-journalist-6936

    02/24/2022, 12:51 AM
    I'm trying to use
    tls.SelfSignedCert
    to issue an mtls certificate used between a few pods. It feels like I'm close, but I'm getting the following error. I guess perhaps I need to b64 decode the
    Diagnostics:
      kubernetes:core/v1:Secret (kong-cluster-cert):
        error: Preview failed: resource kong/kong-kong-cluster was not successfully created by the Kubernetes API server : Secret in version "v1" cannot be handled as a Secret: illegal base64 data at input byte 0
    And it seems these would be the problematic lines in question.
    data: {
            "tls.crt": kongClusterCert.certPem,
            "tls.key": kongClusterCert.privateKeyPem,
    Snippet:
    //// Issue certificate for kong cluster mtls
    const kongClusterKey = new tls.PrivateKey(`${name}-cluster-mtls-pkey`, {
      algorithm: "RSA",
      rsaBits: 2048,
    });
    
    const kongClusterCert = new tls.SelfSignedCert(`${name}-cluster-mtls-cert`, {
      privateKeyPem: kongClusterKey.privateKeyPem,
      allowedUses: [
        "keyEncipherment",
        "digitalSignature",
        "serverAuth",
        "cert_signing",
        "crl_signing",
      ],
      keyAlgorithm: kongClusterKey.algorithm,
      subjects: [{ commonName: 'kong_clustering' }],
      dnsNames: ['kong_clustering'],
      validityPeriodHours: 4870,
      isCaCertificate: false,
    },{
        parent: kongClusterKey,
    });
    
    // TODO: Consider Rotation Strategy
    const secretKongClusterCert = new k8s.core.v1.Secret(`${name}-cluster-cert`, {
        apiVersion: "v1",
        kind: "Secret",
        type: "tls",
        metadata: {
            name: "kong-kong-cluster",
            namespace: "kong",
        },
        data: {
            "tls.crt": kongClusterCert.certPem,
            "tls.key": kongClusterCert.privateKeyPem,
        },
    }, {
        dependsOn: [
            nsKong,
        ],
        parent: kongClusterCert,
        provider: kubeconfig,
    });
    w
    • 2
    • 10
  • r

    refined-terabyte-65361

    02/24/2022, 12:52 AM
    is there example to deploy aws resources using pulumi and github actions ? tried using this example https://www.pulumi.com/docs/guides/continuous-delivery/github-actions/ but i got error stderr: error: no stack named 'dev' found
    b
    • 2
    • 6
  • r

    rough-intern-34947

    02/24/2022, 1:01 PM
    The example TypeScript code is broken here: https://www.pulumi.com/registry/packages/aws/api-docs/rds/clusterinstance/#example-usage
    q
    • 2
    • 1
  • e

    elegant-crayon-4967

    02/24/2022, 8:56 PM
    anyone have success in using the
    aliases
    feature to move a resource from one child library to another?
    l
    • 2
    • 30
  • s

    straight-cartoon-24485

    02/28/2022, 7:32 PM
    How could I patch a new storage class as
    default
    inside a Pulumi program? E.g.:
    $ kubectl get sc | grep \(default\) # find the default class currently set
    $ kubectl patch storageclass openebs-jiva-default -p '{"metadata": {"annotations":{"<http://storageclass.kubernetes.io/is-default-class|storageclass.kubernetes.io/is-default-class>":"false"}}}'
    $ kubectl patch storageclass openebs-jiva-csi-default -p '{"metadata": {"annotations":{"<http://storageclass.kubernetes.io/is-default-class|storageclass.kubernetes.io/is-default-class>":"true"}}}'
    Right now I run these commands after I run the Pulumi program... I'm installing the OpenEBS Helm Chart via Pulumi—how do I become aware of the now newly available storage class, and set that as default?
  • r

    refined-terabyte-65361

    02/28/2022, 8:32 PM
    hello i am trying to use pulumi up in github actions it works as expected . is there a way i can use the resource name from onestep to another ? i am already exporting the name of my bucket in my pulumi script
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    import * as awsx from "@pulumi/awsx";
    
    // Create an AWS resource (S3 Bucket)
    const bucket = new aws.s3.Bucket("accessRequests3Bucket");
    
    // Export the name of the bucket
    export const bucketName = bucket.id;
    i am able to see that in my github actions also
    pulumi up on dev
      Updating (dev):
      
      
      
          pulumi:pulumi:Stack s3-dev running 
      
          aws:s3:Bucket accessRequestBucket  
      
          pulumi:pulumi:Stack s3-dev  
       
      
      Outputs:
          bucketName: "accessrequestbucket-6500d31"
      
      Resources:
          2 unchanged
      
      Duration: 3s
    apologies if this question is not related to pulumi Thanks
    l
    • 2
    • 10
  • b

    busy-journalist-6936

    02/28/2022, 11:27 PM
    is there an example laying around showing how to get the hash of a secret that I create with a pulumi resources so I can use it as a label/annotation to roll my pod deployment when it's value is updated?
    b
    s
    • 3
    • 8
  • b

    busy-lion-51883

    03/04/2022, 8:07 PM
    typescript/aws question: https://pulumi-community.slack.com/archives/CRH5ENVDX/p1646424371007549
    s
    • 2
    • 3
  • a

    abundant-window-12532

    03/07/2022, 11:45 AM
    I've just added ElastiCache to my stack, but I'm having problems getting the address from the output using Typescript, has anyone been able to implement this successfully. I'm trying with the same approach I've done for RDS, but keep getting
    Calling [toString] on an [Output<T>] is not supported. To get the value of an Output<T> as an Output<string> consider either: 1: o.apply(v => `prefix${v}suffix`) 2: pulumi.interpolate `prefix${v}suffix` See <https://pulumi.io/help/outputs> for more details. This function may throw in a future version of @pulumi/pulumi.
    Rather than the expected value
    e
    b
    • 3
    • 8
  • m

    mammoth-art-6111

    03/08/2022, 5:41 PM
    anyone else run into issues re: function serialization and using a pulumi ComponentResource? i refactored a lambda/API gateway setup to be composed in a ComponentResource and now when the function is serialized, it omits all of the member functions required to do the job
    m
    • 2
    • 16
Powered by Linen
Title
m

mammoth-art-6111

03/08/2022, 5:41 PM
anyone else run into issues re: function serialization and using a pulumi ComponentResource? i refactored a lambda/API gateway setup to be composed in a ComponentResource and now when the function is serialized, it omits all of the member functions required to do the job
the only function that was serialized was the one passed directly to
CallbackFunction
but all functions it referenced were not serialized
breaking.txt
^ that's basically the constructor that assigns a member function to the Callback Function
i figured out a workaround; you've gotta create a service object with the functions you want to use in the callback, instantiate it, and then pass it to
aws.lambda.CallbackFunction
as an arrow function w/ the service object instance caught in the closure
idk if that would be easy for others to figure out, took me a while
m

miniature-musician-31262

03/08/2022, 10:09 PM
That’s interesting — I would’ve found this surprising, too. Glad you found a way through it. I wonder if there’s something about
webhookCallback
specifically that got in the way somehow, because this, at least for me, seems to work:
and with a
lambda.CallbackFunction
, I also see
someFunc
serialized into the Lambda:
… so I wonder what happened there. 🤔
m

mammoth-art-6111

03/08/2022, 10:11 PM
yeah. also curious. it was using
this.someFunc
, it was another member function of the instance
m

miniature-musician-31262

03/08/2022, 10:18 PM
aha, so you saw something like this?
m

mammoth-art-6111

03/08/2022, 10:54 PM
yes, exactly
m

miniature-musician-31262

03/08/2022, 11:59 PM
nice, ok. seems like this is either a bug or something that needs to be documented — will report back!
m

mammoth-art-6111

03/09/2022, 3:20 PM
lmk!
m

miniature-musician-31262

03/10/2022, 12:24 AM
Ended up filing this, as I think it may be a bug — or at least need better documentation! https://github.com/pulumi/pulumi/issues/9168
m

mammoth-art-6111

03/10/2022, 3:56 PM
yeah, i wonder if it's possible to serialize in that situation at all. i believe the "instance" or object created from the object prototype exists at the time that the function assignment occurs, but i'm not sure it's simply a matter of capturing everything in the closure and i'm not sure how you would make the serializer aware a particular closure was a "constructor" (since it's syntax sugar/ it's really just another function)
View count: 3