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

    rhythmic-finland-36256

    01/27/2020, 3:05 PM
    On publishing ComponentResources for reuse over several projects: We started modularizing our pulumi (typescript) projects using several
    ComponentResources
    which is a nice way of abstracting a certain part of the whole into a separate file. This makes the projects more readable as we now can find resources easier than in a long list of resources inside a single index.ts file. As we also started using pulumi for more than just one project, I’d like to be able to reuse those components in other projects without copy/pasting single classes between them (which is already way better than to copy/paste many lines of resources from an index.ts). So I’m looking for some hints on how to share those javascript/typescript files via npm. I already know a bit about npm publishing, but I’m specifically interested in how to deal with the dependencies my code has on pulumi classes and how the project setup generally looks. I assume those classes would go into a simple node project (not a pulumi project) with a common
    tsc
    step. • Is there some best practice project structure for such
    ComponentResource
    libraries? • How do you deal with testing the resources if there is no pulumi project? Having a separate repo for the pulumi project that uses the library via npm link? • How to handle dependencies on pulumi resources? I assume the library should not bring specific versions of pulumi providers with it? Is using
    peerDependencies
    the way to go?
    l
    b
    b
    • 4
    • 14
  • n

    numerous-airport-64744

    01/27/2020, 9:26 PM
    Hi there, I’m trying to create a k8s Cluster on DigitalOcean and then provision stuff using the k8s provider. This actually works fine for 7 days and then I got a problem: DO only generates kubeconfigs that at valid for 7 days so after a week the credentials I get from the cluster resource are no longer valid because the credentials are not updated on every run and
    cluster.kubeConfigs[0].rawConfig
    always returns the credentials from the time the cluster was actually created. I tried to get the credentials by using a data source but I still have 2 problems with it: • I’m unable to create a data source for the cluster from the generated name because GetKubernetesClusterArgs does not accept Output<string> as a name and my clusters name is dynamic. • If I hard code the cluster name after it is being created the kubeconfig property of the k8s provider is changed on every
    pulumi up
    ->
    pulumi:providers:kubernetes k8s updated [diff: ~kubeconfig]
    Here are the relevant parts for clarification:
    const cluster = new digitalocean.KubernetesCluster("cluster", {...});
    const clusterDataSource = digitalocean.getKubernetesCluster({ name: cluster.name }); // error TS2322: Type 'Output<string>' is not assignable to type 'string'.
    const kubeConfig = clusterDataSource.kubeConfigs[0].rawConfig;
    const k8sProvider = new k8s.Provider("k8s", { kubeconfig: kubeConfig });
    Any idea how to solve those two issues - primarily of course dynamic cluster name?
    g
    • 2
    • 6
  • c

    clever-egg-2543

    01/29/2020, 4:23 AM
    What’s the best image to use for a GitLab pipeline? Does anyone have an example pipeline for previewing and deploying via Pulumi that could be shared?
    c
    b
    b
    • 4
    • 9
  • s

    square-rocket-59657

    01/30/2020, 8:14 AM
    Has anyone created a Lambda Layer with a typescript class? For example say i have a seperate class i've created that i want to be reused across multiple lambdas something like:
    class myAwesomeClass {
      ... cool options here
    }
    awesome.ts
    Then when creating my layer referencing it like:
    const awesomeLayer = () => new aws.lambda.LayerVersion('my-lambda-version', 
    {
      code: new pulumi.asset.AssetArchive({
        '.': new pulumi.asset.FileArchive('./awesome.ts'),
      }),
      compatibleRuntimes: [
        aws.lambda.NodeJS12dXRuntime,
        aws.lambda.NodeJS10dXRuntime,
      ],
      layerName: 'awesome_layer'
    }, providerOpts);
    The issue it that obviously the typescript file wont run in the lambda, is there a way that pulumi can compile this to normal JS? Or have i missed something?
    c
    • 2
    • 3
  • s

    some-art-311

    01/30/2020, 4:37 PM
    Does anyone know how to use a global
    tsconfig.json
    for Pulumi ? If I drag the
    tsconfig.json
    into the sub folder, it is working fine
    c
    c
    • 3
    • 3
  • s

    some-art-311

    01/30/2020, 4:38 PM
  • s

    some-art-311

    01/30/2020, 4:38 PM
    {
      "compilerOptions": {
        "strict": true,
        "outDir": "bin",
        "target": "es2016",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "experimentalDecorators": true,
        "pretty": true,
        "noFallthroughCasesInSwitch": true,
        "noImplicitReturns": true,
        "forceConsistentCasingInFileNames": true,
        "resolveJsonModule": true
      },
      "files": [
        "index.ts"
      ]
    }
  • s

    some-art-311

    01/30/2020, 4:38 PM
    tsconfig.json ^^^
    a
    • 2
    • 1
  • c

    calm-parrot-72437

    01/30/2020, 5:51 PM
    pulumi and ts noob here. I'm attempting to create a k8s cluster with eks and I'd like to set the public key used for the VMs. This is what I've got: const nodePublicKeyPair = new aws.ec2.KeyPair("eks", { publicKey: "ssh-rsa ..." }) const cluster = new eks.Cluster(env, { ... nodePublicKey: nodePublicKeyPair, ... }) That errors out with this error: Types of property 'nodePublicKey' are incompatible. Type 'KeyPair' is not assignable to type 'string | Promise<string> | OutputInstance<string> | undefined'. Type 'KeyPair' is missing the following properties from type 'OutputInstance<string>': apply, get Any ideas?
    n
    • 2
    • 1
  • a

    ambitious-ram-5811

    01/30/2020, 5:53 PM
    @calm-parrot-72437 I think this is more of a AWS problem, nodePublicKey wants a string, and you're giving it a
    KeyPair
  • a

    ambitious-ram-5811

    01/30/2020, 5:53 PM
    You probably just want to pass it the public key string if you already know it?
  • c

    calm-parrot-72437

    01/30/2020, 5:58 PM
    pulumi preview likes that much better. 🙂 thanks!
  • s

    stocky-island-3676

    01/31/2020, 9:06 AM
    Someone uses ESLint/TSLint for Pulumi? What are configs you recommend?
    b
    n
    +2
    • 5
    • 6
  • b

    breezy-photographer-54783

    01/31/2020, 2:44 PM
    anybody on here looking for a part time or full time project AWS EKS + pulumi ?
  • a

    acceptable-army-69872

    01/31/2020, 5:57 PM
    I'm trying to separate out some projects into separate code bases for simplicity. I wanted to do a base project to deploy some infrastructure, and then use other projects for specific things like a lambda that's deployed to a VPC in the base project. I've done stackReferences before, for basic things like an arn, but can I go deeper? Like can I export the VPC object and then reference it as a Vpc object in another project? something like
    const vpc: aws.ec2.Vpc = apiStack.requireOutput("sharedServicesVpc");
    tosses a type error.
  • a

    acceptable-army-69872

    01/31/2020, 5:59 PM
    FWIW I also tried exporting the vpc.id from the base project, and tried a getVpc call, but got a needs a string, you gave me an Output<string> error.
  • a

    acceptable-army-69872

    01/31/2020, 6:07 PM
    Or maybe the answer is I have to just import the VPCid as a string, and change the code expecting the VPC object to the specific attributes of the VPC i care about (but that's less flexible)
  • e

    elegant-shampoo-65690

    01/31/2020, 6:27 PM
    Hey patrick, this might work:
    const vpc: pulumi.Output<aws.ec2.Vpc> = apiStack.requireOutput("sharedServicesVpc").apply((value) => value as aws.ec2.Vpc);
    a
    c
    • 3
    • 5
  • a

    acceptable-army-69872

    01/31/2020, 6:46 PM
    A valiant effort, but
    Type 'Output<Vpc>' is not assignable to type 'OutputInstance<Vpc>'.
  • a

    acceptable-army-69872

    01/31/2020, 6:51 PM
    Actually after pushing around some vpc: any types in the function calls i'm getting some different errors, let me keep picking.
  • f

    future-megabyte-14556

    02/03/2020, 8:42 AM
    I'm trying to setup Auto SSL certs on kubernetes. I've got my nginx-ingress Helm chart installed and working, but am looking for an example that using a cert-manager Helm Chart. Anyone know of any example repos around?
    l
    • 2
    • 6
  • e

    eager-processor-51878

    02/03/2020, 6:48 PM
    Does anyone use Pulumi with yarn workspaces? It works but I am getting "Could not include required dependency" errors. These seem to be spurious though because it works.
  • l

    limited-rainbow-51650

    02/03/2020, 10:56 PM
    In my Typescript project, I have these files: • index.ts • service/index.ts The file
    service/index.ts
    has:
    export interface DatabaseOptions {
    ...
    }
    
    export class Service extends pulumi.ComponentResource {
    ...
    }
    The main
    index.ts
    file, I has:
    import * as backend from "./service";
    
    const dbArgs = new backend.DatabaseOptions({
    ...
    })
    But I get an error on `DatabaseOptions`:
    error: Running program '/Users/ringods/Projects/devops-sessions/pulumi/backend' failed with an unhandled exception:
        TSError: ⨯ Unable to compile TypeScript:
        index.ts(13,28): error TS2339: Property 'DatabaseOptions' does not exist on type 'typeof import(/Users/ringods/Projects/devops-sessions/pulumi/backend/service/index")'.
    What am I missing here?
    m
    • 2
    • 2
  • h

    handsome-actor-1155

    02/04/2020, 5:04 PM
    Looking for some feedback, is this the best way to accomplish getting the vpcZones (availability zones) in use by the vpc?
    export const vpcZones = vpc.privateSubnetIds.then(function(subnetIds) {
        return subnetIds.map(function (id) {
            return id.apply(id => {
                return aws.ec2.getSubnet({id: id}).availabilityZone;
            });
        });
    });
    • 1
    • 1
  • v

    victorious-helmet-11068

    02/05/2020, 4:11 PM
    hi guys. I saw pulumi in cfgmgmt camp and It’s really impressive!
  • v

    victorious-helmet-11068

    02/05/2020, 4:11 PM
    I would like to code a gcp cross-project setup
  • v

    victorious-helmet-11068

    02/05/2020, 4:11 PM
    I would like to operate in n project, looping the code
    g
    • 2
    • 11
  • v

    victorious-helmet-11068

    02/05/2020, 4:13 PM
    it is possible?
  • b

    bitter-dentist-28132

    02/05/2020, 6:37 PM
    I'm doing this:
    export const getSigningKey = (
            secretKey: string | pulumi.Output<string>,
            region: pulumi.Output<digitalocean.Region | aws.Region>
    ) => {...};
    
    if (cloud === 'digitalocean') {
      s3 = new digitalocean.SpacesBucket(env, {
        region: awsRegion,
      });
    } else if (cloud === 'aws') {
      s3 = new aws.s3.Bucket(env, {
        region: awsRegion,
      });
    }
    signingKey = getSigningKey(
      awsSecretKey,
      s3!.region
    );
    this doesn't work. it complains that the types for
    region
    don't match. anyone know why?
    t
    g
    • 3
    • 5
  • b

    brave-window-69382

    02/08/2020, 6:13 PM
    Since the awsx.ec2.vpc module doesn't expose all of the route tables, I'm attempting the following:
    const vpc = new awsx.ec2.Vpc('test', {})
    const rts = aws.ec2.getRouteTables({
    vpcId: vpc.id
    });
    When I bring up the stack, I'm getting the following error. I can't figure out how to transform pulumi.Output<string> into just a string.
    index.ts(9,36): error TS2345: Argument of type '{ vpcId: pulumi.Output<string>; }' is not assignable to parameter of type 'GetRouteTablesArgs'.
    w
    • 2
    • 2
Powered by Linen
Title
b

brave-window-69382

02/08/2020, 6:13 PM
Since the awsx.ec2.vpc module doesn't expose all of the route tables, I'm attempting the following:
const vpc = new awsx.ec2.Vpc('test', {})
const rts = aws.ec2.getRouteTables({
vpcId: vpc.id
});
When I bring up the stack, I'm getting the following error. I can't figure out how to transform pulumi.Output<string> into just a string.
index.ts(9,36): error TS2345: Argument of type '{ vpcId: pulumi.Output<string>; }' is not assignable to parameter of type 'GetRouteTablesArgs'.
w

white-balloon-205

02/08/2020, 9:13 PM
Since
<http://vpc.id|vpc.id>
is an Output, you need to use apply, and call
getRouteTables
inside that.
const rts = vpc.id.apply(id => aws.ec2.getRouteTables({ vpcId: id }));
👍 1
b

brave-window-69382

02/09/2020, 2:30 AM
Thank you very much!
View count: 10