https://pulumi.com logo
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
golang
  • g

    green-musician-49057

    05/18/2021, 3:47 PM
    Is there an example of wrapping strings as
    pulumi.Secret
    in golang? Do we have to use ApplyT to get convert the output to the right type?
    g
    • 2
    • 6
  • i

    important-sandwich-62391

    05/19/2021, 10:10 PM
    Any ideas on how to work around https://github.com/pulumi/pulumi-eks/issues/566 Just trying to create an Managed Node Group, dont’ really care how…. 🙂. but wondering if using Go for this will just keep causing pain 😞
    🦗 1
    m
    b
    • 3
    • 3
  • r

    ripe-shampoo-80285

    05/24/2021, 12:52 AM
    How do I convert eks cluster,Kubeconfig from AnyOutput to StringOutput in the following: k8sProvider, err := providers.NewProvider( ctx, "k8sprovider", &providers.ProviderArgs{ Kubeconfig: cluster.Kubeconfig, }, pulumi.DependsOn([]pulumi.Resource{cluster})) if err != nil { fmt.Println(err.Error()) return err } Here ProviderArgs expect StringOutput, cluster.Kubeconfig is an AnyOutput.
    b
    • 2
    • 4
  • b

    bored-table-20691

    05/24/2021, 8:29 PM
    I noticed some awkwardness in getting an
    int
    /
    IntOutput
    value from a stack reference. Specifically, in one stack I did a
    ctx.Export("db-port", <http://pulumi.Int|pulumi.Int>(5432)
    , and then in another stack I had a reference to it. Since there isn’t a
    GetIntOutput
    option, I ended up having to do it manually with
    ApplyT
    , and then found out that the value comes across as a
    float64
    (I’m assuming due to the JSON encoding). I ended up with this utility function:
    func getIntOutput(ref *pulumi.StackReference, key string) pulumi.IntOutput {
    	output := ref.GetOutput(pulumi.String(key))
    	return output.ApplyT(func(port interface{}) int {
    		return int(port.(float64))
    	}).(pulumi.IntOutput)
    }
    I wanted to see if this was expected and also if the above solution is reasonable.
    b
    • 2
    • 4
  • a

    ambitious-salesmen-39356

    05/25/2021, 4:31 PM
    I'm having a hard time getting values out of terraform remote state (I'm using the tf cloud backend). Working from the example here: https://www.pulumi.com/docs/guides/adopting/from_terraform/ - is there a canonical way to simply get the map of outputs from the remote state into a Go object so I can interpolate them into other resources?
    b
    • 2
    • 15
  • m

    many-agent-57485

    05/26/2021, 12:53 PM
    Hi, I've tried to read the docs, but couldn't understand . How do i convert
    pulumi.StringOutput
    to
    string
    or
    pulumi.String
    ? thanks !
    b
    a
    +2
    • 5
    • 12
  • a

    ambitious-salesmen-39356

    05/26/2021, 4:15 PM
    I'm trying to work with Kubernetes Custom Resources, specifically a TargetGroupBinding for the AWS LB Controller. I used
    crd2pulumi
    to take the CRD and convert it to Go types, pretty fabulous. However, I'm not sure if this is a me problem or something crd2pulumi missed - one of the types where I'd expect it to have fields is an empty struct:
    type TargetGroupBindingSpecServiceRefPortArgs struct {
    }
    I'd expect this to have like a
    Port: <http://pulumi.Int|pulumi.Int>
    field. When I go to define a port:
    _, err = tgb.NewTargetGroupBinding(ctx, serviceName, &tgb.TargetGroupBindingArgs{
    			ApiVersion: pulumi.String("elbv2.k8s.aws/v1beta1"),
    			Kind:       pulumi.String("TargetGroupBinding"),
    			Metadata: &metav1.ObjectMetaArgs{
    				Name:      pulumi.String(serviceName),
    				Namespace: namespace.Metadata.Elem().Name(),
    			},
    			Spec: &tgb.TargetGroupBindingSpecArgs{
    				TargetType: pulumi.String("ip"),
    				ServiceRef: &tgb.TargetGroupBindingSpecServiceRefArgs{
    					Name: svc.Metadata.Elem().Name().Elem().ToStringOutput(),
    					Port: &tgb.TargetGroupBindingSpecServiceRefPortArgs{
    						Port: <http://pulumi.Int|pulumi.Int>(80),
    					},
    				},
    				TargetGroupARN: pulumi.Sprintf("%s", tgArnOutput),
    			},
    		})
    I get an
    unknown field Port in struct literal
    b
    • 2
    • 9
  • b

    bored-table-20691

    05/26/2021, 5:51 PM
    I’m seeing some odd behavior of values being declared a secret even though they shouldn’t be, specifically with stack reference values. For example, in one stack I have:
    bucket, err := s3.NewBucket(ctx, fmt.Sprintf("my-bucket-%s", region), nil)
    		if err != nil {
    			return err
    		}
    
    		ctx.Export("bucket", bucket.ID())
    And then in another stack:
    infraStack, err := pulumi.NewStackReference(ctx, "...", nil)
    infraBucket := infraStack.GetStringOutput(pulumi.String("bucket"))
    auditLogLocation := pulumi.Sprintf("<s3://%s/audit-logs>", infraBucket)
    auditLogLocation
    is now a secret (i.e. if I export it, it shows up as a secret), and I have to explicitly do
    pulumi.Unsecret(…).(pulumi.StringOutput)
    on it. This happens for any value that comes from the other stack. This is with Pulumi 3.3.0.
    g
    • 2
    • 2
  • m

    modern-nest-74116

    05/29/2021, 4:39 AM
    The UserData in this ec2.LaunchTemplate throws the following error:  
    Ec2LaunchTemplateInvalidConfiguration: User data was not in the MIME multipart format
    I am following AWS provided examples https://docs.aws.amazon.com/batch/latest/userguide/launch-templates.html Not sure what I am doing wrong. All suggestions are welcome.
    launchTemplate, err := ec2.NewLaunchTemplate(ctx, resourceName, &ec2.LaunchTemplateArgs{
    ….
       UserData: pulumi.StringPtr(base64.StdEncoding.EncodeToString([]byte(`
                 MIME-Version: 1.0
                 Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="
    
                 --==MYBOUNDARY==
                 Content-Type: text/x-shellscript; charset="us-ascii"
    
                 #!/bin/bash
                 set -ex
    
                 BOOTSTRAP_SH=/etc/eks/bootstrap.sh
                 BOOTSTRAP_USE_MAX_PODS_SEARCH="USE_MAX_PODS:-true"
                 KUBELET_CONFIG=/etc/kubernetes/kubelet/kubelet-config.json
                 # MAX_PODS=58
    
                 # search for the string to be replaced by sed and return a non-zero exit code if not found. This is used for safety in case the bootstrap.sh
                 # script gets changed in a way that is no longer compatible with our USE_MAX_PODS replacement command.
                 grep -q $BOOTSTRAP_USE_MAX_PODS_SEARCH $BOOTSTRAP_SH
    
                 # set the default for USE_MAX_PODS to false so that the maxPods value set in KUBELET_CONFIG will be honored
                 sed -i"" "s/$BOOTSTRAP_USE_MAX_PODS_SEARCH/USE_MAX_PODS:-false/" $BOOTSTRAP_SH
    
                 --==MYBOUNDARY==--
                `))),
    })
    • 1
    • 1
  • b

    boundless-addition-81455

    05/31/2021, 11:58 AM
    Hi guys, I am using pulumi and digitalocean, but when adding a firewall I need to specify the droplet id. but the id type returned when creating a droplet, how do I convert it to an int type by using ApplyT?
  • r

    ripe-shampoo-80285

    06/04/2021, 2:58 AM
    Any Pulumi golang based example for setting AWS EKS IRSA?
    b
    b
    • 3
    • 15
  • w

    wide-activity-54187

    06/04/2021, 12:55 PM
    https://pulumi-community.slack.com/archives/C01PF3E1B8V/p1622811330151500
  • s

    sticky-bear-14421

    06/11/2021, 9:44 AM
    Hey, I've got a question about resource chaining and dependencies. My code is about base infrastructure setup of an aws account with all the usual suspects like vpc, subnets, routing. First special resource is an organizational transit gateway setup. For this I have to create an IAM role which I assume by creating a provider resource and using this I create a second provider which assumes a role in a second account and there some route table operations are configured. So far, so good .. Now I have the need to do some vpc peerings and like above I have the propagator acceptor pattern again. So, again two providers, over into the second account and accept the peering propagation .. but no, my second provider failes, that it cannot assume the role, and this is where my problems begin. I forgot to allow my IAM role to assume the other accounts accepter role. No problem, attach more resource arns in the policy and another pulumi up and it fails again, as my addition to the roles policy isn't finished when the provider gets created.
    peeringProvider, err := aws.NewProvider(ctx, fmt.Sprintf("peeringProvider-%s", peer.Name), &aws.ProviderArgs{    
          AssumeRole: &aws.ProviderAssumeRoleArgs{                                                                                                            
            RoleArn:     pulumi.String(fmt.Sprintf("arn:aws:iam::%s:role/%s", peer.AccountID, peer.RouteTables["peeringAccepterRole"])),    
            SessionName: pulumi.String("peeringAccepterSession"),                                                                                                            
          },                                                                                                            
          Region: pulumi.String(region.Name),                                                                                                            
        }, pulumi.Provider(provider), pulumi.DependsOn([]pulumi.Resource{provider, role}),                                                                                                            
        )                                                                                                            
        if err != nil {                                                                                                            
          return err                                                                                                            
        }
    Even with the pulumi.DependsOn() containing my role reference, this does not align this provider with the changes on the role. Any hints on how to fix this ordering?
    • 1
    • 2
  • r

    red-football-97286

    06/14/2021, 1:12 PM
    How do you all structure your folders when using Go and Pulumi? I want to have a clean approach. Thanks.
    s
    • 2
    • 2
  • r

    ripe-shampoo-80285

    06/14/2021, 5:20 PM
    Does any body have a golang pulumi example to set up IAM roles to k8s RBAC roles mapping in aws-auth configmap (use roleMappings property) ?
  • s

    sticky-bear-14421

    06/15/2021, 11:54 AM
    Hello, I've got a followup problem to my above one (⬆️). I circumvented the dependency problem hard by disabling the broken provider, using the missing ARNs, and running the update, then activate them again. But, much worse, my problem still exists. Quite consitently Pulumi keeps telling me that the TF Provider cannot assume the configured role. I broke the code out of my base setup stack and moved it over into a new one .. no effect ..
    b
    • 2
    • 31
  • m

    mammoth-honey-6147

    06/15/2021, 5:06 PM
    Sorry for the simple question, long day.. How can I iterate through an array of objects such as
    var k3sNodeList []*ec2.Instance
    in
    ctx.export
    ? It appears just iterating through the array elements in a loop and using
    ctx.export
    only prints out the last in the array.
    b
    a
    s
    • 4
    • 7
  • s

    sticky-bear-14421

    06/21/2021, 2:08 PM
    I've got another question, is there a rule of thumb on on when to use
    foo.bar..ApplyT()
    to enforce Pulumi to wait for the creation of a particular resource?
    s
    • 2
    • 5
  • b

    bright-sandwich-93783

    06/26/2021, 4:57 PM
    Hey all! I have a questions related to the golang AWS SDK. Why do all of the Pulumi SDK APIs return inputs/outputs instead of primitive values? I don't fully understand the architectural decisions around why Pulumi uses Inputs/Outputs with Apply/Lift methods. This adds a lot of boilerplate and complexity to access the underlying raw value. As I understand it, it's because Pulumi runs the code before actually making AWS API calls? Can someone help me understand this?
    b
    • 2
    • 3
  • b

    bright-sandwich-93783

    06/26/2021, 5:02 PM
    Like why can't Pulumi issue blocking calls to AWS in series, and return primitive types that don't require callbacks/Apply/Lift/etc?
  • n

    numerous-thailand-80976

    06/28/2021, 2:31 AM
    Hey!, I’m having a probably very dumb problem, I’m using the Google Native SDK and I’m trying to create a VPC, here’s the code snippet for that:
    vpc, err := network.NewNetwork(ctx, projectID+"-vpc-"+config.Name, &network.NetworkArgs{
    		AutoCreateSubnetworks: pulumi.Bool(config.AutocreateSubnets),
    		Name:                  pulumi.String(config.Name),
    		RoutingConfig: &network.NetworkRoutingConfigArgs{
    			RoutingMode: ?
    		},
    	})
    I’m having an issue with the ?,
    RoutingMode
    is an object of
    *(network,NetworkRoutingConfigArgs).RoutingMode
    type for which there are 2 constants `network.NetworkRoutingConfigRoutingModeGlobal`and
    network.NetworkRoutingConfigRoutingModeRegional
    . I’ve tried the following but all are rejected by the compiler:
    &network.NetworkRoutingConfigRoutingModeGlobal
    &network.NetworkRoutingConfigRoutingMode{ network.NetworkRoutingConfigRoutingModeGlobal }
    &network.NetworkRoutingConfigRoutingMode(network.NetworkRoutingConfigRoutingModeGlobal)
    Does anyone know how I can pass the constant to the
    RoutingMode
    field?
    b
    • 2
    • 3
  • b

    bright-sandwich-93783

    06/29/2021, 7:33 PM
    Hi, super nooby question. I need to access the raw string value of a StringOutput to interpolate it into another string. The
    Apply
    function doesn't return a raw string. how can I do this? Small go snippet would be awesome.
    b
    e
    • 3
    • 5
  • b

    bright-sandwich-93783

    06/29/2021, 11:52 PM
    Hi all -- is there a way to get more informative error messages when
    pulumi preview/up
    fails? I would at least expect Pulumi to tell me which line of code or resource configuration is invalid. For example, I'm trying to create a resource but missing an AWS required field. the error message is
    Diagnostics:
      pulumi:pulumi:Stack (app-staging):
        error: program failed: 1 error occurred:
        	* invalid value for required argument 'ThumbprintLists'
        exit status 1
    
        error: an unhandled error occurred: program exited with non-zero exit code: 1
  • b

    bright-sandwich-93783

    06/29/2021, 11:52 PM
    this doesn't really help me understand which resource is problematic. Am I missing a flag or something?
  • b

    bright-sandwich-93783

    06/29/2021, 11:56 PM
    one solution that came to mind is some kind of error lib that wraps the Pulumi errors (which don't include line numbers or anything useful besides the AWS API error message) in another error that contains line info, etc. But I would kind of expect Pulumi errors to have that?
    b
    • 2
    • 3
  • b

    bright-sandwich-93783

    07/01/2021, 9:35 PM
    Hi all. Inside of an
    ApplyT
    callback, I need to make some network calls. This is because I need the raw string value of an
    Output
    for use as a parameter to an API call somewhere. That API call might fail inside the
    ApplyT
    callback, yet I don't see a way to propagate this error up, since
    ApplyT
    only returns an
    Output
    . Any advice here?
  • b

    bright-sandwich-93783

    07/01/2021, 9:52 PM
    thinking of using the
    ApplyTWithContext
    , because docs say that
    The provided context can be used to reject the output as canceled.
    , but there is no other mention of the word cancel or how to detect if an output has been "cancelled"
  • s

    salmon-account-74572

    07/02/2021, 6:25 PM
    I’ve run into a problem with the Go SDK for AWS. I have code that creates a VPC, public and private subnets, route tables, Internet gateway, etc. It also allocates an EIP for a NAT gateway (for the private subnets). If I run
    pulumi preview
    I get this:
    panic: sync: WaitGroup is reused before previous Wait has returned
        goroutine 1 [running]:
        sync.(*WaitGroup).Wait(0xc000386258)
        	/usr/local/go/src/sync/waitgroup.go:132 +0xae
        <http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.(*Context).wait|github.com/pulumi/pulumi/sdk/v3/go/pulumi.(*Context).wait>(0xc000386140, 0x0, 0x0)
        	/Users/slowe/Code/Go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.4.0/go/pulumi/context.go:156 +0x50
        <http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.RunWithContext(0xc000386140|github.com/pulumi/pulumi/sdk/v3/go/pulumi.RunWithContext(0xc000386140>, 0x1c3a4c8, 0xc0000440ef, 0xc)
        	/Users/slowe/Code/Go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.4.0/go/pulumi/run.go:112 +0x2a6
        <http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.RunErr(0x1c3a4c8|github.com/pulumi/pulumi/sdk/v3/go/pulumi.RunErr(0x1c3a4c8>, 0x0, 0x0, 0x0, 0x0, 0x0)
        	/Users/slowe/Code/Go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.4.0/go/pulumi/run.go:84 +0x23f
        <http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.Run(0x1c3a4c8|github.com/pulumi/pulumi/sdk/v3/go/pulumi.Run(0x1c3a4c8>, 0x0, 0x0, 0x0)
        	/Users/slowe/Code/Go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.4.0/go/pulumi/run.go:41 +0x59
        main.main()
        	/Users/slowe/Code/Repos/lab/infra/aws-infra-go/main.go:14 +0x3e
        exit status 2
    
        error: an unhandled error occurred: program exited with non-zero exit code: 1
    If I comment out the NAT gateway code (which consumes the EIP), then the error goes away. This worked in previous versions of the SDK. I can share my code upon request, in the event that I’m doing something incorrectly.
    b
    • 2
    • 8
  • a

    alert-monitor-28534

    07/06/2021, 8:09 AM
    Hi I'm not really a programmer but I'm still trying to have my homelab up and running with Pulumi and Golang. I try to deploy Traefik via Helm chart but I don't know how to define the "env" for the
    values.yml
    , this is what I have now:
    "env": pulumi.Map{
    "name": pulumi.String("DUCKDNS_TOKEN"),
    "valueFrom": pulumi.Map{
    "secretKeyRef": pulumi.Map{
    "name": pulumi.String("duckdns"),
    "key":  pulumi.String("token"),
    },
    },
    },
    pulumi up
    says this when deploying:
    warning: skipped value for env: Not a table.
    How should I do this?
    b
    b
    • 3
    • 3
  • b

    bright-sandwich-93783

    07/06/2021, 8:18 PM
    ApplyTWithContext
    mentions that the provided context can be used to reject the output as cancelled. If I call the context
    cancel
    method, what am I supposed to expect?
    ApplyTWithContext
    only returns a single value of type
    Output
    . As a caller of
    ApplyTWithContext
    how am I supposed to detect a "rejected output"?
    b
    • 2
    • 2
Powered by Linen
Title
b

bright-sandwich-93783

07/06/2021, 8:18 PM
ApplyTWithContext
mentions that the provided context can be used to reject the output as cancelled. If I call the context
cancel
method, what am I supposed to expect?
ApplyTWithContext
only returns a single value of type
Output
. As a caller of
ApplyTWithContext
how am I supposed to detect a "rejected output"?
b

bored-table-20691

07/08/2021, 10:56 PM
@bright-sandwich-93783 I believe you can have an applier function that returns an error: https://pkg.go.dev/github.com/pulumi/pulumi/sdk@v1.14.1/go/pulumi#OutputState.ApplyT
You can also see in the code that an Output (e.g. StringOutput) will internally store whether it is rejected/errored: https://github.com/pulumi/pulumi/blob/sdk/v3.6.1/sdk/go/pulumi/types.go#L77
View count: 6