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
golang
  • b

    bright-sandwich-93783

    07/08/2021, 7:59 PM
    ^ anyone? Trying to understand the relationship between the pulumi.Context and the context.Context. the former contains a instance of the latter, but doesn't expose a way to cancel it.
  • b

    brainy-rainbow-75025

    07/16/2021, 6:36 PM
    So, I'm trying to get started with the Pulumi golang SDK and so far I'm pretty unimpressed/frustrated. Right out of the gate, all the links in the docs are broken: For instance, this is a link in the VPC docs: https://pkg.go.dev/github.com/pulumi/pulumi/sdk/v4/go/pulumi?tab=doc#IDInput ^^that goes to an error page and every link I've clicked in the Go documentation has been broken so far. I'm attempting to use the
    GetVpc
    call but I can't find a single example of how to declare one of the required arguments for
    InputID
    and again... all the links are broken. Then, I attempt to get the provider version and this is what I get....
    b
    b
    • 3
    • 50
  • b

    brainy-rainbow-75025

    07/16/2021, 6:36 PM
    Not a great first hour or so
  • b

    brainy-rainbow-75025

    07/16/2021, 6:39 PM
    To clarify, go to this page: https://www.pulumi.com/docs/reference/pkg/aws/ec2/vpc/ Click any of the links presented and you'll get an error.
    s
    • 2
    • 1
  • b

    brainy-dawn-85792

    07/22/2021, 6:26 AM
    Hi, is there a way to add a label in aws/eks to the default namespace in golang?
  • q

    quaint-restaurant-18952

    08/03/2021, 4:32 PM
    Hi, trying to get going here with pulumi and golang. Im not to experienced in Go either, but wanted to try this combo.. anyways.. i fail pretty fast, but I belive it is from something that I'm not doing wrong.. running
    pulumi new kubernetes-go
    just takes me straigth to
    Installing dependencies...
    go: <http://github.com/pulumi/pulumi/sdk/v3@v3.9.1|github.com/pulumi/pulumi/sdk/v3@v3.9.1> requires	<http://github.com/spf13/cobra@v1.0.0|github.com/spf13/cobra@v1.0.0> requires	<http://github.com/spf13/viper@v1.4.0|github.com/spf13/viper@v1.4.0> requires	<http://go.uber.org/zap@v1.10.0|go.uber.org/zap@v1.10.0>: verifying go.mod: <http://go.uber.org/zap@v1.10.0/go.mod|go.uber.org/zap@v1.10.0/go.mod>: malformed record data
    When i checked https://pkg.go.dev/go.uber.org/zap@v1.10.0 it is reported as broken.. any suggestions to how to get around this?
    b
    • 2
    • 12
  • q

    quiet-architect-91246

    08/03/2021, 5:22 PM
    pulumi.Run(func(ctx *pulumi.Context) error {
       output := cluster.Provider.ApplyT(func(p *kubernetes.Provider) (string, error) 
    
          appSvc, svcerr := corev1.NewService(ctx, "app-svc", &corev1.ServiceArgs{
               ...
             },
          }, pulumi.Provider(p))
    
          ctx.Export("appIp", appSvc.Status.ApplyT(func(status *corev1.ServiceStatus) *string {
             return status.LoadBalancer.Ingress[0].Ip
          }))
          ctx.Export("test-export", pulumi.String("testexportvalue"))
          return "", nil
       }).(pulumi.StringOutput)
       ctx.Export("output", output)
    
       return nil
    })
    Hi everyone! Im running go code like stated above, and am wondering why only the "output" ctx.Export and not "test-export" or "appIp" show up in my Stack as outputs. I assume its because its inside of an 
    .apply()
     , but cant really understand why that would stop it from working. Also since it doesnt work the way I tried, how would you go about achieving a similar result?
    l
    • 2
    • 12
  • i

    important-sandwich-62391

    08/03/2021, 11:01 PM
    I’m trying to pulumi preview a new stack, and getting a panic:
    panic: reflect: Elem of [secret] type interface {}
    
    goroutine 262 [running]:
    
    reflect.(*rtype).Elem(0x1f42040, 0xc00042d1b0, 0x194)
    
    	/usr/local/Cellar/go/1.16.3/libexec/src/reflect/type.go:915 +0x1a5
    
    <http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.awaitInputs(0x23fd638|github.com/pulumi/pulumi/sdk/v3/go/pulumi.awaitInputs(0x23fd638>, 0xc0000580e0, 0x1f89ee0, 0xc00042d190, 0x94, 0x1f42040, 0xc00042d1b0, 0x194, 0x2420000, 0x0, ...)
    
    	/Users/pquerna/xsrc/ductone/ops/vendor/github.com/pulumi/pulumi/sdk/v3/go/pulumi/types.go:702 +0x2662
    
    <http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.awaitInputs(0x23fd638|github.com/pulumi/pulumi/sdk/v3/go/pulumi.awaitInputs(0x23fd638>, 0xc0000580e0, 0x2088f00, 0xc00042d180, 0x99, 0x1fdc340, 0xc00042d1a0, 0x199, 0x0, 0x0, ...)
    
    	/Users/pquerna/xsrc/ductone/ops/vendor/github.com/pulumi/pulumi/sdk/v3/go/pulumi/types.go:734 +0x150a
    
    <http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.toOutputTWithContext.func3(0xc00042d1c0|github.com/pulumi/pulumi/sdk/v3/go/pulumi.toOutputTWithContext.func3(0xc00042d1c0>, 0x2088f00, 0xc00042d180, 0x2409798, 0xc00029dc70, 0x23fd638, 0xc0000580e0, 0x1fdc340, 0xc00042d1a0, 0x199, ...)
    
    	/Users/pquerna/xsrc/ductone/ops/vendor/github.com/pulumi/pulumi/sdk/v3/go/pulumi/types.go:828 +0x137
    
    created by <http://github.com/pulumi/pulumi/sdk/v3/go/pulumi.toOutputTWithContext|github.com/pulumi/pulumi/sdk/v3/go/pulumi.toOutputTWithContext>
    
    	/Users/pquerna/xsrc/ductone/ops/vendor/github.com/pulumi/pulumi/sdk/v3/go/pulumi/types.go:820 +0x216
    c
    • 2
    • 3
  • b

    bored-spoon-83710

    08/06/2021, 9:09 AM
    Hello, I’ve used crd2pulumi to generate Go code for cert-manager CRDs and I get the following file structure:
    crds
    └── go
        ├── acme
        │   ├── v1
        │   │   ├── challenge.go
        │   │   ├── init.go
        │   │   ├── order.go
        │   │   └── pulumiTypes.go
        │   ├── v1alpha2
        │   │   ├── challenge.go
        │   │   ├── init.go
        │   │   ├── order.go
        │   │   └── pulumiTypes.go
        │   ├── v1alpha3
        │   │   ├── challenge.go
        │   │   ├── init.go
        │   │   ├── order.go
        │   │   └── pulumiTypes.go
        │   └── v1beta1
        │       ├── challenge.go
        │       ├── init.go
        │       ├── order.go
        │       └── pulumiTypes.go
        ├── certmanager
        │   ├── v1
        │   │   ├── certificate.go
        │   │   ├── certificateRequest.go
        │   │   ├── clusterIssuer.go
        │   │   ├── init.go
        │   │   ├── issuer.go
        │   │   └── pulumiTypes.go
        │   ├── v1alpha2
        │   │   ├── certificate.go
        │   │   ├── certificateRequest.go
        │   │   ├── clusterIssuer.go
        │   │   ├── init.go
        │   │   ├── issuer.go
        │   │   └── pulumiTypes.go
        │   ├── v1alpha3
        │   │   ├── certificate.go
        │   │   ├── certificateRequest.go
        │   │   ├── clusterIssuer.go
        │   │   ├── init.go
        │   │   ├── issuer.go
        │   │   └── pulumiTypes.go
        │   └── v1beta1
        │       ├── certificate.go
        │       ├── certificateRequest.go
        │       ├── clusterIssuer.go
        │       ├── init.go
        │       ├── issuer.go
        │       └── pulumiTypes.go
        └── pulumiUtilities.go
    I expected that the acme folder be under the certmanager folder, since the API group of these CRDs is
    <http://acme.cert-manager.io|acme.cert-manager.io>
    . I see from the code (https://github.com/pulumi/crd2pulumi/blob/765df3fae9a0b07043229c4d540c8808a5c25d65/gen/generate.go#L335) that only the first word of the API group is kept. Couldn’t we take as crd2pulumi argument a suffix to remove from the API group and a prefix to add so that for example
    crd2pulumi -g --prefix-to-add certmanager --suffix-to-remove <http://cert-manager.io|cert-manager.io> cert-manager.crds.yaml
    would give a structure like that?
    crds
    └── go
        ├── certmanager
        │   ├── acme
        │   │   ├── v1
        │   │   │   ├── challenge.go
        │   │   │   ├── init.go
        │   │   │   ├── order.go
        │   │   │   └── pulumiTypes.go
        │   │   ├── v1alpha2
        │   │   │   ├── challenge.go
        │   │   │   ├── init.go
        │   │   │   ├── order.go
        │   │   │   └── pulumiTypes.go
        │   │   ├── v1alpha3
        │   │   │   ├── challenge.go
        │   │   │   ├── init.go
        │   │   │   ├── order.go
        │   │   │   └── pulumiTypes.go
        │   │   └── v1beta1
        │   │       ├── challenge.go
        │   │       ├── init.go
        │   │       ├── order.go
        │   │       └── pulumiTypes.go
        │   ├── v1
        │   │   ├── certificate.go
        │   │   ├── certificateRequest.go
        │   │   ├── clusterIssuer.go
        │   │   ├── init.go
        │   │   ├── issuer.go
        │   │   └── pulumiTypes.go
        │   ├── v1alpha2
        │   │   ├── certificate.go
        │   │   ├── certificateRequest.go
        │   │   ├── clusterIssuer.go
        │   │   ├── init.go
        │   │   ├── issuer.go
        │   │   └── pulumiTypes.go
        │   ├── v1alpha3
        │   │   ├── certificate.go
        │   │   ├── certificateRequest.go
        │   │   ├── clusterIssuer.go
        │   │   ├── init.go
        │   │   ├── issuer.go
        │   │   └── pulumiTypes.go
        │   └── v1beta1
        │       ├── certificate.go
        │       ├── certificateRequest.go
        │       ├── clusterIssuer.go
        │       ├── init.go
        │       ├── issuer.go
        │       └── pulumiTypes.go
        └── pulumiUtilities.go
  • f

    fast-florist-41572

    08/11/2021, 8:09 AM
    Is there any easy way to pass in a slice of values into
    pulumi.all
    ? The setup I have is that I create a list of AWS accounts from a JSON file, and then want to create a policy that uses the the IDs/Arns for all those accounts. However I'm not sure how best to pass this data in? Maybe I'm going about this the incorrect way but does anyone have best practises or how to do this?
  • f

    fast-florist-41572

    08/11/2021, 9:24 AM
    So I appear to have made some progress using
    pulumi.Any
    where I want to define the resources as follows
    "Resource": []interface{}{
    							pulumi.Sprintf("arn:aws:s3:::%s/AWSLogs/%s/*", ctBucket.ID(), logAccount.ID()),
    						},
    That works fine if I inline it But when I use a function instead like
    func createS3BucketPolicyResources(bucket *s3.Bucket, accounts []*organizations.Account) []pulumi.StringOutput {
    	var resources []pulumi.StringOutput
    
    	for _, account := range accounts {
    		resource := pulumi.Sprintf("arn:aws:s3:::%s/AWSLogs/%s/*", bucket.ID(), account.ID())
    		resources = append(resources, resource)
    	}
    
    	return resources
    }
    I get an error
    marshaling properties: awaiting input property policy: cannot marshal an input of type pulumi.StringOutput with element type string as a value of type pulumi.StringOutput
  • f

    fast-florist-41572

    08/11/2021, 11:09 AM
    I've had luck making sure the return from the above function is
    pulumi.StringArray
  • f

    fast-florist-41572

    08/11/2021, 1:00 PM
    If anyone still has good examples or best practises on the above would love to see them. Now trying to generate another policy for KMS and it expects a different input so the above isn't as clean
    b
    • 2
    • 32
  • m

    mammoth-honey-6147

    08/13/2021, 8:59 AM
    Does everything have to be contained within the
    pulumi.Run
    function in
    main
    ? I'm getting to the point where I'd like to break out some stuff into separate functions. For example, probing a generated url from an output until there's a response with go's native
    http
    package
    b
    • 2
    • 2
  • g

    green-motorcycle-58080

    08/13/2021, 12:30 PM
    @mammoth-honey-6147 I've had some success with breaking things out for instance I have a function with the signature
    func monitoring(ctx *pulumi.Context, k8sProvider *providers.Provider) error {...}
    and call it happily within the pulumi.Run func with
    if err = monitoring(ctx, k8sProvider); err != nil {
    	return err
    }
    m
    • 2
    • 15
  • g

    green-motorcycle-58080

    08/14/2021, 3:36 PM
    Slight correction, that should be
    kubernetes.Provider
    , not
    providers.Provider
    . Just migrating to v3 now
  • r

    ripe-shampoo-80285

    08/23/2021, 12:43 PM
    Has anybody seen this? Note it used to work fine. I upgraded golang to the last 1.16: 1.16.6, pulumi to v3.10.3 recently if that helps. Tried go clean --modcache & go mod tidy No luck.
    Not able to get k8s provider module
  • r

    ripe-shampoo-80285

    08/23/2021, 1:23 PM
    Downgrade github.com/pulumi/pulumi-kubernetes/sdk/v3 from v3.6.2 to v3.5.1 fixed the issue!!!
    g
    b
    • 3
    • 9
  • p

    purple-jelly-68780

    08/24/2021, 6:39 PM
    Super noob question here... I'm writing my first Pulumi program in Go and am having some trouble getting an int (specifically
    0
    ) to become an IntInput. I have tried:
    pulumi.IntInput(0)
    and
    var zero int = 0
    pulumi.IntInput(zero)
    and
    pulumi.IntInput(pulumi.Input(0))
    with no success 😕 I think I'm missing something fundamental here so if anyone has a moment to help clear this up for me that would be great!
    b
    • 2
    • 4
  • p

    purple-jelly-68780

    08/27/2021, 4:34 PM
    Since dynamic providers are not supported in Go, what is the appropriate workaround when you need to implement a new provider? In particular, I'm looking to create a new provider in order to update GoDaddy domain nameservers. I see that in this doc there is reference to a third type of provider that you can write yourself and share. Are there any examples on how to implement one of these providers?
    g
    • 2
    • 7
  • f

    fast-photographer-25791

    08/27/2021, 6:51 PM
    Howdy yall! im hitting the following error and and i think this could be a fairly easy fix and there is something im overlooking. Any help or advice would be appreciated. @agreeable-eye-87399 tagging for vis.
    Diagnostics:
    pulumi:pulumi:Stack (localsre-eks-dev):
    # <http://github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/providers|github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/providers>
    /Users/zcn/go/pkg/mod/github.com/pulumi/pulumi-kubernetes/sdk/v3@v3.6.3/go/kubernetes/providers/provider.go:28:38: undefined: getEnvOrDefault
    /Users/zcn/go/pkg/mod/github.com/pulumi/pulumi-kubernetes/sdk/v3@v3.6.3/go/kubernetes/providers/provider.go:28:61: undefined: parseEnvBool
    /Users/zcn/go/pkg/mod/github.com/pulumi/pulumi-kubernetes/sdk/v3@v3.6.3/go/kubernetes/providers/provider.go:31:38: undefined: getEnvOrDefault
    /Users/zcn/go/pkg/mod/github.com/pulumi/pulumi-kubernetes/sdk/v3@v3.6.3/go/kubernetes/providers/provider.go:34:53: undefined: getEnvOrDefault
    /Users/zcn/go/pkg/mod/github.com/pulumi/pulumi-kubernetes/sdk/v3@v3.6.3/go/kubernetes/providers/provider.go:34:76: undefined: parseEnvBool
    /Users/zcn/go/pkg/mod/github.com/pulumi/pulumi-kubernetes/sdk/v3@v3.6.3/go/kubernetes/providers/provider.go:37:50: undefined: getEnvOrDefault
    /Users/zcn/go/pkg/mod/github.com/pulumi/pulumi-kubernetes/sdk/v3@v3.6.3/go/kubernetes/providers/provider.go:37:73: undefined: parseEnvBool
  • w

    wide-crayon-4093

    09/07/2021, 5:51 AM
    hey everyone, I've been trying to grasp the ApplyT cause I'm loosing the current scope trying to do this:
    pgaConfig := cluster.pgaPassword.Result.ApplyT(func(pgaPassword string) string {
      println(fmt.Sprintf("%v", cluster.cfg.Databases))
      return cluster.preparePgaConfig(pgaCfg.ApiKey, pgaPassword)
    }).(pulumi.StringOutput)
    if I have many 'cluster' resources, e.g iterating over an array of clusters and generating resources, then inside ApplyT
    preparePgaConfig
    is called on the last cluster, not each. How do I pass the 'context' in there?
    b
    • 2
    • 6
  • w

    wonderful-twilight-70958

    09/18/2021, 9:10 PM
    👋
  • w

    wonderful-twilight-70958

    09/18/2021, 9:10 PM
    Trying to create a new aws-go project and when I run the
    new
    command I get the following error when installing the dependencies:
    <http://github.com/pulumi/pulumi-aws/sdk/v4/go/aws/s3|github.com/pulumi/pulumi-aws/sdk/v4/go/aws/s3>: unzip /home/john/go/pkg/mod/cache/download/github.com/pulumi/pulumi-aws/sdk/v4/@v/v4.18.0.zip: open /home/john/go/pkg/mod/github.com/pulumi/pulumi-aws/sdk/v4@v4.18.0/dotnet/KinesisAnalyticsV2/Inputs/ApplicationApplicationConfigurationSqlApplicationConfigurationReferenceDataSourceReferenceSchemaRecordFormatMappingParametersCsvMappingParametersArgs.cs: file name too long
  • w

    wonderful-twilight-70958

    09/18/2021, 9:10 PM
    Don't see anything in the go or pulumi issues about it already
  • w

    wonderful-twilight-70958

    09/18/2021, 9:12 PM
    go 1.16.6
    if relevant on Ubuntu 20.04
    s
    l
    b
    • 4
    • 23
  • q

    quick-room-65437

    09/22/2021, 3:31 PM
    Noob question: Trying to create a new vpc and then use the id in subsequent steps... however the Vpc struct that gets returned doesn't have an Id - unlike the LookupVpcResult struct.
    b
    • 2
    • 12
  • q

    quick-room-65437

    09/22/2021, 3:33 PM
    is there a way around this other than creating the VPC out of band - most of the examples seem to show the id being accessible (in typescript at least)
  • b

    billowy-army-68599

    09/22/2021, 3:34 PM
    Hey Hutch, see the thread - the VPC you're creating should have an
    id
    output - if you share your code in the thread above we should be able to get it working
  • e

    echoing-librarian-76448

    09/29/2021, 4:57 PM
    I noticed that when trying to use
    ctx.Export
    inside of an
    .ApplyT
    function, the export doesn't happen. Is this the expected behavior? Here's a code example:
    aksVNet.ID().ToStringOutput().ApplyT(func(id string) error {
    	applicationAKSSubnetID := fmt.Sprintf("%s/subnets/Application", id)
    
    	var clusterInput *aks.ClusterInput
    	if err := cfg.TryObject(appAKSClusterConfigKey, &clusterInput); err != nil {
    		return err
    	}
    
    	cluster, err = aks.CreateAKSCluster(ctx,
    		clusterInput,
    		applicationAKSSubnetID,
    		commonTags)
    	if err != nil {
    		return err
    	}
    	
    	ctx.Export("clusterName", cluster.Name)
    
    	return nil
    })
    b
    l
    • 3
    • 8
Powered by Linen
Title
e

echoing-librarian-76448

09/29/2021, 4:57 PM
I noticed that when trying to use
ctx.Export
inside of an
.ApplyT
function, the export doesn't happen. Is this the expected behavior? Here's a code example:
aksVNet.ID().ToStringOutput().ApplyT(func(id string) error {
	applicationAKSSubnetID := fmt.Sprintf("%s/subnets/Application", id)

	var clusterInput *aks.ClusterInput
	if err := cfg.TryObject(appAKSClusterConfigKey, &clusterInput); err != nil {
		return err
	}

	cluster, err = aks.CreateAKSCluster(ctx,
		clusterInput,
		applicationAKSSubnetID,
		commonTags)
	if err != nil {
		return err
	}
	
	ctx.Export("clusterName", cluster.Name)

	return nil
})
b

bored-table-20691

09/29/2021, 4:58 PM
In general you should avoid creating resources and exports in apply
e

echoing-librarian-76448

09/29/2021, 5:00 PM
I do try to avoid it but there are times when I need a string value of a
pulumi.StringOutput
that I haven't found another way to access without
.ApplyT
you can see in the example that I'm trying to get a newly created VNet ID so I can build the subnet info. I wasn't been able to get the subnet ID directly
Is there a way to get a specific subnet's ID directly, even if it's a
pulumi.StringOutput
type? I could refactor our code to not need the plain string if it's possible.
b

bored-table-20691

09/29/2021, 7:49 PM
Which provider are you using?
l

lemon-agent-27707

09/30/2021, 1:00 AM
Exporting values from within apply is not supported and will not work.
👍 1
You can accomplish the same thing by running an apply, returning the value you want to export, and exporting the output returned by the apply. Some pseudocode:
idOutput := val.Apply( v => ...someTransform.. return v.id);
ctx.export("idOutput", idOutput)
e

echoing-librarian-76448

10/06/2021, 2:56 PM
Sorry for the slow reply. I was able to get back to this today and ended up refactoring some functions to use
pulumi.StringInput
as a parameter instead of
String
I was able to avoid using
ApplyT
after making that switch. Thanks for the guidance on this
😛artypus: 1
View count: 4