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

    elegant-crayon-4967

    04/28/2021, 9:14 PM
    trying to upload a list of files to S3, then save the arns of those objects to a list that I can pass later in my program. Anyone know of an elegant way to do this?
    b
    • 2
    • 24
  • e

    elegant-pager-5412

    04/29/2021, 4:39 AM
    Good Morning! It seems like the
    serializeFunction
    is having an issue serializing TypeORM active record entities. I’ve opened an issue regarding this with easy reproduction steps: https://github.com/pulumi/pulumi/issues/6908 Maybe someone here bumped into this and solved it?
  • p

    polite-shoe-79877

    04/29/2021, 10:11 AM
    How do you guys import json files? i have this in my ts file
    import serviceConfig from '../appsettings.json';
    this in ts config
    {
        "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"
        ]
    }
    But iam till gettin this error Cannot find module '../appsettings.json'. Consider using '--resolveJsonModule' to import module with '.json' extension
  • d

    damp-school-17708

    04/29/2021, 10:56 AM
    I think that's just a "resolveJsonModule": true in your ts config
    p
    e
    • 3
    • 4
  • m

    mysterious-wolf-74677

    04/29/2021, 10:06 PM
    I keep getting an error, and I'm not quite sure how to get around it:
    aws:iam:RolePolicy (fooRolePolicy):
        error: aws:iam/rolePolicy:RolePolicy resource 'fooRolePolicy' has a problem: "policy" contains an invalid JSON: invalid character '\n' in string literal
    the resource is built like this:
    new aws.iam.RolePolicy('fooRolePolicy', {
      role: fooRole.id,
      policy: `{
                "Version": "2012-10-17",
                "Statement": [
                  {
                    "Sid": "AWSCloudTrailCreateLogStream",
                    "Effect": "Allow",
                    "Action": [
                      "logs:CreateLogStream",
                      "logs:PutLogEvents"
                    ],
                    "Resource": "${foobarLogGroup.arn}:*"
                  }
                ]
              }`,
    })
  • m

    mysterious-wolf-74677

    04/29/2021, 10:06 PM
    What am I doing wrong?
    l
    • 2
    • 17
  • m

    mysterious-wolf-74677

    04/29/2021, 10:07 PM
    should I make the policy flat? instead of with the carriage returns? or is there something I have incorrect in my policy?
  • m

    mysterious-wolf-74677

    04/29/2021, 10:08 PM
    I was following along with this: https://www.pulumi.com/docs/reference/pkg/aws/cloudtrail/trail/#sending-events-to-cloudwatch-logs
  • b

    breezy-butcher-78604

    04/30/2021, 3:19 AM
    why does requiring stack outputs return an
    Output<T>
    instead of just
    T
    or
    Promise<T>
    ? stack outputs will be known at preview time but since they return
    Output<T>
    i can't use those values until deploy time
    r
    l
    • 3
    • 11
  • m

    mysterious-oyster-86659

    05/03/2021, 7:13 PM
    Happy Monday, Everyone👋 Issues with deploying the following
    TS
    -formatted
    Lambda
    resource to provision a
    Python
    runtime, which already exists in S3 as a zip. Any thoughts to solutions for my use-case...? Note that all other resources referenced in properties for the
    Lambda
    are valid and exist in my stack.
    export const campuSolutionsLambdaIngestCleaner = new aws.lambda.Function(
        "campus-solutions-lambda-ingest-cleaner-foo",
        {
            name: "campuSolutions-LambdaIngestCleaner-foo",
            role: campusSolutionsLambdaRole.arn,
            // code: lambdaScriptBucketObjectCampuSolutionsCleaner,
            s3Bucket: lambdaScriptBucketObjectCampuSolutionsCleaner.bucket,
            s3Key: lambdaScriptBucketObjectCampuSolutionsCleaner.key,
            memorySize: 9000,
            runtime: "python3.8",
            timeout: 800,
            vpcConfig: {
                securityGroupIds: [lambdaSqlRedshiftSecurityGroupfoo.id],
                subnetIds: [
                    config.require("az0SubnetPrivateId"),
                    config.require("az1SubnetPrivateId"),
                ],
            },
            tags: tags(),
        },
        { deleteBeforeReplace: true },
    )
    *ERROR*(s):
    * filename, s3_* or image_uri attributes must be set
    or sometimes, it's this...
    error creating Lambda Function: ValidationException: status code: 400, request id: e8e53a21-e586-4bd1-a0dc-e9aa5627a87f
  • f

    fresh-hospital-81544

    05/04/2021, 12:57 AM
    https://www.pulumi.com/docs/reference/pkg/aws/acm/certificatevalidation/
    const exampleRecord: aws.route53.Record[];
    for (const range of Object.entries(exampleCertificate.domainValidationOptions.apply(domainValidationOptions => domainValidationOptions.reduce((__obj, dvo) => { ...__obj, [dvo.domainName]: {
        name: dvo.resourceRecordName,
        record: dvo.resourceRecordValue,
        type: dvo.resourceRecordType,
    } }))).map(([k, v]) => {key: k, value: v})) {
        exampleRecord.push(new aws.route53.Record(`exampleRecord-${range.key}`, {
            allowOverwrite: true,
            name: range.value.name,
            records: [range.value.record],
            ttl: 60,
            type: range.value.type,
            zoneId: exampleZone.then(exampleZone => exampleZone.zoneId),
        }));
    }
    Hi, typescript noob so bear with me. The above code is copy+paste from the docs and it gives a lot of compiler errors. does anyone know how it should be? Thanks
    l
    • 2
    • 9
  • e

    elegant-pager-5412

    05/05/2021, 1:15 PM
    Hey guys! There is a major pain I’m trying to think how to handle. I have a layer that injects some common nodejs modules. This layer is attached to some lambda I have. Now when I write my lambda code that relies on that package, I also import the package at the top of the file. What happens then is that Pulumi attempts to bundle that package into my lambda code, even tho the only reason I have it installed is so I can create a layer with this module. How can we tell Pulumi not to bundle this package? Also, Pulumi does not respect tree-shaking and bundles the entire package even if I’m using a subset of the package. Is my only option here is to pipe my code through a more “intelligent” such as webpack to do the tree-shaking for me?
    r
    • 2
    • 2
  • i

    incalculable-hairdresser-41711

    05/10/2021, 11:17 AM
    question about committing stack configuration files, if I've created a secret with pulumi as the provider, is that safe to commit? just curious is all. I know I could probably set up the secret provider to AWS and then reference the arn in my stack definition
    ✅ 1
    w
    • 2
    • 2
  • w

    worried-boots-97291

    05/11/2021, 10:57 AM
    Hello, we're using Pulumi v3.2.1 and Azure-Native 1.1.0. We want to unit test creating resources. We've followed the guide here: https://www.pulumi.com/docs/guides/testing/unit/ Unit tests are written in Typescript with Jest Our Mock looks like this:
    runtime.setMocks({
        newResource(args: MockResourceArgs): { id: string | undefined; state: Record<string, any> } {
            const { type, id, name } = args;
            expect(type).toEqual("azure-nextgen:network/latest:Subnet");
            return {
                id,
                state: {
                    ...args.inputs,
                    name,
                },
            };
        },
        call(args: MockCallArgs) {
            return args.inputs;
        },
    });
    Running tests give: `Program run without the Pulumi engine available; re-run using the
    pulumi
    CLI` Is anyone able to help with why this is?
    l
    • 2
    • 3
  • e

    elegant-pager-5412

    05/12/2021, 7:30 AM
    Hey guys, Why isn’t Pulumi tree-shaking incldued node_modules? The behavior I see is that Pulumi detects usage of a node_module (such as
    data-fns
    ) and simply copy the entire folder into the lambda’s code. Why can’t Pulumi only copy the subset of features used?
  • f

    fast-vegetable-68654

    05/12/2021, 3:10 PM
    Is there a better way to do this? I want to take the output from another stack (
    rootAccountId
    ) and use it when creating the principal for a role.
    const rootAccountId = organization.getOutput('rootAccountId'); <-- output from another stack
    
    const adminRole = createRole({
      allowedActions: accountRoles.admin,
      principal: {
        AWS: [rootAccountId.apply((id) => `arn:aws:iam::${id}:root`)],
      },
      roleName: 'admin',
    });
    
    export function createRole({
      allowedActions,
      principal,
      roleName,
    }: {
      allowedActions: string[];
      principal: aws.iam.Principal;
      roleName: string;
    }) {
      const role = new aws.iam.Role(`${roleName}-role`, {
        assumeRolePolicy: aws.iam.assumeRolePolicyForPrincipal(principal),
      });
      ...
    }
  • l

    little-cartoon-10569

    05/13/2021, 1:59 AM
    I'm unit testing (mocha+pulumi.runtime.setMocks()) and getting an error aynchronously. The offending test is passing, and about 4 or 5 tests later, another test fails with an error obviously caused by my changed suite.
    • 1
    • 17
  • p

    proud-spoon-58287

    05/13/2021, 11:42 AM
    Hi all, upgraded from pulumi v2 to v3. I am seeing a strange error with this part:
    aws:elasticache:Cluster (data-feed-control):
        error: unmarshaling urn:pulumi:development::platform-data-feed::aws:elasticache/cluster:Cluster::data-feed-control's instance state: could not read field snapshot_arns: '' expected type 'string', got unconvertible type '[]interface {}', value: '[]'
    in this part:
    return new aws.elasticache.Cluster('data-feed-control', {
      clusterId: 'data-feed-control',
      engine: 'redis',
      engineVersion: '6.x',
      nodeType: 'cache.t3.micro',
      numCacheNodes: 1,
      parameterGroupName: 'default.redis6.x',
      securityGroupIds: [defaultSecurityGroup.id],
      subnetGroupName: feedControlSubnetGroup.id
    })
    c
    a
    • 3
    • 28
  • m

    melodic-easter-82419

    05/13/2021, 4:18 PM
    Currently, I am trying to export out an object of key,values in a pulumi stack. This is mostly setup to automate our pipeline deployment with resources generated by pulumi. Problem I am having is getting this to populate correctly.
    export const resources = pulumiResources.reduce(
      (result, res) => ({
        ...result,
        [res.location]: {
          // This variable is Output<string>
          resourceGroup: res.resourceGroup,
          otherProperty: res.foo,
        },
      }),
      {}
    );
    Problem I am running into is when I try to run pulumi.apply in order to set the key as a string. When I run this, I will either only get the first item in the list applied to the object or I will get the last object of list applied.
    export const resources = pulumiResources.reduce((result, res) =>
      res.location.apply(
        (location) => ({
          ...result,
          [location]: {
            // This variable is Output<string>
            resourceGroup: res.resourceGroup,
            otherProperty: res.foo,
          },
        }),
        {}
      )
    );
    I tried doing a pulumi.all on the resources and this didn’t work either.
    s
    • 2
    • 1
  • r

    red-football-97286

    05/14/2021, 8:23 AM
    Hi, does anyone have any tips how I can dynamically get the AWS account ID and pass it to a function to use to generate a JSON snippet?
    d
    l
    c
    • 4
    • 16
  • m

    microscopic-dress-1605

    05/18/2021, 12:06 PM
    I’m trying to upgrade a Pulumi library (not a program) written in Typescript from Pulumi v2 to v3 without much luck. The unit tests of the library complain with:
    Error: Program run without the Pulumi engine available; re-run using the `pulumi` CLI
    As if the mocks are not taken into account. I’ve done the necessary modifications to the mock definition as defined by the Upgrading to Pulumi v3 documentation. The unit tests worked perfectly well with the v2 of the Pulumi SDK. Note: By Pulumi library I mean it defines a generic set of infrastructure that is reused by several Pulumi programs. So, it does not define a stack. This is similar to Terraform modules. Does anyone has an idea what could be the problem? Thank you for your help.
    • 1
    • 1
  • g

    gray-hamburger-90102

    05/21/2021, 9:27 AM
    Hey, is there a nice way here to get all of the route tables for my VPC? As you can see from my attempt, I can't get an array of the routeTable Ids:
    const vpc = new awsx.ec2.Vpc("BaseNetworkVPC", {
        cidrBlock: "10.50.0.0/22",
        subnets: [
            { type: "public" },
            { type: "private" },
        ],
    });
    
    // this is probably wrong, but not sure how to proceed!
    const vpcPrivateSubnets = pulumi.output(vpc.privateSubnets).apply(psns => psns.map(psns => psns.routeTable?.id));
    
    // I want to make a routeTable propagation for each of my VPC's private subnets
    const routeTablePropagation2 = new aws.ec2.VpnGatewayRoutePropagation("VPGPropagateMainRouteTable", {
            vpnGatewayId: gatewayAssociation.associatedGatewayId,
            routeTableId: // what goes here?
        });
    });
    b
    l
    • 3
    • 7
  • l

    limited-rainbow-51650

    05/21/2021, 10:07 AM
    Hello, trying to get some unit tests running. I base myself on this example: https://github.com/pulumi/examples/blob/master/testing-unit-ts/ec2tests.ts Although I invoke the
    done
    function in both paths of my
    if-else
    , I still get this error:
    Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/r.de.smet/Projects/pulumi-libs/test/gcp/network/index.spec.ts)
    The only difference I have is that I use
    ts-mocha
    rather than
    mocha -r ts-node/register
  • l

    little-market-63455

    05/21/2021, 1:45 PM
    Hi @faint-oil-7535, was going through your example and I cannot see how it would work. According to my understanding all references to types from
    @pulumi
    packages would be removed at runtime and you are referencing
    aws.iam.User
    or am I missing something?
  • h

    hundreds-leather-25986

    05/22/2021, 3:49 PM
    Hi all, Sample datadog query
    max(last_5m):avg:gcp.pubsub.subscription.examplemetric{project_id} by {subscription_id}
    Note:  {subscription_id} //contains multiple values
    Trying to convert into single pulumi datadog monitor help appreciated thanks
  • l

    little-fish-42857

    05/25/2021, 3:40 PM
    Hello, I have a TS pulumi program that is using a dynamic nodejs provider defined within the project. We are seeing a strange issue in our CI system (Gitlab) only. This one's a bit of a headscratcher because I cannot reproduce it outside of CI. It runs preview/up just fine on my local dev env and in my local docker instance (we use the same image in CI) -- however in CI we see this (See thread)
    l
    • 2
    • 7
  • q

    quiet-hairdresser-18834

    05/27/2021, 11:48 PM
    Anyone manage to deploy a certificate that you have on disk to an Azure Keyvault? I am just guess and testing formats/encoding and not having a lot of luck so far
  • q

    quiet-hairdresser-18834

    05/28/2021, 12:17 AM
    const fs = require('fs')
        const data = fs.readFileSync('./Files/certificates/dev.pfx', 'base64')
        var cert = new azure.keyvault.Certificate("LetsEncrypt", {
            name: "LetsEncrypt",
            keyVaultId: keyVaultId,
            certificate: {
                contents: data,
                password: "MyPassword"
            },
            certificatePolicy: {
                 issuerParameters: {
                     name: "Unknown"
                },
                keyProperties: {
                    exportable: false,
                    keyType: "RSA",
                    reuseKey: false,
                    keySize: 2048
                },
                secretProperties: {
                    contentType: "application/x-pkcs12",
                },
            }
    
        })
  • q

    quiet-hairdresser-18834

    05/28/2021, 12:17 AM
    figured it out for those who may need it
    👍 1
  • l

    limited-rainbow-51650

    05/31/2021, 9:51 AM
    Quick question: one of my colleagues reports that he has to run the typescript transpiler manually for his pulumi project. I fail to find what is missing from his setup why he has to do that. Does anyone know what “config” is used by Pulumi CLI to determine that the project is Typescript?
    l
    • 2
    • 1
Powered by Linen
Title
l

limited-rainbow-51650

05/31/2021, 9:51 AM
Quick question: one of my colleagues reports that he has to run the typescript transpiler manually for his pulumi project. I fail to find what is missing from his setup why he has to do that. Does anyone know what “config” is used by Pulumi CLI to determine that the project is Typescript?
l

little-cartoon-10569

05/31/2021, 9:14 PM
Has he turned off the built-in transpilation as described here? https://www.pulumi.com/docs/intro/languages/javascript/#disabling-built-in-typescript-support
View count: 5