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

    little-market-63455

    06/01/2021, 4:05 PM
    Hi folks, another question. I guess top-level await support is still not upon us correct? At least this issue doesn't seem to provide a solution just yet
    b
    • 2
    • 4
  • b

    brash-airline-37413

    06/02/2021, 4:15 AM
    Anyone got a second to help me with this. Completely stuck. https://github.com/pulumi/pulumi/issues/7179
    b
    • 2
    • 2
  • b

    bitter-australia-87528

    06/03/2021, 7:52 AM
    Hi, just wondering if there is a way to auto generate typescript types for the config.
    k
    • 2
    • 22
  • g

    green-morning-1318

    06/03/2021, 11:19 PM
    Not trying to sell anything, but just sharing because I'm really happy Lightbend got on the Pulumi bandwagon too 😎 we've added support to deploy Akka Cloud Platform using Pulumi https://github.com/lightbend/akka-cloud-platform-deploy 🙌
    😛artypus: 2
    🙌 2
    c
    • 2
    • 1
  • e

    echoing-zebra-28421

    06/04/2021, 2:29 PM
    Does anyone know why it lasts a long time in this step?
  • e

    echoing-zebra-28421

    06/04/2021, 2:32 PM
    My code is
    // Create the role for the Lambda to assume
    const lambdaRole = new aws.iam.Role("lambdaRole", {
      assumeRolePolicy: {
        Version: "2012-10-17",
        Statement: [
          {
            Action: "sts:AssumeRole",
            Principal: {
              Service: "<http://lambda.amazonaws.com|lambda.amazonaws.com>",
            },
            Effect: "Allow",
            Sid: "",
          },
        ],
      },
    });
    
    // Attach the fullaccess policy to the Lambda role created above
    const rolepolicyattachment = new aws.iam.RolePolicyAttachment(
      "lambdaRoleAttachment",
      {
        role: lambdaRole,
        policyArn: aws.iam.ManagedPolicy.AWSLambdaBasicExecutionRole,
      }
    );
    
    // Create the Lambda to execute
    const lambda = new aws.lambda.Function("lambdaFunction", {
      code: new pulumi.asset.AssetArchive({
        ".": new pulumi.asset.FileArchive("./src/app"),
      }),
      runtime: "nodejs12.x",
      role: lambdaRole.arn,
      handler: "index.handler",
    });
    
    // Give API Gateway permissions to invoke the Lambda
    const lambdapermission = new aws.lambda.Permission("lambdaPermission", {
      action: "lambda:InvokeFunction",
      principal: "<http://apigateway.amazonaws.com|apigateway.amazonaws.com>",
      function: lambda,
    });
    
    // Set up the API Gateway
    const apigw = new aws.apigatewayv2.Api("httpApiGateway", {
      protocolType: "HTTP",
      routeKey: "GET /",
      target: lambda.invokeArn,
    });
    
    export const endpoint = apigw.apiEndpoint;
  • e

    echoing-zebra-28421

    06/04/2021, 2:36 PM
    c
    • 2
    • 2
  • e

    echoing-zebra-28421

    06/04/2021, 3:45 PM
    Does anyone have an example where multiple routes from apigatewayv2 are implemented?
  • e

    echoing-zebra-28421

    06/04/2021, 3:46 PM
    for example:
    const api = new awsx.apigateway.API(`airship-api-${NODE_ENV}`, {
      routes: [
        {
          path: "/",
          method: "GET",
          eventHandler: async (event: APIGatewayProxyEvent) => ({
            statusCode: HttpStatus.OK,
            body: "Hello, API Gateway V4!",
          }),
        },
        {
          path: "/api/named_users/associate",
          method: "POST",
          eventHandler: async (event: APIGatewayProxyEvent): Promise<any> => ({
            statusCode: HttpStatus.OK,
            body: JSON.stringify(await handleSetNamedUser(event)),
            isBase64Encoded: false,
          }),
        },
        {
          path: "/api/channels/tags",
          method: "POST",
          eventHandler: async (event: APIGatewayProxyEvent) => ({
            statusCode: HttpStatus.OK,
            body: JSON.stringify(await handleSetTags(event)),
            isBase64Encoded: false,
          }),
        },
      ],
    });
    I want to make something if
    c
    • 2
    • 11
  • e

    echoing-zebra-28421

    06/06/2021, 1:38 AM
    Hello everyone, I have a query. Has someone managed to implement Inversifyjs within Pulumi? I get this error when I follow the implementation of the Inversifyjs documentation:
    Method Map.prototype.has called on incompatible receiver #<Map>","stack":["TypeError: Method Map.prototype.has called on incompatible receiver #<Map>
  • c

    curved-pharmacist-41509

    06/07/2021, 5:01 AM
    https://www.npmjs.com/package/@wanews/nx-pulumi - for those using NX for mono repos, have created a NX plugin which makes it pretty easy to use Pulumi with NX
    ✅ 1
    🙌 2
  • g

    gorgeous-country-43026

    06/08/2021, 7:14 AM
    Is there an easy way to convert an array of
    Output
    objects into one? I am aware of
    pulumi.all
    but that has been defined for explicit amount of arguments and as such it doesn't work with
    Function.prototype.apply
    as far as I see it
  • g

    gorgeous-country-43026

    06/08/2021, 7:14 AM
    I get a variable amount of Outputs and would want to wait until all of them are done and then do stuff on all of them
  • g

    gorgeous-country-43026

    06/08/2021, 7:18 AM
    Hmm. Maybe a simple
    pulumi.output(myArrayOfOutputs)
    could do it... At least it returns a
    pulumi.UnwrappedArray
  • s

    steep-toddler-94095

    06/08/2021, 7:50 AM
    should be able to use
    pulumi.all
    for this
    const asdf = [] as Array<Output<string>>
    pulumi.all(asdf).apply(x=>x) // x will be type string[] here
    l
    • 2
    • 5
  • e

    echoing-zebra-28421

    06/09/2021, 8:53 PM
    Hello everyone, I have a problem and I can't solve it. I want to implement path aliases in typescript. when i run:
    pulumi up -y -s dev
    my error
    TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Array
    this is my
    tsconfig.ts
    {
      "compilerOptions": {
        "baseUrl": "./src",
        "paths": {
          "@application/*": [
            "application/*"
          ],
          "@config/*": [
            "config/*"
          ],
          "@domain/*": [
            "domain/*"
          ],
          "@api-route": [
            "api-route.ts"
          ],
          "@interfaces/*": [
            "interfaces/*"
          ]
        },
        "strict": true,
        "outDir": "bin",
        "target": "ESNEXT",
        "lib": [
          "ESNEXT"
        ],
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "experimentalDecorators": true,
        "pretty": true,
        "noFallthroughCasesInSwitch": true,
        "noImplicitReturns": true,
        "esModuleInterop": true,
        "emitDecoratorMetadata": true,
        "skipLibCheck": true,
        "forceConsistentCasingInFileNames": true,
        "typeRoots": [
          "./node_modules/@types"
        ],
        "types": [
          "@types/node",
          "node"
        ]
      },
      "files": [
        "src/handler.ts"
      ],
      "include": [
        "src/**/*.ts"
      ],
      "exclude": [
        "node_modules"
      ]
    }
    my package.json
    {
      "name": "api-notifications",
      "scripts": {
        "lint": "tslint -p tsconfig.json -c tslint.json",
        "prettify": "prettier . --write"
      },
      "main": "src/handler.ts",
      "devDependencies": {
        "@types/aws-sdk": "^2.7.0",
        "@types/dotenv": "^8.2.0",
        "@types/node": "^10.17.60",
        "typescript": "^4.2.4",
        "tslint": "^6.1.3",
        "tslint-config-airbnb": "^5.11.2"
      },
      "_moduleAliases": {
        "@application": [
          "bin/application"
        ],
        "@config": [
          "bin/config"
        ],
        "@domain": [
          "bin/domain"
        ],
        "@interfaces": [
          "bin/interfaces"
        ]
      },
      "dependencies": {
        "@pulumi/aws": "^4.0.0",
        "@pulumi/awsx": "^0.30.0",
        "@pulumi/pulumi": "^3.0.0",
        "@types/aws-lambda": "^8.10.76",
        "axios": "^0.21.1",
        "dotenv": "^9.0.2",
        "module-alias": "^2.2.2"
      }
    }
    Any idea or example to add the path aliases? for example: instead of this
    import { CustomEventService } from "../../../application/services/custom-event/custom-event.service";
    use this:
    import { CustomEventService } from "@application/services/custom-event/custom-event.service";
    in my
    ./src/handler.ts
    I add
    import "module-alias/register";
    l
    c
    • 3
    • 22
  • l

    little-fish-42857

    06/16/2021, 7:42 PM
    hello, i was wondering if anyone knows an elegant way to write a dynamic provider that is only used as a data source? we want to retrieve the kubernetes cluster version and use it as an input for a helm chart deployment.
  • a

    abundant-king-20145

    06/16/2021, 10:22 PM
    Hello, I have an issue writing unit tests in pulumi-ts. It throws me this:
    Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
    When you use a debugger the call ends when a resource is being created. Doing that things after the resource creation are unreachable: Here is my test .
    import * as pulumi from '@pulumi/pulumi';
    import { MockCallArgs } from '@pulumi/pulumi/runtime';
    import { describe, it, before } from 'mocha';
    
    pulumi.runtime.setMocks({
        newResource: function(args: pulumi.runtime.MockResourceArgs): {id: string, state: any} {
            return {
                id: args.inputs.name + "_id",
                state: args.inputs,
            };
        },
        call: function(args: MockCallArgs) {
            return args.inputs;
        },
    });
    
    describe('Example Service',  () => {
        let definitions: typeof import('./service-example');
        before(async () => {
            definitions = await import('./service-example');
        })
        it('should forward port 80 to 80', (done) => {
            pulumi.all([definitions.ServiceExample]).apply(([ServiceExample]) => {
                const se = new ServiceExample()
                const service = se.aService;
                done()
            })
    
        });
    })
    And my base class that I want to test.
    import * as k8s from '@pulumi/kubernetes';
    import {ComponentResource} from "@pulumi/pulumi";
    
    export class ServiceExample extends ComponentResource{
        private name: string = 'S1'
        aService: k8s.core.v1.Service;
    
        constructor() {
            super('k8s:Service', 'S1');
            this.aService = this.createService()
        }
    
        createService: () => k8s.core.v1.Service = () => {
            return new k8s.core.v1.Service(
                this.name = '-service',
                {
                    metadata: {
                        name: this.name,
                        namespace: 'one'
                    },
                    spec: {
                        selector: {
                            foo: 'bar'
                        },
                        ports: [
                            {
                                name: 'http',
                                port: 80,
                                targetPort: 80}
                        ]
                    }
    
                }
            )
        }
    }
    And here is the repo if you want to clone it and test it on your own: https://gitlab.com/diego.huerta/pulumi-example
  • a

    acceptable-army-69872

    06/21/2021, 6:49 PM
    Are there feelings on arrays of interfaces vs maps in typescript? I have an "org" pulumi project for managing all the cross role organization configuration, as well as DNS. At the moment it's just a big array of json'y looking
    [{"Name":"", "Email": "", "Tags":"", "AdminRoles":[], "RORoles":[], "ZoneDelegation":[]}]
    . It's a gross, but working fine. When I was just doing the roles, it was pretty easy to use a single loop where I created a provider per account. Now that I've added DNS, I'm thinking I'd like to have a single provider per account that I can pass around instead of a provider per account per type of activity. Seems like it could easily be an array of interfaces, that I access the right account provided doing some map/filters, or it could be a map type of
    <string, aws.Provider>
    . Y'all got thoughts on which method may be prefered? Or should I go traipsing down the "turn your big gross json blob into objects, and store the provider in an account member" path?
    • 1
    • 1
  • g

    gorgeous-country-43026

    06/22/2021, 9:04 AM
    Is there a way for me to generate YAML out of Pulumi kubernetes object without actually creating that specific resource into the cluster? I know this is a very specific request but the reason I would need this is that a 3rd party app ran on our k8s cluster supports providing a job template yaml to it as a file (yes, as a file, it doesn't support ConfigMaps etc). I would like to generate that file based on other cluster data that Pulumi is controlling. Generating a valid YAML file out of Pulumi resources with
    Output
    abstraction is not a trivial task and I would assume Pulumi is actually under the hood generating YAML anyway from the definitions it would make sense if one could also export that data out somehow. However, I think this is not possible since as far as I can see it, Pulumi automatically registers a resource to state when you say
    new <resourcetype
    and you can't override this functionality, right? If the answer to my question is what I think it is then my follow up question is: is there a ready tool or library function that could take in TypeScript data (objects, arrays etc) with Pulumi
    Output
    and it would return a valid YAML string with
    Output
    values properly populated? If the answer to that one is "no" then I have one additional question: how can I reliably generate a string dynamically recursively in such a way that
    Output
    objects are handled correctly? I actually wrote this simple "data to YAML" converter where I tried to handle the
    Output
    objects correctly but unfortunately it doesn't seem to work that well...
    b
    s
    • 3
    • 17
  • e

    elegant-crayon-4967

    06/22/2021, 9:37 PM
    Curious how folks out there are handling creating an EC2 Instance and in the same stack, passing the Instance ID as a string for an SSM Parameter?
    l
    a
    +2
    • 5
    • 32
  • b

    breezy-cricket-40277

    06/25/2021, 4:41 PM
    Testing - Not detecting that is running a test
    b
    f
    h
    • 4
    • 11
  • g

    green-daybreak-98726

    06/29/2021, 11:35 PM
    In another weird state: • During
    pulumi up
    a delete that had other requirements was running, then errored so which canceled out of the script. • Tried to re-run
    pulumi up
    , and the state now hangs on that part. • Ran a
    pulumi refresh
    to see if it resolved any issues, fails on:
    error: the current deployment has 1 resource(s) with pending operations:
      * {URN}, interrupted while deleting
    • Tried running
    pulumi state delete {URN}
    to manually remove problem resources, but get an error where it wants me to delete dependencies first but those dependencies don't exist anymore, so I cant technically delete them. Out of curiosity, is the best way to resolve this to run
    pulumi stack export
    fix the issues and reimport? Or is there a more elegant way to remove this corrupt state?
    s
    • 2
    • 2
  • c

    cold-motherboard-287

    07/01/2021, 2:57 PM
    What would be the recommended pattern to have async "things" happening inside of a
    ComponentResource
    ? I need to use
    await
    and inside of the constructor, AFAIK, is not possible.
  • c

    curved-pharmacist-41509

    07/02/2021, 2:33 PM
    Wrap the promise in
    pulumi.output()
    . It then can use pulumi’s input/output approach to handle it
  • s

    steep-toddler-94095

    07/02/2021, 11:29 PM
    Is it possible to have pulumi use the
    tsconfig.json
    file at the root of my repo? I'm getting an error when trying to use
    .flatMap
    even though I have
    es2019
    added to my root tsconfig's
    lib
    . It only works if I create a new tsconfig inside the stack's dir but I'd like to avoid having to do this for every stack
    • 1
    • 1
  • c

    cold-motherboard-287

    07/06/2021, 7:45 AM
    I'm trying to handle exceptions in typescript (inside of an async code). What would be the proper way of handling it? I've not found an exception class or something that I could use to cast such error.
    error: Running program '/home/user/development/company/aws-iam-provisioning' failed with an unhandled exception:
    Error: invocation of aws😒sm/getParameter:getParameter returned an error: invoking aws😒sm/getParameter:getParameter: 1 error occurred:
    * Error describing SSM parameter (eks-name2): ParameterNotFound:
    at Object.callback (/home/user/development/company/aws-iam-provisioning/node_modules/@pulumi/pulumi/runtime/invoke.js:139:33)
    at Object.onReceiveStatus (/home/user/development/company/aws-iam-provisioning/node_modules/@grpc/grpc-js/src/client.ts:338:26)
    at Object.onReceiveStatus (/home/user/development/company/aws-iam-provisioning/node_modules/@grpc/grpc-js/src/client-interceptors.ts:426:34)
    at Object.onReceiveStatus (/home/user/development/company/aws-iam-provisioning/node_modules/@grpc/grpc-js/src/client-interceptors.ts:389:48)
    at /home/user/development/company/aws-iam-provisioning/node_modules/@grpc/grpc-js/src/call-stream.ts:276:24
    at processTicksAndRejections (node:internal/process/task_queues:78:11)
    s
    • 2
    • 5
  • b

    breezy-butcher-78604

    07/07/2021, 3:32 AM
    can anyone help me understand why upgrading from
    @pulumi/aws
    v3.0.0 to v3.38.1 causes the next
    pulumi up
    to remove the AWS tags assigned to some (not all) resources in the stack?
    • 1
    • 2
  • g

    green-pencil-17360

    07/07/2021, 10:59 PM
    Hello, I have a problem with the paraphrase. It did not prompt for the second time when I did the
    pulumi up
    . It actually forced me to set up the pass-phrase when I created the stack. It is throwing me the following error.
    constructing secrets manager of type "passphrase": unable to find either `PULUMI_CONFIG_PASSPHRASE` or `PULUMI_CONFIG_PASSPHRASE_FILE` when trying to access the Passphrase Secrets Provider; please ensure one of these environment variables is set to allow the operation to continue
  • m

    many-salesmen-89069

    07/08/2021, 9:20 AM
    Hello, I’m trying to find the documentation for
    aws.lambda.CallbackFunction
    , tutorials link to this page, but there is nothing there. Could somebody point me to the right direction?
    b
    c
    l
    • 4
    • 6
Powered by Linen
Title
m

many-salesmen-89069

07/08/2021, 9:20 AM
Hello, I’m trying to find the documentation for
aws.lambda.CallbackFunction
, tutorials link to this page, but there is nothing there. Could somebody point me to the right direction?
b

brave-planet-10645

07/08/2021, 10:49 AM
What's the original page that linked through to the callbackfunction that wasn't there?
m

many-salesmen-89069

07/08/2021, 12:21 PM
I’ve closed those tabs sorry
is there a doc page for it? would be good to see some typescript examples
c

cool-fireman-90027

07/08/2021, 2:39 PM
Does this help: https://www.pulumi.com/docs/guides/crosswalk/aws/lambda/#register-an-event-handler-using-a-magic-lambda-function
l

little-cartoon-10569

07/08/2021, 11:14 PM
Unfortunately the docs are based on Terraform, and those mixins are added by Pulumi. The best source of info is the source code, I think.
m

many-salesmen-89069

07/09/2021, 9:29 AM
thanks!
View count: 1