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

    tall-umbrella-19082

    04/26/2020, 12:13 AM
    Hi all, I’m learning Pulumi and going through the GCP examples on github.com/pulumi/examples
  • t

    tall-umbrella-19082

    04/26/2020, 12:13 AM
    Further, I encountered the following error …
  • t

    tall-umbrella-19082

    04/26/2020, 12:14 AM
    I’m using go 1.13.10
  • t

    tall-umbrella-19082

    04/26/2020, 12:16 AM
    gcp-go-functions
    has setup the runtime to be Go1.11 for the Cloud function. However,
    go.mod
    mentions 1.13.
  • t

    tall-umbrella-19082

    04/26/2020, 12:17 AM
    Do folks know what’s going on with this context Pulumi error?
  • t

    tall-umbrella-19082

    04/26/2020, 1:19 AM
    I updated my dependencies to use github.com/pulumi/pulumi/sdk/go/pulumi
  • t

    tall-umbrella-19082

    04/26/2020, 1:20 AM
    And renamed
    NewFunctionsIamMember
    to
    NewFunctionIamMember
    w
    • 2
    • 7
  • t

    tall-umbrella-19082

    04/26/2020, 2:35 AM
    When going through the
    gcp-go-gke
    example …
  • t

    tall-umbrella-19082

    04/26/2020, 2:35 AM
  • t

    tall-umbrella-19082

    04/26/2020, 2:36 AM
    And according to https://pkg.go.dev/github.com/pulumi/pulumi-kubernetes?tab=versions I don’t see a v2 version
    w
    • 2
    • 2
  • b

    busy-account-42432

    04/26/2020, 9:58 AM
    Is there a PR for renderyamltodirectory option in the kubernetes provider for golang? I'm new to pulumi and this would be required for our GitOps workflow
    w
    • 2
    • 3
  • g

    gifted-city-99717

    04/28/2020, 1:31 AM
    Hi, are there any golang terraform provider (via tfbridge) examples out there? I haven’t seen any - I’m looking how to map Config and the Resources in the tfbridge.ProvideInfo struct to a port a grafana terraform provider… or more specifically in the generated (and commented-out) example helper functions like “makeType”
    w
    b
    • 3
    • 3
  • g

    gifted-city-99717

    04/28/2020, 6:28 PM
    has anyone run into this when building a provider? I’m seeing a type assertion that’s failing on code that was geneated. It’s saying github.com/hashicorp/terraform-plugin-sdk/helper/schema.Provider doesn’t implement github.com/hashicorp/terraform/terraform.ResourceProvider (wrong type for Apply) full stack trace:
    ♥ λ make
    ===============
    grafana Package
    ===============
    BUILD:
    cd provider && go install -ldflags "-X <http://github.com/crasiak/pulumi-grafana/provider/pkg/version.Version=v0.0.1-dev.1588091482+gbc899c3.dirty|github.com/crasiak/pulumi-grafana/provider/pkg/version.Version=v0.0.1-dev.1588091482+gbc899c3.dirty>" <http://github.com/crasiak/pulumi-grafana/provider/cmd/pulumi-tfgen-grafana|github.com/crasiak/pulumi-grafana/provider/cmd/pulumi-tfgen-grafana>
    # <http://github.com/crasiak/pulumi-grafana/provider|github.com/crasiak/pulumi-grafana/provider>
    ./resources.go:98:25: impossible type assertion:
    	*"<http://github.com/hashicorp/terraform-plugin-sdk/helper/schema|github.com/hashicorp/terraform-plugin-sdk/helper/schema>".Provider does not implement "<http://github.com/hashicorp/terraform/terraform|github.com/hashicorp/terraform/terraform>".ResourceProvider (wrong type for Apply method)
    		have Apply(*"<http://github.com/hashicorp/terraform-plugin-sdk/terraform|github.com/hashicorp/terraform-plugin-sdk/terraform>".InstanceInfo, *"<http://github.com/hashicorp/terraform-plugin-sdk/terraform|github.com/hashicorp/terraform-plugin-sdk/terraform>".InstanceState, *"<http://github.com/hashicorp/terraform-plugin-sdk/terraform|github.com/hashicorp/terraform-plugin-sdk/terraform>".InstanceDiff) (*"<http://github.com/hashicorp/terraform-plugin-sdk/terraform|github.com/hashicorp/terraform-plugin-sdk/terraform>".InstanceState, error)
    		want Apply(*"<http://github.com/hashicorp/terraform/terraform|github.com/hashicorp/terraform/terraform>".InstanceInfo, *"<http://github.com/hashicorp/terraform/terraform|github.com/hashicorp/terraform/terraform>".InstanceState, *"<http://github.com/hashicorp/terraform/terraform|github.com/hashicorp/terraform/terraform>".InstanceDiff) (*"<http://github.com/hashicorp/terraform/terraform|github.com/hashicorp/terraform/terraform>".InstanceState, error)
    ./resources.go:119:3: cannot use preConfigureCallback (type func(resource.PropertyMap, *"<http://github.com/hashicorp/terraform/terraform|github.com/hashicorp/terraform/terraform>".ResourceConfig) error) as type tfbridge.PreConfigureCallback in field value
    make: *** [tfgen] Error 2
    and go.mod looks like:
    module <http://github.com/crasiak/pulumi-grafana/provider|github.com/crasiak/pulumi-grafana/provider>
    
    go 1.13
    
    replace <http://github.com/Azure/go-autorest|github.com/Azure/go-autorest> => <http://github.com/Azure/go-autorest|github.com/Azure/go-autorest> v12.4.3+incompatible
    
    require (
    	<http://github.com/hashicorp/terraform|github.com/hashicorp/terraform> v0.12.2
    	<http://github.com/hashicorp/terraform-plugin-sdk|github.com/hashicorp/terraform-plugin-sdk> v1.8.0
    	<http://github.com/pulumi/pulumi-terraform-bridge/v2|github.com/pulumi/pulumi-terraform-bridge/v2> v2.0.0
    	<http://github.com/pulumi/pulumi/sdk/v2|github.com/pulumi/pulumi/sdk/v2> v2.0.0
    	<http://github.com/terraform-providers/terraform-provider-grafana|github.com/terraform-providers/terraform-provider-grafana> v1.5.0
    )
    b
    • 2
    • 2
  • g

    green-morning-1318

    05/05/2020, 12:21 AM
    Diagnostics:
      pulumi:pulumi:Stack (marketplace-dev):
        panic: fatal: An assertion has failed: {<nil> <nil> <nil> <nil> 173f6e1d-e6a5-4d4d-9fe0-555c41c9faa0 <nil>}: cannot assign vsphere.virtualMachineClonePtrType to vsphere.VirtualMachineClone
        goroutine 52 [running]:
        <http://github.com/pulumi/pulumi/sdk/v2/go/common/util/contract.failfast(...)|github.com/pulumi/pulumi/sdk/v2/go/common/util/contract.failfast(...)>
            /Users/lstigter/go/pkg/mod/github.com/pulumi/pulumi/sdk/v2@v2.0.0/go/common/util/contract/failfast.go:23
        <http://github.com/pulumi/pulumi/sdk/v2/go/common/util/contract.Assertf(0x1e5e600|github.com/pulumi/pulumi/sdk/v2/go/common/util/contract.Assertf(0x1e5e600>, 0x1ff289a, 0x1a, 0xc000185490, 0x3, 0x3)
            /Users/lstigter/go/pkg/mod/github.com/pulumi/pulumi/sdk/v2@v2.0.0/go/common/util/contract/assert.go:33 +0x197
        <http://github.com/pulumi/pulumi/sdk/v2/go/pulumi.marshalInputAndDetermineSecret(0x1e5e6a0|github.com/pulumi/pulumi/sdk/v2/go/pulumi.marshalInputAndDetermineSecret(0x1e5e6a0>, 0xc0002a66c0, 0x211a520, 0x1e5e4a0, 0xc000185501, 0x1094ad2, 0x1de2900, 0x3, 0xc000185628, 0x109327d, ...)
            /Users/lstigter/go/pkg/mod/github.com/pulumi/pulumi/sdk/v2@v2.0.0/go/pulumi/rpc.go:244 +0x355
        <http://github.com/pulumi/pulumi/sdk/v2/go/pulumi.marshalInput(0x1dda240|github.com/pulumi/pulumi/sdk/v2/go/pulumi.marshalInput(0x1dda240>, 0xc000382660, 0x211a520, 0x1d36320, 0x1dda201, 0xc000382660, 0x194, 0x0, 0x211a520, 0x1d36320, ...)
            /Users/lstigter/go/pkg/mod/github.com/pulumi/pulumi/sdk/v2@v2.0.0/go/pulumi/rpc.go:144 +0x73
        <http://github.com/pulumi/pulumi/sdk/v2/go/pulumi.marshalInputs(0x20f38e0|github.com/pulumi/pulumi/sdk/v2/go/pulumi.marshalInputs(0x20f38e0>, 0xc0003d0000, 0x2b, 0xc000384c90, 0xc0003c24e0, 0xc0003aa0f0, 0x41, 0x0, 0x0)
            /Users/lstigter/go/pkg/mod/github.com/pulumi/pulumi/sdk/v2@v2.0.0/go/pulumi/rpc.go:102 +0x492
        <http://github.com/pulumi/pulumi/sdk/v2/go/pulumi.(*Context).prepareResourceInputs(0xc0001e4200|github.com/pulumi/pulumi/sdk/v2/go/pulumi.(*Context).prepareResourceInputs(0xc0001e4200>, 0x20f38e0, 0xc0003d0000, 0x2001f73, 0x2b, 0xc0003c24e0, 0xc0003a32c0, 0x0, 0x0, 0x0)
            /Users/lstigter/go/pkg/mod/github.com/pulumi/pulumi/sdk/v2@v2.0.0/go/pulumi/context.go:776 +0x23a
        <http://github.com/pulumi/pulumi/sdk/v2/go/pulumi.(*Context).RegisterResource.func1(0xc0003a32c0|github.com/pulumi/pulumi/sdk/v2/go/pulumi.(*Context).RegisterResource.func1(0xc0003a32c0>, 0xc0001e4200, 0x20f38e0, 0xc0003d0000, 0x2001f73, 0x2b, 0xc0003c24e0, 0x1fe7e0a, 0xc, 0x1)
            /Users/lstigter/go/pkg/mod/github.com/pulumi/pulumi/sdk/v2@v2.0.0/go/pulumi/context.go:453 +0x154
        created by <http://github.com/pulumi/pulumi/sdk/v2/go/pulumi.(*Context).RegisterResource|github.com/pulumi/pulumi/sdk/v2/go/pulumi.(*Context).RegisterResource>
            /Users/lstigter/go/pkg/mod/github.com/pulumi/pulumi/sdk/v2@v2.0.0/go/pulumi/context.go:441 +0x540
        exit status 2
    The error indicates that
    vsphere.virtualMachineClonePtrType to vsphere.VirtualMachineClone
    though according to the syntax there’s nothing wrong 😞 The equivalent of this works flawlessly when I execute it with TypeScript 🤔
    g
    • 2
    • 7
  • g

    green-morning-1318

    05/05/2020, 12:21 AM
    I’m using the vSphere provider to create a new VM:
    vm, err := vsphere.NewVirtualMachine(ctx, "TomcatServer", &vsphere.VirtualMachineArgs{
    	ResourcePoolId: pulumi.String(resourcePool.Id),
    	DatastoreId:    pulumi.StringPtr(datastore.Id),
    	Folder:         pulumi.StringPtr("Workloads"),
    	NumCpus:        pulumi.IntPtr(1),
    	Memory:         pulumi.IntPtr(1024),
    	GuestId:        pulumi.StringPtr("other-64"),
    	NetworkInterfaces: vsphere.VirtualMachineNetworkInterfaceArray([]vsphere.VirtualMachineNetworkInterfaceInput{
    		vsphere.VirtualMachineNetworkInterfaceArgs{
    			AdapterType: pulumi.String("vmxnet3"),
    			NetworkId:   pulumi.String(network.Id),
    		},
    	}),
    	Disks: vsphere.VirtualMachineDiskArray([]vsphere.VirtualMachineDiskInput{
    		vsphere.VirtualMachineDiskArgs{
    			ThinProvisioned: pulumi.BoolPtr(true),
    			Size:            pulumi.IntPtr(20),
    			Label:           pulumi.StringPtr("disk0"),
    			EagerlyScrub:    pulumi.BoolPtr(false),
    		},
    	}),
    	Clone: vsphere.VirtualMachineClonePtr(&vsphere.VirtualMachineCloneArgs{
    		TemplateUuid: pulumi.String("173f6e1d-e6a5-4d4d-9fe0-555c41c9faa0"),
    	}),
    })
    When I run this, I get an error:
  • g

    gifted-city-99717

    05/05/2020, 10:49 PM
    Hi, are there any further examples of writing tests in golang? I’ve been looking at the examples repo, and was hoping to see some other examples besides the unit tests already included… I looked at the aws provider as well but didn’t see any there either
    w
    • 2
    • 2
  • s

    stocky-motorcycle-65008

    05/11/2020, 6:44 PM
    Hello, how can I convert a custom type, pulumi.StringOutput to String?
    b
    b
    • 3
    • 4
  • h

    helpful-processor-86468

    05/13/2020, 6:53 AM
    How can I get values from nested structures?
    service, err := cloudrun.NewService(.....)
    if err != nil { return err }
    ctx.Export("gateway-metadata", service.Template.Metadata())
    This results in error
    applier must have 1 input parameter assignable
    <http://github.com/pulumi/pulumi-gcp/sdk/v3|github.com/pulumi/pulumi-gcp/sdk/v3> v3.0.1
    <http://github.com/pulumi/pulumi/sdk/v2|github.com/pulumi/pulumi/sdk/v2> v2.0.0
  • h

    helpful-processor-86468

    05/13/2020, 9:48 AM
    anyone?
  • h

    helpful-processor-86468

    05/13/2020, 10:31 AM
    Is this something that is not available? I'm reading documentation about this and it seems that it's not yet in golang... That seems to me to be really important feature not to be in official release of supported language.
    l
    • 2
    • 3
  • e

    enough-engineer-49169

    05/14/2020, 9:55 AM
    I don't if it's the good channel. But I tried for now tu use pulumi with golang. So, my question is. How can I delete a ressource without deleting the stack ? Is it possible to do it from the code. I can create a cluster, but I don't know how to remove it.
    f
    • 2
    • 1
  • s

    stocky-motorcycle-65008

    05/20/2020, 6:05 PM
    Hello anyone has an example of data sources in terraform with pulumi?
    • 1
    • 1
  • g

    gifted-city-99717

    05/20/2020, 11:22 PM
    Hi, i’m running into a go mod error I’m not sure how to fix
    imports <http://github.com/Azure/go-autorest/autorest|github.com/Azure/go-autorest/autorest>: ambiguous import: found package <http://github.com/Azure/go-autorest/autorest|github.com/Azure/go-autorest/autorest> in multiple modules:
    	<http://github.com/Azure/go-autorest|github.com/Azure/go-autorest> v12.0.0+incompatible (/Users/jws/code/gocode/pkg/mod/github.com/!azure/go-autorest@v12.0.0+incompatible/autorest)
    	<http://github.com/Azure/go-autorest/autorest|github.com/Azure/go-autorest/autorest> v0.10.0 (/Users/jws/code/gocode/pkg/mod/github.com/!azure/go-autorest/autorest@v0.10.0)
    I think I want to pin a version of autotest? is that the right way to solve a dependency error like this? i’m on
    ♥ λ go version
    go version go1.14.3 darwin/amd64
    l
    • 2
    • 4
  • g

    gifted-city-99717

    05/23/2020, 4:41 PM
    I think I found a bug:
    ♥ λ go test -v
    # <http://github.com/pulumi/pulumi/pkg/v2/resource/stack|github.com/pulumi/pulumi/pkg/v2/resource/stack>
    ../../../../../../pkg/mod/github.com/pulumi/pulumi/pkg/v2@v2.2.1/resource/stack/deployment.go:405:10: secret.Plaintext undefined (type apitype.SecretV1 has no field or method Plaintext)
    FAIL	notifying-sink [build failed]
    I can run
    pulumi preview
    without a problem
    ♥ λ pulumi preview
    Previewing update (corelight/dev):
         Type                 Name                          Plan
     +   pulumi:pulumi:Stack  corelight-notifying-sink-dev  create
     +   └─ aws:s3:Bucket     my-bucket                     create
    
    Resources:
        + 2 to create
    
    Permalink: <https://app.pulumi.com/corelight/corelight-notifying-sink/dev/previews/6a73ca35-1d63-46b1-af02-50d6f6302722>
    and my go.mod looks like this
    module notifying-sink
    
    go 1.13
    
    replace <http://github.com/Azure/go-autorest|github.com/Azure/go-autorest> => <http://github.com/Azure/go-autorest|github.com/Azure/go-autorest> v12.4.3+incompatible
    
    require (
        <http://github.com/onsi/ginkgo|github.com/onsi/ginkgo> v1.12.2 // indirect
        <http://github.com/pulumi/pulumi-aws/sdk/v2|github.com/pulumi/pulumi-aws/sdk/v2> v2.0.0
        <http://github.com/pulumi/pulumi/pkg/v2|github.com/pulumi/pulumi/pkg/v2> v2.2.1
        <http://github.com/pulumi/pulumi/sdk/v2|github.com/pulumi/pulumi/sdk/v2> v2.0.0
        <http://github.com/stretchr/testify|github.com/stretchr/testify> v1.5.1
        <http://gopkg.in/airbrake/gobrake.v2|gopkg.in/airbrake/gobrake.v2> v2.0.9 // indirect
        <http://gopkg.in/gemnasium/logrus-airbrake-hook.v2|gopkg.in/gemnasium/logrus-airbrake-hook.v2> v2.1.2 // indirect
    )
    I am able to run
    go build
    successfully
    • 1
    • 1
  • b

    brainy-psychiatrist-41826

    05/24/2020, 9:28 PM
    any maintainers here? how painful was it to port this tool to go? if/when go gets generics, do you intend on rewriting pieces of it?
  • m

    millions-judge-24978

    05/25/2020, 12:48 AM
    I’m completely lost why I get an error from this snippet
    _, err = kubernetes.NewProvider(ctx, name, &kubernetes.ProviderArgs{
    		Kubeconfig: doks.KubeConfigs.ApplyStringPtr(func(configs []digitalocean.KubernetesClusterKubeConfig) pulumi.StringPtrOutput {
    			return pulumi.StringPtr(*configs[0].RawConfig).ToStringPtrOutput()
    		}),
    	}, parent)
    panic: interface conversion: pulumi.Output is pulumi.AnyOutput, not pulumi.StringPtrOutput
    b
    • 2
    • 3
  • b

    billowy-needle-56870

    05/25/2020, 4:14 PM
    Hi. I’m trying to make something like this with go, https://github.com/pulumi/examples/blob/master/aws-ts-static-website/index.ts#L107. But how can I convert the output of the route53.GetZone function to the input of the route53.NewRecord?
    l
    • 2
    • 1
  • i

    important-appointment-55126

    05/26/2020, 6:49 PM
    For resources that want a json policy string, is there an elegant way to form those, short of constructing them inside an
    ApplyT
    with whatever arguments they depend on and returning a literal string?
  • i

    important-appointment-55126

    05/26/2020, 6:50 PM
    eg. i see from the typescript examples, one can do
    const policy = new aws.iam.RolePolicy("allow-s3-management-policy", {
        role: allowS3ManagementRole,
        policy: {
            Version: "2012-10-17",
            Statement: [{
                Sid: "AllowS3Management",
                Effect: "Allow",
                Resource: "*",
                Action: "s3:*",
            }],
        },
    }, {parent: allowS3ManagementRole});
    which makes expansion of outputs easy
  • i

    important-appointment-55126

    05/26/2020, 6:50 PM
    but it seems the same thing in Go would require me to build the policy string
    w
    • 2
    • 3
