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

    brave-window-69382

    02/09/2020, 5:05 PM
    I am really struggling with understanding how outputs work in Pulumi. Here's what I'm trying to do. After creating an alb loadbalancer with
    new aws.alb.loadbalancer
    I'm trying to use an output in a userdata script:
    const test = "test"
    const dnsName = lb.dnsName
    const userData =
    ``#!/bin/bash`
    echo Test string: ${test}
    `echo ${dnsName}``
    console.log(userData)
    The diagnostic log produces:
    #!/bin/bash
    echo Test string: test
    echo 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.
    I've been through the output documentation in the URL in addition to combing this Slack workspace but I can't seem to find a solution here. How can I use the dnsName output from the lb resource as a pure string?
    w
    • 2
    • 2
  • i

    incalculable-dream-27508

    02/09/2020, 5:08 PM
    From my playing around it seems that whatever you
    export
    ends up as
    output
  • i

    incalculable-dream-27508

    02/09/2020, 5:10 PM
    With this code you'll end up with outputs of
    ips
    ,
    hostnames
    and
    url
    Untitled
  • i

    incalculable-dream-27508

    02/09/2020, 5:14 PM
    Allowing you to for example to
    curl $(pulumi stack output url)
  • i

    incalculable-dream-27508

    02/09/2020, 5:16 PM
    Though with the code I'm using (taken from https://github.com/pulumi/infrastructure-as-code-workshop/blob/master/labs/02-app-arch/code/01-provisioning-vms/step4.ts ), it is using unexported variables in the
    userData
  • r

    rough-tomato-98795

    02/10/2020, 11:59 AM
    I want to migrate my current solution of deployment (shell script which runs few kubectl commdns) to pulomi one the easiest way at the beginning. As a first step i want to just take already written yaml descriptors and insted of applying them with kubectl use pulumi. I am currently loading the descriptors with
    @pulumi/kubernetes/yaml/ConfigFile
    providing a file path to it. Is that a valid way? I am getting error when pulomi tryies to parse that yaml.
    t
    • 2
    • 6
  • c

    colossal-room-15708

    02/11/2020, 9:59 AM
    Anybody know how I can fix this? This is coming from here: https://github.com/pulumi/examples/blob/master/azure-ts-static-website/staticWebsite.ts#L67
    r
    t
    • 3
    • 6
  • c

    colossal-room-15708

    02/11/2020, 10:05 AM
    If I follow VS Code's recommendation (quick fix) to make those optional then that makes the linter happy, but then this one here fails: https://github.com/pulumi/examples/blob/master/azure-ts-static-website/index.ts#L32
  • s

    salmon-account-74572

    02/11/2020, 9:51 PM
    What's the best way to determine why Pulumi (via
    pulumi preview
    ) is saying a resource must be replaced?
    i
    g
    • 3
    • 10
  • s

    salmon-account-74572

    02/11/2020, 9:52 PM
    (I'm trying to figure out why Pulumi wants to replace an EC2 instance when nothing about the EC2 instance is being changed.)
  • s

    stocky-spoon-28903

    02/12/2020, 1:57 PM
    If you expand the details view it should tell you the property, old and (possibly) new values (if the new value is prompt)
  • s

    salmon-account-74572

    02/12/2020, 6:18 PM
    @stocky-spoon-28903 We found the issue; I was using
    securityGroups
    instead of
    vpcSecurityGroupIds
    . Switching to the latter resolves the problem.
  • s

    stocky-spoon-28903

    02/12/2020, 6:18 PM
    ah yes,
    securityGroups
    is for EC2 classic
  • s

    stocky-spoon-28903

    02/12/2020, 6:19 PM
    So chances are this actually was a worse problem than you’d imagine too
  • b

    broad-dog-22463

    02/12/2020, 9:51 PM
    @salmon-account-74572 FYI, this issue will be taken care of during the next week or 2 - https://github.com/pulumi/pulumi-aws/issues/852
    s
    • 2
    • 1
  • i

    icy-london-58403

    02/17/2020, 6:59 PM
    I'm trying to learn dynamic providers and I'm starting by wrapping a tool called netbox which does IPAM. I get this error:
    prefix.ts(130,21): error TS2564: Property 'endpoint' has no initializer and is not definitely assigned in the constructor.
    prefix.ts(131,21): error TS2564: Property 'token' has no initializer and is not definitely assigned in the constructor.
    prefix.ts(132,21): error TS2564: Property 'description' has no initializer and is not definitely assigned in the constructor.
    I followed the directions on: https://www.pulumi.com/docs/intro/concepts/programming-model/#dynamicproviders I made my create return the same names as the
    public readonly
    members of my
    Resource
    . What am I doing wrong? Partial of my code:
    class PrefixProvider implements pulumi.dynamic.ResourceProvider {
        public async create(inputs: PrefixInputs): Promise<pulumi.dynamic.CreateResult> {
            pulumi.log.debug("prefix create...")
            let netboxClient = new Client({
                host: inputs.endpoint,
                token: inputs.token,
            })
    
            
            let description = `${inputs.platform} | ${inputs.region} | ${inputs.type} | ${inputs.name}`
    
            var async_function = async function(): Promise<AxiosResponse<createPrefixResponse>> {
                return await netboxClient.createPrefix({
                    prefix: inputs.prefix,
                    description: description,
                    vrf: inputs.vrfID,
                })
            }
    
            const response = await async_function()
    
            return {
                id:  response.data.id.toString(),
                outs: {
                    endpoint: inputs.endpoint,
                    token: inputs.token,
                    description: description,
                },
            }
        }
    
        public async delete(id: pulumi.ID, props: PrefixInputs): Promise<void> {
            pulumi.log.debug("prefix delete...")
    
            let netboxClient = new Client({
                host: props.endpoint,
                token: props.token,
            })
    
            var async_function = async function() {
                return await netboxClient.deletePrefix({
                    id: Number(id),
                })
            }
    
            const response = await async_function()
        }
    }
    
    export class Prefix extends pulumi.dynamic.Resource {
        public readonly endpoint: pulumi.Output<string>
        public readonly token: pulumi.Output<string>
        public readonly description: pulumi.Output<string>
    
        constructor(name: string, props: PrefixResourceInputs, opts?: pulumi.CustomResourceOptions) {
            super(new PrefixProvider(), name, {...props, endpoint: undefined, token: undefined, description: undefined}, opts)
        }
    }
    m
    • 2
    • 5
  • a

    acceptable-army-69872

    02/18/2020, 4:20 PM
    My goal is to pull lambda's from a separate git repo based on a git tag, and upload them via pulumi. Are there examples of using https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/asset/ to do that? It'd be pretty great to avoid having to figure out a git subshell or some random ts module.
  • i

    important-ram-83431

    02/19/2020, 11:30 AM
    Sorry guys for bothering you, but I'm going crazy on that... I'm trying to create an EKS cluster, create the Rancher Cluster representation and then, import that cluster.
    const cluster = new eks.Cluster(name, {
        vpcId: vpc.id,
        subnetIds: vpc.publicSubnetIds,
        storageClasses: "gp2",
        deployDashboard: false,
        nodeGroupOptions: {
            spotPrice: "0.038",
            instanceType: "m5.large",
            desiredCapacity: 6,
            minSize: 6,
            maxSize: 24,
        }
    });
  • i

    important-ram-83431

    02/19/2020, 11:30 AM
    const rancherCluster = new rancher2.Cluster(name, {
        name: name,
        description: "Imported Cluster for Airflow (" + name + ")",
        driver: "imported",
        enableClusterAlerting: true,
        enableClusterIstio: true,
        enableClusterMonitoring: true,
    });
    
    const rancherClusterImport = new k8s.yaml.ConfigFile(name + "-import", {
            file: rancherCluster.clusterRegistrationToken.manifestUrl,
        }, {
            provider: cluster.provider,
            dependsOn: [cluster, rancherCluster]
        });
    });
  • i

    important-ram-83431

    02/19/2020, 11:32 AM
    Last part doesn't work, because ConfigFileOpts.file expects a string. I've tried:
    rancherCluster.clusterRegistrationToken.manifestUrl.apply((manifestUrl) => {
        new k8s.yaml.ConfigFile(name + "-import", {
            file: manifestUrl
        }, {
            provider: cluster.provider,
            dependsOn: [cluster, rancherCluster]
        });
    });
    t
    • 2
    • 7
  • i

    important-ram-83431

    02/19/2020, 11:32 AM
    But then, ConfigFile resource is missing in preview, and, on successive executions, is deleted because mainfestUrl is not "Promise" anymore...
    g
    • 2
    • 1
  • i

    important-ram-83431

    02/19/2020, 11:34 AM
    Even, on https://www.pulumi.com/docs/intro/concepts/programming-model/#apply the Note explains explicitly not to do that... But, I'm unable to find the right way 😢
  • f

    fresh-pilot-59899

    02/21/2020, 9:09 PM
    Hi, what is the role of the template config from the Pulumi.yaml? only for documentation purposes? It does not seem to be injected in the stack file when I create a new one.
    template:
      config:
        azure:region:
          description: Azure location where to provision the resources created by this component.
        azure:environment:
          description: The Azure environment to use (`public`, `usgovernment`, `german`, `china`)
          default: public
    w
    • 2
    • 1
  • s

    stocky-island-3676

    02/25/2020, 4:36 PM
    On compiling a Pulumi module,
    tsc
    returns an error in `@pulumi/pulumi`:
    node_modules/@pulumi/pulumi/queryable/index.d.ts:8:60 - error TS2304: Cannot find name 'Omit'.
    
    8 export declare type ResolvedResource<T extends Resource> = Omit<Resolved<T>, "urn" | "getProvider">;
    Package versions
    1.11.0
    ,
    1.10.0
    &
    1.9.0
    return the same error (didn’t test others, yet).
    w
    • 2
    • 8
  • l

    limited-rainbow-51650

    02/26/2020, 4:07 PM
    Any news on the new Yarn2 PnP support? https://github.com/pulumi/pulumi/issues/3586
  • l

    limited-rainbow-51650

    02/26/2020, 4:15 PM
    I just added a comment to the GH issue with my findings.
  • d

    delightful-truck-1268

    02/27/2020, 9:32 PM
    It might be neat to create some dotenv files from pulumi outputs. Would I have to write a script to do this?
  • r

    rough-tomato-98795

    02/28/2020, 8:40 AM
    Hello, what is actual result of get functions in azureAd (eg.: getApplication)? Function signatures says: Promise<T> & T. So my question is: is the returned stuff promise or not?
  • l

    limited-rainbow-51650

    02/28/2020, 9:52 AM
    I have this as my stack config, set via `pulumi config set --path pulumi:providers.gitlab --secret`:
    config:
      pulumi:providers:
        gitlab:
          secure: AAABAIAhjQk...
    How can I retrieve the
    gitlab
    secret in Typescript code? I tried the following two ways: •
    new pulumi.Config("pulumi").requireSecret("providers.gitlab")
    •
    new pulumi.Config("pulumi:providers").requireSecret("gitlab")
    Neither of these two work.
    m
    • 2
    • 1
  • b

    bored-furniture-11856

    02/29/2020, 10:46 PM
    Did I miss a thing, or why does kubernetesx.Deployment.createService() use autonaming?
    metadata  : {
        annotations: {
            <http://pulumi.com/autonamed|pulumi.com/autonamed>: "true"
        }
        labels     : {
            <http://app.kubernetes.io/managed-by|app.kubernetes.io/managed-by>: "pulumi"
        }
        name       : "foo-api-2rwgcw01"
        namespace  : "backend"
    }
    Is there any way around that? Or is it a missing feature? Any chance to set the Service name to
    foo-api
    ? https://github.com/pulumi/pulumi-kubernetesx/blob/master/nodejs/kubernetesx/kx.ts#L260
    g
    • 2
    • 1
Powered by Linen
Title
b

bored-furniture-11856

02/29/2020, 10:46 PM
Did I miss a thing, or why does kubernetesx.Deployment.createService() use autonaming?
metadata  : {
    annotations: {
        <http://pulumi.com/autonamed|pulumi.com/autonamed>: "true"
    }
    labels     : {
        <http://app.kubernetes.io/managed-by|app.kubernetes.io/managed-by>: "pulumi"
    }
    name       : "foo-api-2rwgcw01"
    namespace  : "backend"
}
Is there any way around that? Or is it a missing feature? Any chance to set the Service name to
foo-api
? https://github.com/pulumi/pulumi-kubernetesx/blob/master/nodejs/kubernetesx/kx.ts#L260
g

gorgeous-egg-16927

03/02/2020, 3:26 PM
Autonaming is the default for Pulumi, but the intent is to allow overrides as needed. This feature is tracked in https://github.com/pulumi/pulumi-kubernetesx/issues/52 In the meantime, you’d have to specify the Service the usual way if you need a specific name. Something like this should work:
const svc = new kx.Service("nginx", {
    metadata: { name: "nginx" },
    spec: {
        ports: { http: 80 },
        selector: deployment.spec.selector.matchLabels,
        type: kx.types.ServiceType.LoadBalancer,
    }
})
👍 1
View count: 2