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

    able-hair-32695

    07/16/2022, 1:13 AM
    When setting up a EventRuleEventSubscription similar to https://www.pulumi.com/blog/scheduling-serverless/, is there a way to change the runtime of the lambda that is created? Currently getting a warning from the AWS SDK about v3 not supporting node v12 at some point
    • 1
    • 1
  • c

    colossal-quill-8119

    07/18/2022, 10:15 AM
    is there a way to get head sha directly from pulumi without config
    l
    • 2
    • 3
  • p

    powerful-art-87860

    07/19/2022, 7:59 AM
    I've been having some issues with the
    propagateTags
    property from the aws.ecs.Service: 1. setting it's value for the first time triggers a Service create-replacement. 2. changing it afterwards also triggers a Service create-replacement. The pulumi up detail shows the
    name
    ,
    id
    and
    propagateTags
    changing. The
    name
    and
    id
    change is due to the ending randomId from pulumi changing. Tried TASK_DEFINITION, SERVICE, NONE and removing the property, it always requires a replacement. I understand that changing the name triggers a replacement but why does
    propagateTags
    change the ending randomId from
    name
    ? Has anyone had this issue?
    w
    l
    b
    • 4
    • 10
  • b

    brave-scientist-99340

    07/20/2022, 8:55 PM
    Hey, I am having a problem that might be related to the autonaming logic in https://github.com/pulumi/pulumi-google-native/pull/551. Since v0.21.0 of
    @pulumi/google-native
    I am getting the following change on a non-modified `artifactregistry/v1:Repository`:
    ~ name: "projects/***/locations/us/repositories/my-repo-822c5d8" => "projects/***/locations/us/repositories/my-repo-5637933"
    (only the ID changes). When I apply it I get the following error:
    google-native:artifactregistry/v1:Repository (***):
        error: error sending request: googleapi: Error 400: Repository mode cannot be changed: "<https://artifactregistry.googleapis.com/v1/projects/***/locations/us/repositories/my-repo>" map[format:DOCKER name:projects/***/locations/us/repositories/my-repo-ee37a82]
    Now this does not make sense to me because according to the GCP docs this name should just be
    projects/***/locations/us/repositories/my-repo
    and not have any random ID suffix (also I am pretty sure its immutable). Seems like a bug to me but I just wanted to check in if I missed something?
    p
    • 2
    • 3
  • p

    polite-napkin-90098

    07/20/2022, 9:13 PM
    I'm having some more Output fun. I've exported the publicSubnetIds from an EKS stack with a line like:
    export const publicSubnetIds = cluster.core.publicSubnetIds;
    and then import them into another stack with
    const pubsub = stackMon.getOutput("publicSubnetIds");
    I then need to use them to annotate an ingress in a helm chart something like
    ingress: {
        annotations: {
            '<http://alb.ingress.kubernetes.io/subnets|alb.ingress.kubernetes.io/subnets>': `${pubsub[0]}, ${pubsub[1]}`
    or
    '<http://alb.ingress.kubernetes.io/subnets|alb.ingress.kubernetes.io/subnets>': `${pubsub.join(',')}`
    but this results in
    Property 'join' does not exist on type 'OutputInstance<any>'.
    or a similar error saying I can't index an Output<any> with 0 or 1 What am I getting wrong here? Can I not export an array? Do I need some apply magic on the gotten output before Typescript will accept it is and array and can be joined?
    r
    • 2
    • 7
  • s

    square-ability-48831

    07/21/2022, 7:53 PM
    I'm trying to override the autonaming of an ECR repository, but not sure if this is a type issue or an api issue -
    // Create a repository.
    const repo = new awsx.ecr.Repository("cicd", {
      name: "cicd",
    });
    the docs show a name param is available to be set, but I get:
    index.ts(5,3): error TS2345: Argument of type '{ name: string; }' is not assignable to parameter of type 'RepositoryArgs'.
          Object literal may only specify known properties, and 'name' does not exist in type 'RepositoryArgs'.
    b
    • 2
    • 5
  • b

    big-notebook-65054

    07/22/2022, 6:57 PM
    Hi, I'm having some trouble getting a random password into a string I can use within the code. It says to use
    password.result
    but that doesn't seem to ever change from a
    pulumi.Output<string>
    type.
    const password = new random.RandomPassword(`random-password-${stack}`, { length: 16 });
    To get into the specifics more, I am trying to place this password output into a config file on an EC2 instance by inserting it into the userData script. Every time I check the new EC2 server I get this error in the logs:
    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`
    See <https://pulumi.io/help/outputs> for more details.
    This function may throw in a future version of @pulumi/pulumi./"
    In the docs it says
    Because outputs are asynchronous, their actual raw values are not immediately available.
    which makes sense, but I cannot use
    apply()
    or any of the other options to get a readable string value on the
    password.result
    output. What am I missing here? Is there some sort of async/await functionality I can use to wait for it to resolve? Thanks!
    b
    • 2
    • 5
  • s

    strong-megabyte-18664

    07/23/2022, 2:07 AM
    Hello, I’m just getting started with Pulumi and I’m already stuck.
    import * as awsClassic from "@pulumi/aws";
    
    const vpc = awsClassic.ec2.getVpcs({
        tags: {
            env: "staging"
        }
    });
    
    // Export a few interesting fields to make them easy to use:
    export const vpcId = vpc.??
    I get any properties on the
    vpc
    const. I think it’s because
    ec2.getVpcs()
    is returning a
    Promise<GetVpcsResult>
    . I have zero Typescript experience and I’m not sure how to handle the Promise return so I can retrieve Vpc properties from it. Maybe an
    await
    or something? Help!
    b
    a
    • 3
    • 3
  • a

    able-hair-32695

    07/28/2022, 2:18 AM
    What’s the correct way to define a custom role for a serialized function tied to an EventRule for example? So far, I see that the
    aws.cloudwatch.onSchedule
    handler argument which is an
    EventRuleEventHandler
    has the below doc on it referencing a
    createCallbackFunction
    but I can’t find any docs referencing that anywhere(Other than in the
    pulumi-cloud
    repo). As it stands now it seems like the inline function definitions always default to
    iam.AWSLambda_FullAccess
    . I’m hoping to be able to define my own role for the function https://github.com/pulumi/pulumi-aws/blob/914003a7a1d16b8389529420a2a91200bc250d7e/sdk/nodejs/lambda/lambdaMixins.ts#L141-L148 Pulumi Doc I based my code on: https://www.pulumi.com/blog/scheduling-serverless/
  • b

    big-notebook-65054

    07/28/2022, 5:26 PM
    I have two
    command.remote.Command
    issues/questions that I would love some insight on if possible: 1. The first command I try to run on the server is a combination
    sudo apt-get update && sudo apt-get install redis-server -y
    . The weird part is that it works maybe 50-60% of the time but when it fails it gives me an error message which indicates that
    apt-get update
    didnt run:
    E: Unable to locate package redis-server error: Process exited with status 100
    2. Later on in the list of commands I try to set the redis password via the redis-cli interactive shell with this command:
    sudo redis-cli <<<"CONFIG SET requirepass ${result.secretString}"
    . stdout returns and
    OK
    which typically indicates success when done manually, however when I try to log into the server remotely there is no password set. Very strange behavior.
    a
    • 2
    • 3
  • b

    brief-helicopter-28120

    08/04/2022, 9:31 AM
    Hello, I'm trying to use
    k8s.yaml.ConfigFile
    to deploy CRDs into my EKS cluster (typescript) and I run into issues. Btw I'm new to typescript and as well to pulumi. So please kindly bare with me 🙏 Code:
    import * as k8s from "@pulumi/kubernetes";
    import * as eks from "@pulumi/eks";
    
    
    export default {
        install_crds(cluster: eks.Cluster){
            new k8s.yaml.ConfigFile("argocd_namespace", {
                file: "kubernetes_cluster_components/namespaces/argocd-namespace.yaml",
            }, {providers: { "kubernetes": cluster.provider }});
        }
    };
    Error:
    pulumi:pulumi:Stack  k8s-moralis-aws-dev-argo-test  running.    error: an unhandled error occurred: Program exited with non-zero exit code: -1
    I0804 09:23:53.878138   22054 deployment_executor.go:162] deploymentExecutor.Execute(...): exiting provider canceller
         Type                 Name                           Plan     Info
         pulumi:pulumi:Stack  k8s-moralis-aws-dev-argo-test           1 error; 39 messages
    
    Diagnostics:
      pulumi:pulumi:Stack (k8s-moralis-aws-dev-argo-test):
        Cloud Provider: aws Stack: aws-dev-argo-test
    
        error: an unhandled error occurred: Program exited with non-zero exit code: -1
    The error message is not very descriptive, hence difficult to troubleshoot. Can someone please help me here 🙏
    w
    • 2
    • 2
  • w

    white-chef-55657

    08/04/2022, 12:10 PM
    I couldn’t find in the docs of the pulumi package, but is there a way to check if I’m currently in preview/update/destroy etc. ?
    w
    • 2
    • 8
  • g

    gorgeous-country-43026

    08/15/2022, 11:48 AM
    Hmm. I wonder if the following would be possible: I'm considering using a single project for my infrastructure code (monorepo of sorts) but use stacks for different parts of my infrastructure. I'm not going into too much detail into this why I think this would be a good idea but I faced a problem where Pulumi expects
    index.ts
    to be in the root of the project. Basically this limits me from creating several
    index.ts
    files into different folders and still retain the flexibility to jump between those via
    pulumi stack select whatever
    . If I model this via different projects then I need to do a separate login every time I switch project (not using Pulumi Service for now). I wonder if there is a way to tell Pulumi to use a different
    index.ts
    per stack?
    w
    l
    • 3
    • 10
  • f

    freezing-accountant-92268

    08/16/2022, 1:17 PM
    Hi, I’m trying to create a app load balancer with a target with a target group to a docker image, but its only working for me if the docker image listens on port 80, I need it to work on a diff port... (Its most probably a stupid config I don’t understand...) if someone can help please.
    b
    w
    a
    • 4
    • 22
  • l

    late-lizard-19909

    08/16/2022, 2:10 PM
    I'm confused about working with outputs I guess. I want to call a secret from an azure keyvault that is not managed by Pulumi state. I'm calling a keyvault.getSecret or .getSecretOutput. And I know I want the Value property of the secret, but I don't know how to get there once I have the output or promise. I'm trying something like this:
  • l

    late-lizard-19909

    08/16/2022, 2:10 PM
    const domainSecretGet = azure_native.keyvault.getSecret({
        secretName: "secret1",
        vaultName: "AZVault1",
        resourceGroupName: "AZVault"
    });
    
    export const domainSecretGetValue = domainSecretGet.then(domainSecretGet => domainSecretGet.properties.value);
    
    console.log(domainSecretGetValue)
    s
    • 2
    • 1
  • l

    late-lizard-19909

    08/16/2022, 2:10 PM
    but its returning undefined
  • l

    late-lizard-19909

    08/16/2022, 4:24 PM
    Also my goal is to eventually use this secret inside of a scale set extension
  • s

    square-ability-48831

    08/17/2022, 3:34 AM
    Looking for some
    StackReference
    type conversion help, or maybe it's the standard Output/Input handling stuff that I need? I'm accessing the details of a VPC from a StackReference, and I need the
    subnetId
    as an
    Input
    to an
    ec2
    - whats the best way to be able to treat the subnet output from the StackReference into an array? Or even better - can I grab the full vpc Output object and then interrogate it to get the subnetId I need?
    const devopsVpc = vpcStack.getOutput("devopsVpc"); // Full VPC output - can I get this and use it like it was created in this stack? 
    const devopsVpcPublicSubnetIds = vpcStack.getOutput("devopsVpcPublicSubnetIds"); // Output<any> - can I coerce this to an array?
    // output in this stack is Array:
    // Outputs:
    // + subnetIds: [
    //   +     [0]: "subnet-06a**********3fe0"
    //   +     [1]: "subnet-036**********c6b7"
    //     ]
    
    // but how to access as an array as input to EC2 creation?
    // just need a single subnetId
    const host = new ec2.Instance("bastionHost", {
      ami: ubuntuAmi,
      tags: { "Name": "hostthemost" },
      instanceType: "t2.medium",
      subnetId: devopsVpcPublicSubnetIds[0], // <-- throws since not an array type
    //   ...other props...
    })
    
    export const subnetIds = devopsVpcPublicSubnetIds; // show sup as an array Output (see above)
    s
    • 2
    • 2
  • r

    rapid-spoon-72613

    08/17/2022, 5:08 PM
    How do I pulumify this import of a function app as an API in Azure API Management.? We are creating policies and the API manager as well as importing WADL of APIs but we are struggling to make use of pulumi to attach existing Azure Functions as APIs https://docs.microsoft.com/en-us/azure/api-management/import-function-app-as-api
  • s

    square-ability-48831

    08/17/2022, 10:33 PM
    I swear I saw a page on how to tell pulumi to use an explicit
    tsconfig.pulumi.json
    file instead of the default
    tsconfig.json
    - something other than setting
    PULUMI_NODEJS_TSCONFIG_PATH
    ? Isn't there a config I can add to Pulumi.yaml to point to it? Can't find in the docs what that should be...
  • l

    late-lizard-19909

    08/19/2022, 2:44 PM
    Having alot of issues with my typescript intellisense breaking in VSCode after running for about 5 minutes, anyone have similar issues and able to find a resolution? I haven't been able to find one that works for me
    b
    m
    +2
    • 5
    • 13
  • i

    icy-controller-6092

    08/22/2022, 5:42 PM
    import type { Provider } from '@pulumi/aws'
    seems like it doesn’t work. Easy workaround though (just use
    aws.Provider
    instead through a regular import). but I’m curious to know why it doesn’t work?
    l
    m
    • 3
    • 18
  • a

    alert-plumber-27645

    08/23/2022, 3:21 PM
    can we create the stack outputs/exports programmatically?
  • a

    alert-plumber-27645

    08/23/2022, 3:23 PM
    like export const xyz = "something" is one option but i want to create an export conditionally
    v
    • 2
    • 1
  • t

    thousands-psychiatrist-31710

    08/23/2022, 7:37 PM
    Trying to use the GitHub Provider in TS to create a Repository environment and some secrets, but I see consistent failures like.. "stderr: error: PUT <https://api.github.com/repos/&lt;your%20org&gt;/accounts/environments/development%7Chttps://api.github.com/repos/&lt;your org>/accounts/environments/development>: 422 Fail to create protected rule, please ensure billing plan include protected branch gate. []" I tried with an access token with all assigned scopes and received the same results. The Environment as well a a subset of my desired secrets is created successfully. I am able to manually change the branch rules for the environment. Can I get some assistance or pointed to the implementation so I can potentially fix?
    b
    • 2
    • 3
  • l

    little-cartoon-10569

    08/23/2022, 10:34 PM
    Convention question: when creating component resource classes, does anyone separate the args passed to super() from the args used in the component resource? I've just recommended to someone that they don't do this, but I think the recommendation is personal bias based on all code I've seen or written. Can anyone think of a reason to pass in two args parameters to a constructor: one to be passed to super(), and one specifically for the specific class?
    b
    c
    • 3
    • 4
  • i

    icy-controller-6092

    08/24/2022, 10:24 PM
    This is more of a typescript question, but I’m trying to create this resource creator bound to a specific region so I can use it with deploying region-specific stacks… but I am getting a typescript error (code in thread)
    l
    • 2
    • 45
  • g

    gorgeous-painting-25877

    08/25/2022, 2:22 PM
    I want to program my own package in Typescript. Is this possible at all and if so are there any examples? So far I have come across https://www.pulumi.com/docs/intro/concepts/resources/dynamic-providers, is that what I am looking for? All existing packages in the registry seem to have been implemented directly in go or with the tf bridge.
    l
    • 2
    • 11
  • s

    square-hair-965

    08/25/2022, 8:37 PM
    hello everyone, I'm new around here but am looking forward to becoming an active contributor. I'm having a hell of a time getting an interpolated
    Output<string>
    to play nice with the
    aws.ec2.LaunchTemplate
    userData
    attribute. I've tried quite a few different approaches but I always seem to wind up with this in my aws console:
    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`
    
    See <https://pulumi.io/help/outputs> for more details.
    This function may throw in a future version of @pulumi/pulumi.
    The userData script is a fairly large bash script that is created by interpolating numerous outputs from other resources. When I export it it's correct in the Pulumi console. Full component code to follow in the thread ->
    s
    b
    b
    • 4
    • 7
Powered by Linen
Title
s

square-hair-965

08/25/2022, 8:37 PM
hello everyone, I'm new around here but am looking forward to becoming an active contributor. I'm having a hell of a time getting an interpolated
Output<string>
to play nice with the
aws.ec2.LaunchTemplate
userData
attribute. I've tried quite a few different approaches but I always seem to wind up with this in my aws console:
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`

See <https://pulumi.io/help/outputs> for more details.
This function may throw in a future version of @pulumi/pulumi.
The userData script is a fairly large bash script that is created by interpolating numerous outputs from other resources. When I export it it's correct in the Pulumi console. Full component code to follow in the thread ->
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

const config = new pulumi.Config();

export interface WorkerLaunchTemplateArgs {
    stack: pulumi.Input<string>;
    instanceType: string;
    vpcSecurityGroupIds: pulumi.Output<any>[];
    userData: pulumi.Output<string>;
    ami: pulumi.Input<string>;
}

export default class WorkerLaunchTemplate extends pulumi.ComponentResource {

    launchTemplateId;

    constructor(name: string, args: WorkerLaunchTemplateArgs, opts?: pulumi.ResourceOptions) {

        super("pkg:index:WorkerLaunchTemplate", name, {}, opts);

        const launchTemplate = new aws.ec2.LaunchTemplate(`${args.stack}-${name}`, {
            imageId: args.ami,
            instanceType: args.instanceType,
            userData: Buffer.from(`${args.userData}`, 'utf8').toString('base64'),
            vpcSecurityGroupIds: args.vpcSecurityGroupIds,
            tagSpecifications: [{
                resourceType: "instance",
                tags: {
                    Name: `${args.stack}-${name}`
                },
            }],

        });

        this.launchTemplateId = launchTemplate.id;
    }

}
Let me know what you guys think. I've had similar issues before and worked around them by refactoring some code but nothing I try here seems to work.
s

steep-toddler-94095

08/25/2022, 8:44 PM
args.userData
is an
Output<string>
so you cannot treat it like a string. Similarly to a
Promise
, you can only access its string value in a callback function within the
apply
method (`sort of like Promise's
then
method)
userData: args.userData.apply(userData => Buffer.from(userData, 'utf8').toString('base64'),
🙌 1
s

square-hair-965

08/25/2022, 8:53 PM
awesome that worked Mike! Thanks so much. I did something similar (though not inline) earlier and I had thought it didn't work but now I wonder if I just forgot to check the latest version in console 😫
😛: 1
b

billowy-army-68599

08/25/2022, 9:00 PM
https://leebriggs.co.uk/blog/2021/05/09/pulumi-apply
s

square-hair-965

08/25/2022, 9:05 PM
thanks jaxx, I've gotten my head around what Pulumi wants to do the past few weeks, I just couldn't quite figure out what I was doing wrong with the Buffer func here. I did something similar for my container definitions earlier in the week`.apply(([dbConnection, ...]) => JSON.stringify(...)` I probably should of referred back there. Thanks for the help, really do appreciate it.
b

breezy-airplane-94478

09/09/2022, 4:00 AM
@billowy-army-68599 thanks for the clarifications here, they helped me out this week. I'm actually learning typescript for the first time through pulumi (zero JS experience either) so I often struggle to even know what I'm supposed to google lol
View count: 1