Powered by Linen
Title
i

important-appointment-55126

05/26/2020, 6:50 PM
but it seems the same thing in Go would require me to build the policy string
w

white-balloon-205

05/27/2020, 3:33 PM
Currently, you need to build the string. Supporting a strongly typed way to build these JSON objects in Go, .net and Python is tracked in https://github.com/pulumi/pulumi-terraform-bridge/issues/132 which is partly complete - and hopefully will be completed soon!
i

important-appointment-55126

05/27/2020, 4:10 PM
great thanks - For now i wrote a little helper for Go’s template library that makes it easy to use outputs with templates
my current hack, if you’re curious:
Policy: pulutil.Template(map[string]interface{}{
                                "BucketARN": bucket.Arn,
                                "KeyARN":    key.Arn,
                        }, `{
                                        "Version": "2012-10-17",
                                        "Statement": [
                                                {
                                                        "Effect": "Allow",
                                                        "Action": [
                                                                "s3:ListBucket"
                                                        ],
                                                        "Resource": [
                                                                "{{ .BucketARN }}"
                                                        ]
                                                },{
                                                        "Sid": "S3PutAndGetAccess",
                                                        "Effect": "Allow",
                                                        "Action": [
                                                                "s3:PutObject",
                                                                "s3:GetObject"
                                                        ],
                                                        "Resource": [
                                                                "{{ .BucketARN }}/*"
                                                        ]
                                                }, {
                                                        "Sid": "KMSDecryptAndEncryptAccess",
                                                        "Effect": "Allow",
                                                        "Action": [
                                                                "kms:Decrypt",
                                                                "kms:Encrypt"
                                                        ],
                                                        "Resource": "{{ .KeyARN }}"
                                                }
                                        ]
                                }`),
👍 1
View count: 3