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

    white-rainbow-68240

    07/13/2020, 1:18 PM
    Maybe I'm approaching this from the wrong angle. Maybe this is a docker container problem.
  • s

    salmon-ghost-86211

    07/15/2020, 2:52 PM
    I'm trying to create access keys, write a few fields into a new JSON object and convert it to ciphertext, then save it to S3 as a new file. Before this code I create a KMS key (myKms), and IAM user (iamUser) and have an S3 bucket object defined (myS3Bucket). If 
    userIamAccessKeys.id
     or 
    userIamAccessKeys.secret
     is the only 
    content
     on the BucketObject, it writes successfully. If  
    encryptedKeys
     ciphertext is the 
    content
    , the text written is 
    [object Object]
    . I can't seem to use 
    toJSON
     or 
    toString
     or 
    .apply
     to build the ciphertext. How do I pull out some details from the 
    AccessKey
    , convert it to 
    Ciphertext
     and insert it into the 
    BucketObject
     
    content
    ?
    const userIamAccessKeys = new aws.iam.AccessKey(
        "iam-access-key",
        { user: iamUser.name, },
        { dependsOn: iamUser }
    );
    
    const encryptedKeys = new aws.kms.Ciphertext(
        "user-encrypted-keys",
        {
            keyId: myKms.keyId,
            plaintext: `{
              "access_key": ${userIamAccessKeys.id},
              "secret_key": ${userIamAccessKeys.secret}
            }
            `
        },
        { dependsOn: userIamAccessKeys }
    );
    
    // Store the already encrypted access keys in S3
    const accessKeysInS3 = new aws.s3.BucketObject(
        "access-keys-in-s3",
        {
            bucket: myS3Bucket.apply(bucket => bucket.id),
            content: encryptedKeys.toString(),
            key: "accesskeys.json.enc"
        },
        { dependsOn: [userIamAccessKeys, encryptedKeys] }
    );
    g
    • 2
    • 1
  • r

    ripe-russia-4239

    07/15/2020, 8:00 PM
    In my unit tests, I want to be able to make use of the config values for a given stack, so that I can verify that, for example, resources are deployed to the NorthEurope region in Azure even though that’s only specified in my stack config files and not in my Pulumi app. How can I go about doing this? I suspect the config-loading behaviour is overridden by the
    setMocks()
    call, but I haven’t verified that yet.
    g
    • 2
    • 4
  • r

    ripe-russia-4239

    07/15/2020, 8:36 PM
    A further question: I’ve successfully deployed an Azure App Service resource (🎉) but as it’s deploying private images from Docker Hub, the app is currently unavailable. How can I provide the necessary PAT for Docker Hub in the App Service deployment?
    g
    t
    • 3
    • 3
  • q

    quiet-hairdresser-18834

    07/16/2020, 7:23 PM
    Can StackReference outputs only be simple strings or can they be complex types? If they can be complex, how do I convert it to a strong type? I have a collection of base azure.types.input.network.NetworkSecurityGroupSecurityRule[] that I export from my core stack and want that available in my dev/test stacks
    l
    • 2
    • 2
  • b

    billions-lock-80282

    07/29/2020, 2:03 PM
    Hi, I've just updated to Pulumi 2 and fixing up the new asynchronous code. How do I access a single subnet in an array of subnets of type
    Promise<pulumi.Output<string>[]>
    ? This is for an ec2 instance subnet field.
    s
    • 2
    • 3
  • b

    bland-telephone-59986

    07/29/2020, 2:32 PM
    Hi, I’m wondering if it possible to use pulumi.Output<string> as a string argument to fs.copyFile src or dest. I want to copy files from kubernetes render provider “rendertoyaml” directory to another one.
  • q

    quiet-hairdresser-18834

    07/31/2020, 1:24 AM
    Is it possible to wait in a pulumi script? I am having issues with a service principal not being replicated so I would like to wait X seconds to see if that fixes it
    w
    • 2
    • 1
  • n

    nutritious-battery-42762

    08/05/2020, 12:44 PM
    i want to auto update godaddy records but the only solution i found is https://github.com/baronfel/pulumi-godaddy but it's not working
    e
    • 2
    • 1
  • n

    nutritious-battery-42762

    08/05/2020, 12:46 PM
    any suggestion?
  • p

    proud-spoon-58287

    08/07/2020, 9:04 AM
    Hi all, dumb question:
    export class KsqlDbCluster {
    
        private readonly _clusterName: string
    
        constructor(clusterName: string) {
            this._clusterName = clusterName
        }
        private readonly _k8nCluster: gcp.container.Cluster = this.buildCluster(this._clusterName)
    I am invoking this class this way
    const ksqlDbClusterName = 'ksqldb-cluster'
    const ksqlDbCluster = new KsqlDbCluster(ksqlDbClusterName)
    Why in the world
    this._clusterName
    is undefined?
    b
    l
    c
    • 4
    • 28
  • p

    proud-spoon-58287

    08/07/2020, 9:05 AM
    I am using TS the way I'd use Java. Maybe I am missing something 🙂
  • p

    proud-spoon-58287

    08/07/2020, 11:28 AM
    kubernetes:core:Namespace (ksqldb-cluster):
        error: configured Kubernetes cluster is unreachable: failed to parse kubeconfig data in `kubernetes:config:kubeconfig`; this must be a YAML literal string and not a filename or path - yaml: line 2: mapping values are not allowed in this context
    • 1
    • 3
  • p

    proud-spoon-58287

    08/07/2020, 11:28 AM
    I keep seeing this error while creating a namespace
  • l

    little-cartoon-10569

    08/10/2020, 5:04 AM
    Is it pointless to use any of the resource-getting functions in a resource constructor? I want to call
    awsx.ec2.Vpc.fromExistingIds
    to load a Vpc created elsewhere so that I can create a new route on one of its subnets. But
    awsx.ec2.Vpc#privateSubnets
    is
    async
    , and typescript doesn't allow use of
    await
    in constructors. I assume that I have to use an async function called after my constructor?
    g
    • 2
    • 5
  • l

    little-cartoon-10569

    08/11/2020, 2:26 AM
    I've just upgraded from 2.7.1 to 2.8.2, including binaries (via the nodejs Docker image) and npm packages. I'm now having problems with security group rules. Two of the error messages I get are
    Type 'OutputInstance<number>' is missing the following properties from type 'OutputInstance<number>': apply, get
    and
    'import("/pulumi/projects/node_modules/@pulumi/pulumi/index").OutputInstance<number>' is not assignable to type 'import("/pulumi/projects/node_modules/@pulumi/pulumi/output").OutputInstance<number>'.
    I deleted my node_modules and ran
    npm install
    and
    npm upgrade
    . Any other suggestions?
    f
    • 2
    • 19
  • p

    proud-spoon-58287

    08/12/2020, 10:52 AM
    Hi all, how do I get the target port number from a Service object?
    r
    • 2
    • 1
  • p

    proud-spoon-58287

    08/12/2020, 10:58 AM
    https://www.pulumi.com/docs/reference/pkg/kubernetes/apiextensions/customresource/
  • p

    prehistoric-account-60014

    08/12/2020, 6:57 PM
    I’m attempting to set up a dynamic provider for Stripe webhook endpoints but requests are failing with this error:
    Invalid Stripe API version: [object Object]
    . This is due a serialization issue. Here’s a snippet with the dynamic provider’s source. Any ideas how to avoid this?
    stripe.ts
    h
    w
    • 3
    • 31
  • b

    breezy-butcher-78604

    08/14/2020, 5:01 AM
    is it possible to perform any processing of
    Input<T>
    values? I'm passing an
    Input<aws.ecs.Secret[]>
    to a module i'm writing and I want to do some processing on the various values of
    valueFrom
    within the
    aws.ecs.Secret[]
    so I can collate them into a list of secret ARNs to add to an IAM policy. i can see heaps of docs on using
    Output<T>
    via
    apply()
    etc but there doesn't seem to be any documentation (that I can find) about working with
    Input<T>
    l
    • 2
    • 5
  • l

    little-cartoon-10569

    08/15/2020, 7:59 AM
    Are there any gotchas with try-catch blocks in Pulumi? I have a snippet like this:
    try {
        const stack = new pulumi.StackReference('stackName');
        const someId = peerStack.requireOutput("resourceId") as pulumi.Output<string>;
      } catch (e) {
        if (e instanceof Error) {
          pulumi.log.error(e.message);
          return pulumi.output(`${e.message}`);
        } else {
          pulumi.log.error("Unknown object thrown");
          return pulumi.output("Unknown error");
        }
      }
    I'm expecting this code to report the error and continue working. But I'm getting
    error: Running program '/pulumi/projects/main/pulumi/projects/example' failed with an unhandled exception:
    Error: Required output 'someId' does not exist on stack 'stackName'.
    at /pulumi/projects/node_modules/@pulumi/pulumi/stackReference.js:72:23
    ...
    And preview fails. Even though I have handled the exception... How can I conditionally skip a section of my code if a required output isn't present in another stack?
    a
    • 2
    • 43
  • b

    breezy-butcher-78604

    08/19/2020, 8:31 AM
    I'm trying to create an
    awsx.ecs.FargateTaskDefinition
    using secrets that contain
    Output<string>
    however the underlying type -
    aws.ecs.Secret
    has properties that are
    string
    only. example code below:
    const secret = new aws.secretsmanager.Secret("my-secret", {});
    
    const taskDefinition = new awsx.ecs.FargateTaskDefinition("my-task-definition", {
        executionRole: executionRole,
        logGroup: logGroup,
        container: {
            image: "my-image:latest",
            memory: 128,
            cpu: 512,
            portMappings: [{
                protocol: "tcp",
                containerPort: 8080,
            }],
            secrets: [
                { name: "MY_SECRET", valueFrom: secret.arn }
            ]
        }
    });
    this produces build errors since the
    aws.ecs.Secret
    type is defined as follows:
    interface Secret {
        name: string;
        valueFrom: string;
    }
    and
    valueFrom
    expects a string and not an
    Output<string>
    which is returned from
    secret.arn
    how can i coerce the types to allow this to work?
    m
    l
    • 3
    • 3
  • a

    abundant-airplane-93796

    08/19/2020, 3:43 PM
    Really struggling with a stackreference/output typing issue trying to reference an array from my central config stack - my typescript isn't the best. Providing a slightly simplified version of my scenario - tried a bunch of things, including trying to JSON.stringify the output and then parse it back on the other side, but I can't seem to turn it back into an array of strings that I can iterate over: Stack A - Config: Exports a bunch of core GCP config values for use in other stacks like so
    export const gcpConfig = {
      regions: config.requireObject<Array<string>>('gcp-regions'),
    };
    offending config value looks like
    myconfig:gcp-regions:
      - us-east1
    Stack B - Infra: Utilizes a custom resource that creates a GCP network and a bunch of subnets
    const envConfig = new pulumi.StackReference('yadayada');
    const gcpConfig = envConfig.getOutput('gcpConfig');
    const regions = gcpConfig.apply((v) => v.regions);
    Unfortunately I can't figure out any way to manipulate
    regions
    back into an array of strings I can iterate over. Can someone please help?
    g
    l
    • 3
    • 7
  • a

    ancient-megabyte-79588

    08/20/2020, 5:20 PM
    Hey.. I have a question about
    exports
    ... I have a pulumi app that is modularized in a simple Typescript fashion. I have a "MyModules" folder and I have files in there with exported functions. This all works great from running pulumi and letting me have manageable files to deal with. What doesn't work though is if one of these functions needs to export something out to the pulumi service as a stack output.
    export const keyvaultId = keyvault.id
    does not work in the function in the module.
    export
    has to be outside of the function.
    exports["keyvaultId"] = keyvault.id
    and
    exports.keyvaultId = keyvault.id
    which work in the function do not seem to be getting exported into the stack outputs. If I put an
    exports.<name> = value;
    in the top-level index.ts, it does work. I would have expected the exports to work anywhere I use it and the stack output is correctly updated. Is this an incorrect expectation?
    l
    s
    • 3
    • 7
  • d

    dazzling-memory-8548

    08/21/2020, 10:12 PM
    @white-balloon-205 Question related to the import errors seen in https://pulumi-community.slack.com/archives/CJ909TL6P/p1592523846362500... We're building our lambdas using
    CallbackFunction
    in order to take advantage of the automatic serialization (https://www.pulumi.com/docs/tutorials/aws/serializing-functions/). This works fine in most cases but starts to break down when we put resources in different modules. I have repository
    A
    that contains my pulumi stack and resources, and a repository
    B
    that contains shared pulumi
    Component
    s and typescript helper functions in sub-modules. If I create a
    CallbackFunction
    in
    A
    that uses a sub-module from
    B
    , I run into `ImportModuleError`s, even if that sub-module in
    B
    doesn't directly include any references to
    @pulumi/*
    modules. It appears the serialization pulls in the entire
    B
    module, rather than just the needed sub-module, causing the lambda to try to import erroneous pulumi libraries. Situations like this seem to be correctly handled when all of the dependencies are in
    A
    , but the serializer gets tripped up when a dependent module itself has pulumi dependencies. Is this a potential bug in the serializer, or should I be using a different pattern to avoid this (split modules so they don't share pulumi code with vanilla lambda helpers)? Is there a way to ask the serializer to be more aggressive about inlining dependent code? Thanks. cc @worried-engineer-33884
    w
    • 2
    • 2
  • w

    worried-painting-67291

    08/24/2020, 5:43 PM
    I think I remember seeing this a couple months ago, but I can't find it now: Is there an example of createIfNotExists for AWS resources? Specifically: I have multiple clusters in seperate VPCs.. The clusters share dynamo and RDS tables, though, so I need a way to createIfNotExists those resources.
    h
    g
    • 3
    • 7
  • w

    worried-painting-67291

    08/24/2020, 5:44 PM
    I can hack together something with
    getTable
    and
    apply
    but I thought I read somewhere that it might not be the best approach (to work with the preview and whatnot)
  • w

    worried-painting-67291

    08/24/2020, 7:56 PM
    also.. along these same lines.. how can I tell Pulumi to not delete these shared resources when deleting a stack?
    g
    h
    • 3
    • 2
  • s

    stocky-spoon-28903

    08/24/2020, 8:33 PM
    @worried-painting-67291 look at the data source methods: getVpc et al. They just reference resources instead of creating them.
  • w

    worried-painting-67291

    08/24/2020, 9:25 PM
    @stocky-spoon-28903 - I use do use those. I basically do a aws.dynamodb.getTable, then I chain a
    then()
    and if getTable fails.. then I call new aws.dynamodb.Table. One problem, though, seems to be that even if the stack didn't create the resource.. it will still try to delete it when I delete the stack. Another problem also seems to be in refreshing the state of the stack.. but that is less important and isn't consistently a problem..
Powered by Linen
Title
w

worried-painting-67291

08/24/2020, 9:25 PM
@stocky-spoon-28903 - I use do use those. I basically do a aws.dynamodb.getTable, then I chain a
then()
and if getTable fails.. then I call new aws.dynamodb.Table. One problem, though, seems to be that even if the stack didn't create the resource.. it will still try to delete it when I delete the stack. Another problem also seems to be in refreshing the state of the stack.. but that is less important and isn't consistently a problem..
View count: 3