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

    acceptable-army-69872

    03/24/2020, 12:23 PM
    I'm going to go ahead and assume the docs
    Specify a single resource URN to update.
    say update on purpose. Kind of a bummer that this is a different behavior than terraform for the same verbage.
  • g

    gentle-diamond-70147

    03/24/2020, 3:32 PM
    Mind opening an issue at https://github.com/pulumi/pulumi ? Regarding the
    Specify a single resource URN to update
    , I don't believe it's meant to be on resource update but
    pulumi update
    , so it should work for creating resources too. That's what I would expect too.
  • l

    loud-napkin-70080

    03/26/2020, 11:15 PM
    good afternoon, I have my code in typescript, everything turned out ok, but now I want to be able to run a script to copy files to my azure fileshare, only when I finish applying the changes. It can? How do I detect that I finish applying the changes, what is the callback? Is there an after apply method?
  • c

    chilly-laptop-44574

    03/28/2020, 12:33 AM
    Hello, I have my project structured by using directories, something like this:
    └── infrastructure
        └── network
            ├── dev
            ├── prod
            └── stage
                ├── 01-host-project
                │   ├── Pulumi.stage.yaml
                │   └── Pulumi.yaml
                └── 02-host-vpc
                    ├── Pulumi.stage.yaml
                    └── Pulumi.yaml
    Is it possible to have
    package.json
    and
    node_module
    global on let say this level <
    stage
    folder>
    └── infrastructure
        └── network
            └── stage
    So
    npm install
    is done only once?
    s
    g
    • 3
    • 4
  • c

    creamy-traffic-12121

    03/30/2020, 4:13 PM
    reposting from aws channel in case this is a better place for this:
  • c

    creamy-traffic-12121

    03/30/2020, 4:13 PM
    @here running into some issues when trying to reference an arn when creating an sns topic (typescript project):
    const topicSubscription = new aws.sns.TopicSubscription("topic", {
        topic: snsTopic,
        protocol: "lambda",
        endpoint: lambda.arn
    })
    This is throwing the following error when running `$ pulumi up`:
    error: Running program '/Users/michaelstott/sns' failed with an unhandled exception:
        TypeError: Cannot read property 'arn' of undefined
            at Object.<anonymous> (/Users/michaelstott/sns/sns.ts:10:25)
            at Module._compile (internal/modules/cjs/loader.js:955:30)
    The lambda in question is defined in another file and would be provisioned normally if not for this error. It seems that Pulumi is attempting to create the topic before the lambda is created. Is there a workaround for this?
    m
    • 2
    • 2
  • i

    incalculable-engineer-92975

    03/31/2020, 1:58 PM
    @here Anyone know how to convert a Promise into an Output?
    g
    • 2
    • 2
  • c

    calm-jewelry-71872

    03/31/2020, 3:53 PM
    Hello, i am facing issue that when i am trying to run sudo yum -y update from my ec2 instance i am getting error: Could not retrieve mirrorlist http://repo.eu-central-1.amazonaws.com/latest/main/mirror.list error was 12: Timeout on http://repo.eu-central-1.amazonaws.com/latest/main/mirror.list: (28, 'Connection timed out after 10001 milliseconds')
    g
    • 2
    • 2
  • m

    miniature-arm-21874

    04/01/2020, 1:55 PM
    I have created an ALB with awsx and a listener which listens on port 443. When the LB is created it creates a security group and then the listener creation attaches ingress and egress rules to port 443 from anywhere. I then attach a listener rule to a target group and the target group to an `ecs.FargateService`` the problem i'm having is that the ingress/egress only create a rule for 443 and doesn't create one which allows the LB to talk to the instances for the healthcheck and then the end up in a perpetual up/down cycle. I can prove this works by adding
    80 tcp 0.0.0.0/0
    outbound rule to the created group in the console to test. as soon as i create this it works but also then allows http traffic to my container which i don't want. i just need https externally. what's the best way to make this work? I've added my own security group with an egress rule with
    80 tcp 0.0.0.0/0
    for now which makes my healthchecks pass and attached it to the LB. however, like i said this makes http work even though i haven't got an HTTP listener on my load balancer so i'm not entirely sure why i can get to the container on port 80 as soon as i add this? must have been the browser cache or some delay updating. it's no longer letting me get to port 80 externally. not really sure what the best way to fix this is. any help would be appreciated.
    • 1
    • 1
  • b

    breezy-cricket-40277

    04/01/2020, 1:58 PM
    Warning:
    resource plugin azure is expected to have version >=2.3.1, but has ; the wrong version may be on your path, or this may be a bug in the plugin
    Is there any required configuration missing?
    m
    • 2
    • 9
  • m

    miniature-arm-21874

    04/01/2020, 3:52 PM
    How can I get the name of a created repository to use as a string in getImage?
    const repo = new awsx.ecr.Repository('my-ecr-repository');
    
    const image = aws.ecr.getImage({
      repositoryName: repo.repository.name.apply((name) => name),
      imageTag: 'latest',
    });
    I get
    Type 'Output<string>' is not assignable to type 'string'. [Error/2322]
    for repositoryName
    w
    • 2
    • 4
  • a

    alert-restaurant-79151

    04/01/2020, 5:11 PM
    I get
    "Received 0 SUCCESS signal(s) out of 1.  Unable to satisfy 100% MinSuccessfulInstancesPercent requirement"
    what do I do wrong?
  • a

    alert-restaurant-79151

    04/01/2020, 5:12 PM
    aws:cloudformation:Stack (resetCases):
        error: 1 error occurred:
        	* creating urn:pulumi:test::testing::awsx:x:ecs:Cluster$awsx:x:autoscaling:AutoScalingGroup$aws:cloudformation/stack:Stack::resetCases: ROLLBACK_COMPLETE: ["The following resource(s) failed to create: [Instances]. . Rollback requested by user." "Received 0 SUCCESS signal(s) out of 2.  Unable to satisfy 100% MinSuccessfulInstancesPercent requirement"]
  • s

    square-rose-64819

    04/01/2020, 6:07 PM
    what's the best way to break down my index.ts file into multiple configuration modules? i've noticed that if i make a new module and import it from within my index.ts file, pulumi won't create any of the resources unless i reference them, e.g. by exporting them. i'm guessing this is because node is immediately garbage collecting them or removing the import because its not used.
    w
    • 2
    • 2
  • c

    chilly-laptop-44574

    04/02/2020, 5:55 AM
    Hi Guys, any idea this code fails?
    async function waitForServiceAccount(accountNum: string): Promise<any> {
      if (!pulumi.runtime.isDryRun()) {
          // Wait for up to 10 minutes
          for (let i = 0; i < 60; i++) {
              const objectViewer = await gcp.serviceAccount.getAccount({
                accountId: `service-${accountNum}`
              });
              if (objectViewer.email && objectViewer.name && objectViewer.uniqueId) {
                  return objectViewer.email;
              }
              <http://pulumi.log.info|pulumi.log.info>(`Waiting for Service Account ${accountNum} (${i})`)
              // Wait for 10s between polls
              await new Promise(r => setTimeout(r, 10000));
          }
          throw new Error("timed out waiting for Job to complete");
      }
    }
    
    const email= serviceProject.number.apply(projectNumber => waitForServiceAccount(projectNumber));
    serviceProject
    is of course created before but in the same ts file. Getting this error:
    error: Request "Create IAM Members roles/compute.securityAdmin serviceAccount:Calling [toString] on an [Output<T>] is not supported.\n\nTo get the value of an Output<T> as an Output<string> consider either:\n1: o.apply(v => `prefix${v}suffix`)\n2: pulumi.interpolate `prefix${v}suffix`\n\nSee <https://pulumi.io/help/outputs> for more details.\nThis function may throw in a future version of @pulumi/pulumi. for \"project \\\"xxxxxxxx\\\"\"" returned error: Error applying IAM policy for project "xxxxxxxx": Error setting IAM policy for project "xxxxxxxxxx": googleapi: Error 400: Invalid service account (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`
    f
    • 2
    • 1
  • b

    busy-magazine-48939

    04/02/2020, 8:14 AM
    Is there way I can explicitly tell pulumi to ignore a particular object that happened to be exported in my module? Right now any
    export const something…
    will be shown in pulumi log, hard to traverse through this noize.
  • h

    high-lamp-12603

    04/02/2020, 4:50 PM
    Hey new to Pulumi and looking for some best practices around cross stack references that go beyond the simple examples. The docs seem to heavily suggest using many small stacks but there are limited examples actually doing this. I’m attempting to create a VPC stack and a EKS stack and link resources across them
    // VPC Stack
    import * as awsx from '@pulumi/awsx';
    
    const vpc = new awsx.ec2.Vpc('application-vpc', {
      cidrBlock: '10.128.0.0/19',
      enableDnsSupport: true,
      enableDnsHostnames: true,
      subnets: [...Array(3).keys()].map((i) => ({ name: `private-${i}`, type: 'private' })),
      numberOfNatGateways: 1,
    });
    
    export const { id, privateSubnetIds } = vpc;
    
    // EKS Stack - Stack References Only
    import * as awsx from '@pulumi/awsx';
    import * as eks from '@pulumi/eks';
    import * as pulumi from '@pulumi/pulumi';
    import { last } from 'lodash';
    
    const env = last(pulumi.getStack().split('.'));
    
    const vpcStack = new pulumi.StackReference(`infra.vpc.${env}`);
    const vpcId = vpcStack.getOutput('vpcId');
    const privateSubnetIds = vpcStack.getOutput('privateSubnetIds');
    
    export const eksCluster = new eks.Cluster('applicatin-eks-cluster', {
      vpcId,
      privateSubnetIds,
    });
    
    // EKS Stack - Only pass minimal references (ideal)
    import * as awsx from '@pulumi/awsx';
    import * as eks from '@pulumi/eks';
    import * as pulumi from '@pulumi/pulumi';
    import { last } from 'lodash';
    
    const env = last(pulumi.getStack().split('.'));
    
    const vpcStack = new pulumi.StackReference(`infra.vpc.${env}`);
    const vpcId = vpcStack.getOutput('vpcId');
    
    const vpc = awsx.ec2.Vpc.fromExistingIds('application-vpc', {
      vpcId,
    });
    
    export const eksCluster = new eks.Cluster('applicatin-eks-cluster', {
      vpcId: vpc.id,
      privateSubnetIds: vpc.privateSubnetIds,
    });
    Option 1 works but outputting every will get messy quickly with increased complexity. Option 2 doesn’t actually work because
    fromExistingIds
    doesn’t actually hydrate the subnets. Any suggestions or better examples?
    w
    • 2
    • 32
  • h

    high-lamp-12603

    04/02/2020, 10:19 PM
    anyone have experience deploying typescript aws lambdas with pulumi? I’ve attempted to use both
    aws.cloudwatch.onSchedule
    and
    new aws.lambda.Function
    to create the typescript bundle. I can’t seem to get dependencies pulled in correctly. I either get errors like
    which could not be serialized because it was a native code function
    or
    Could not include required dependency
    . I feel like I’m missing something obvious
    f
    l
    m
    • 4
    • 40
  • b

    billowy-oxygen-65892

    04/03/2020, 2:54 PM
    Trying to schedule a stepfunction using cloudwatch event rule..any ideas?
    🚬 1
  • s

    square-rose-64819

    04/06/2020, 7:53 PM
    is it possible using the typescript api to assign a
    dependsOn
    to a value that may be null
  • b

    breezy-butcher-78604

    04/07/2020, 7:59 AM
    i’m attempting to create some AWS lambdas with pulumi however I’m having some trouble. my pulumi project is configured so the source code is in
    src/
    rather than in the top level dir. my function definition looks like this:
    const myFunction = new aws.serverless.Function("my-func", {
        callback: (a, b, c) => { console.log(a,b,c); }
    });
    but when i run
    pulumi up
    i get the following error:
    Error reading file '<path-to-project>/src/package.json' when computing package dependencies. Error: ENOENT: no such file or directory, open '<path-to-project>/src/package.json'
    is there a way I can get pulumi to look up a directory? or is there a way i can define a function inline without it having to check the package.json?
    s
    g
    f
    • 4
    • 18
  • r

    rough-tomato-98795

    04/07/2020, 2:30 PM
    Hello i am trying to write dynamic provider which will call external api and should cancel the deployment process creation when there is error in the response. Is it possible to do that.?
    a
    • 2
    • 8
  • c

    colossal-room-15708

    04/08/2020, 10:00 PM
    I think I'm way deep in the rabbit hole and I need someone to help me out with this super basic thing... I've got a resource that accepts a JSON.stringify() string. How do I read a json file in the same folder (call it
    template.json
    ) into this property? I tried way too many things now and they all seem way too complex (SO answers usually are).
    s
    • 2
    • 2
  • b

    boundless-airport-99052

    04/09/2020, 3:58 PM
    Hi, I wonder if we can use
    pulumi.Output
    with
    await
    to be used in an
    async
    method?
  • b

    boundless-airport-99052

    04/09/2020, 4:00 PM
    In my case, I’m creating a
    ComponentResource
    and want to use
    await
    in the
    initialize
    function as below:
    export class MyComponent extends pulumi.ComponentResource {
        protected async initialize(args: Inputs): Promise<any> {
             await pulumi.output(args.inputA).apply(value => ....)
        }
    }
    w
    • 2
    • 4
  • m

    miniature-arm-21874

    04/10/2020, 6:30 PM
    When serializing lambda functions is it possible to run a specific method and keep additional code inside the function but not in the handler?
    const lambda = async (event, context) => {
      const knex = Knex(...);
      knex.query(...)
    }
    this establishes a connection inside of the function invocation and as a result can't be used between separate invocations with lambda's container use but also takes time to start up each time as a result. The best practices suggest initialising sdks and connections outside of the handler https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html is it possible to create lambdas a bit like in the below example?
    const knex = Knex(...);
    const lambda = async (event, context) => {
      knex.query(...)
    }
    t
    a
    • 3
    • 11
  • e

    eager-pillow-75917

    04/13/2020, 12:35 PM
    Hi, I am new to Pulumi and I noticed that contrair to Terraform, that the tf files just need to be in the same directory, Pulumi deploys from the
    index.ts
    . I am separating my infrastructure into separate file for sake of organization and separation. But I noticed that I not only have to import to index.ts, but I have to use it somehow. Even it is a simple export of output in the end for Pulumi to deploy whatever it is on the import. Is there a better way to do this? A best practice maybe that most of you are following?
    l
    f
    w
    • 4
    • 5
  • c

    cuddly-smartphone-89735

    04/15/2020, 3:53 PM
    Say, I have a
    ComponentResource
    , that slowly grows too big to be all in one file. Is it good practice to structure parts of the resources in another file using a function or plain class, so that the "internal" structure is not reflected in the pulumi state, but I still get to make it more readable? Would you prefer a function or a plain class? Or a whole other concept for this?
    g
    • 2
    • 2
  • l

    limited-rainbow-51650

    04/16/2020, 10:21 AM
    I have Typescript package A where I create
    export abstract class Network extends pulumi.ComponentResource
    . In package B, depending on A, I create a concrete subclass
    class GoogleNetwork extends network.Network
    . In the same file where this concrete class is defined, I use it via
    this.virtualNetwork = new GoogleNetwork(name)
    . The build works, but when running tests, I get this error:
    TypeError: Class constructor Network cannot be invoked without 'new'
        at new GoogleNetwork (/Users/ringods/Projects/cumundi/blueprints/libraries/packages/network-gcp/src/index.ts:21:23)
        at GoogleNetworkBuilder.network (/Users/ringods/Projects/cumundi/blueprints/libraries/packages/network-gcp/src/index.ts:29:31)
        at Object.<anonymous> (/Users/ringods/Projects/cumundi/blueprints/libraries/packages/network-gcp/test/simple.ts:5:6)
        ...
    This is probably something missing in my
    tsconfig.json
    files, but I failed to find what so far. I experimented with the following
    compilerOptions
    so far:
    target
    ,
    module
    ,
    moduleResolution
  • l

    limited-rainbow-51650

    04/16/2020, 12:37 PM
    No progress so far. When I search for the
    TypeError: Class constructor …
    error message, I bump into this SO article: https://stackoverflow.com/questions/50203369/class-constructor-cannot-be-invoked-without-new-typescript-with-commonjs/50203532#50203532 Where they advice to set the
    target
    at least to
    ES6
    . Like the Pulumi libs, I
    target: "ES2016"
    , so that shouldn’t be a problem, right.
Powered by Linen
Title
l

limited-rainbow-51650

04/16/2020, 12:37 PM
No progress so far. When I search for the
TypeError: Class constructor …
error message, I bump into this SO article: https://stackoverflow.com/questions/50203369/class-constructor-cannot-be-invoked-without-new-typescript-with-commonjs/50203532#50203532 Where they advice to set the
target
at least to
ES6
. Like the Pulumi libs, I
target: "ES2016"
, so that shouldn’t be a problem, right.
View count: 3