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

    elegant-dress-88912

    10/06/2020, 3:10 PM
    trying to create instance template and specify metadata in https://pkg.go.dev/github.com/pulumi/pulumi-gcp/sdk/v3/go/gcp/compute#InstanceTemplateArgs
  • e

    elegant-dress-88912

    10/06/2020, 3:10 PM
    found no examples unfortunately
  • e

    elegant-dress-88912

    10/06/2020, 3:12 PM
    ah, found it.
    pulumi.Map{}
    works
  • r

    rich-exabyte-94739

    10/07/2020, 5:56 PM
    Question: I'm trying to get a StackReference for our
    infra
    stack in our `api`stack and using the example code is returning an error:
    slug := fmt.Sprintf("foo/%v/%v", ctx.Project(), "infra")
    stackRef, err := pulumi.NewStackReference(ctx, slug, nil)
    if err != nil {
    	return err
    }
    Returns the following error:
    pulumi:pulumi:StackReference (foo/bar/api):
        error: resource 'urn:pulumi:api::bar::pulumi:pulumi:StackReference::foo/bar/api' registered twice (read and read)
    Am I missing something here?
    • 1
    • 1
  • s

    stocky-spoon-28903

    10/07/2020, 6:31 PM
    Sounds like this is elsewhere in the file too?
  • r

    rich-exabyte-94739

    10/07/2020, 6:36 PM
    Nope, this is the only
    pulumi.NewStackReference
    stack ref
  • r

    rich-exabyte-94739

    10/07/2020, 7:02 PM
    Actually, I take that back. I was calling it twice. Problem solved.
  • s

    stocky-spoon-28903

    10/07/2020, 8:40 PM
    👍
  • t

    tall-needle-56640

    10/08/2020, 9:01 PM
    I'm new to Go. How can I run the CLI from the command line? I deployed the
    pulumi/pulum
    image, ran
    make ensure
    and then
    make
    . Then I tried to run
    go run main.go
    but I get an error: "./main.go:48:12: undefined: NewPulumiCmd"
    b
    s
    • 3
    • 5
  • f

    faint-eye-21524

    10/09/2020, 2:03 AM
    Hey. Has anyone tried to create a Managed Instance Group using custom instance templates in GCP? I didn't see the MIG type in the sdk. Any pointers?
    e
    • 2
    • 3
  • s

    strong-musician-98782

    10/15/2020, 12:38 PM
    Hey, i'm unsure if that's the correct channel to ask that but i'm trying to convert Terraform's DYN provider to pulumi via pulumi-tf-provider-boilerplate and i'm encountering this error while building the provider:
    (venv)  morz@morz-5480  ~/git/pulumi-dyn   master ±  make
    ===========
    dyn Package
    ===========
    BUILD:
    [ -x /home/adirc/.pulumi/bin/pulumi ] || curl -fsSL <https://get.pulumi.com> | sh
    cd provider && go install -ldflags "-X <http://github.com/pulumi/pulumi-dyn/provider/pkg/version.Version=v0.0.1-alpha.1593782371+g931a267.dirty|github.com/pulumi/pulumi-dyn/provider/pkg/version.Version=v0.0.1-alpha.1593782371+g931a267.dirty>" <http://github.com/pulumi/pulumi-dyn/provider/cmd/pulumi-tfgen-dyn|github.com/pulumi/pulumi-dyn/provider/cmd/pulumi-tfgen-dyn>
    # <http://github.com/pulumi/pulumi-dyn/provider|github.com/pulumi/pulumi-dyn/provider>
    ./resources.go:90:21: 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)
    Makefile:75: recipe for target 'tfgen' failed
    make: *** [tfgen] Error 2
    seems to be unrelated to my changes, is it possible that terraform changed their schema or something else that could cause it to break? Thanks 🙂
    b
    b
    • 3
    • 8
  • b

    big-account-56668

    10/20/2020, 5:57 PM
    I've not been able to reproduce this locally and it's possible it is not Pulumi related. However in our CI setup since adding a Pulumi program we keep getting errors like the following for a lot of linters run with
    golangci-lint
    1.31.0
    ERRO Running error: gofmt: analysis skipped: errors in package: [/home/circleci/project/cmd/pulumi/main.go:11:2: could not import <http://github.com/pulumi/pulumi-gcp/sdk/v3/go/gcp/compute|github.com/pulumi/pulumi-gcp/sdk/v3/go/gcp/compute> (-: could not load export data: no export data for "<http://github.com/pulumi/pulumi-gcp/sdk/v3/go/gcp/compute|github.com/pulumi/pulumi-gcp/sdk/v3/go/gcp/compute>")]
    It is not only
    gofmt
    but happens for
    gocritic
    and
    errcheck
    as well. I don't know what the error means but that package specifically has caused a lot of pain as it is linking ~3000 types taking up considerable resources. Does anyone know what the error means and possibly how to address it other than disabling the linters? I'm at a loss.
    • 1
    • 1
  • i

    icy-london-58403

    10/20/2020, 11:23 PM
    can’t find any information on how to access a component’s outputs in golang. I have the following component:
    // AZ args for the vpc
    type AZ struct {
    	pulumi.ResourceState
    }
    // NewAZ makes a new AZ for the VPC to test NAT
    func NewAZ(ctx *pulumi.Context, name string, args *AZArgs, opts ...pulumi.ResourceOption) (*AZ, error) {
    ...
    ...
    ...
    	ctx.RegisterResourceOutputs(AZ, pulumi.Map{
    		"PublicSubnetID":  publicSubnet.ID(),
    		"PrivateSubnetID": privateSubnet.ID(),
    	})
    	return AZ, nil
    }
    I need the IDs of the subnets being created.
    l
    • 2
    • 13
  • g

    gifted-city-99717

    10/21/2020, 8:20 PM
    I’m writing unit tests in go. In a function I’m using an ApplyString to extract the string out of the StringOutput, When testing I’m seeing and I’m not sure what it means, or how to fix it
    panic: applier must have 1 input parameter assignable from interface {} [recovered]
    	panic: applier must have 1 input parameter assignable from interface {}
    l
    • 2
    • 4
  • b

    big-account-56668

    10/28/2020, 10:35 AM
    I'm experiencing compilation of
    <http://github.com/pulumi/pulumi-gcp/sdk/v3/go/gcp/compute|github.com/pulumi/pulumi-gcp/sdk/v3/go/gcp/compute>
    to be untenable.
    time GOGC=5 go build <http://github.com/pulumi/pulumi-gcp/sdk/v3/go/gcp/compute|github.com/pulumi/pulumi-gcp/sdk/v3/go/gcp/compute>
    go build <http://github.com/pulumi/pulumi-gcp/sdk/v3/go/gcp/compute|github.com/pulumi/pulumi-gcp/sdk/v3/go/gcp/compute>: /usr/lib/go/pkg/tool/linux_amd64/compile: signal: killed
    GOGC=5 go build <http://github.com/pulumi/pulumi-gcp/sdk/v3/go/gcp/compute|github.com/pulumi/pulumi-gcp/sdk/v3/go/gcp/compute>  1692.27s user 245.14s system 338% cpu 13:33.62 total
    still getting killed. From
    dmesg
    Out of memory: Killed process 543715 (compile) total-vm:7909668kB, anon-rss:7163404kB, file-rss:0kB, shmem-rss:304kB, UID:1000 pgtables:14172kB oom_score_adj:0
    Are there any suggestions on how to address this other than tweaking
    GOGC
    as previously suggested in https://pulumi-community.slack.com/archives/CCWP5TJ5U/p1601400720014500?thread_ts=1601396803.013000&amp;cid=CCWP5TJ5U?
    • 1
    • 1
  • s

    salmon-account-74572

    10/28/2020, 3:58 PM
    As I understand it (and correct me if I'm wrong), part of the reason for using custom
    Output
    types is to track resource state, dependencies, etc. Can someone enlighten me as to why we might need to preserve such additional information across stacks? I'm thinking of a
    StackReference
    producing
    Outputs
    .
    b
    • 2
    • 3
  • s

    salmon-account-74572

    10/28/2020, 4:54 PM
    OK, another question related to the previous one: why is it that I can use the Automation API to retrieve "ordinary" values from a stack's output (i.e., a simple
    String
    instead of a
    StringOutput
    )? And is there a way (seems like I tried it and it didn't work) to use the Automation API methods/functions inside a stack's code?
  • s

    salmon-account-74572

    10/28/2020, 5:44 PM
    Is there seriously NO way to just extract the value(s) from an
    Output
    when using a
    StackReference
    ? I know I'm a Go newbie, but...wow. I have a value that represents the number of AZs in an AWS region. I just need to get to that value, and be able to use it as a number. No matter what I try, I just run right into a brick wall of
    Output
    limitations.
    b
    • 2
    • 6
  • f

    future-ocean-92178

    10/30/2020, 8:42 AM
    Hi, may I ask a question here . below code does not work , it says ./main.go:207:19: mixture of field:value and value initializers ./main.go:208:4: cannot use vswitchId (type vpc.Switch) as type pulumi.Resource in slice literal: vpc.Switch does not implement pulumi.Resource (pulumi.addTransformation method has pointer receiver) . what is the correct way to use DependsOn ?
    eni1, err := vpc.NewNetworkInterface(ctx, name, &vpc.NetworkInterfaceArgs{
    VswitchId: vswitchId.ID(),
    SecurityGroups: pulumi.StringArray{
    sgid,
    },
    pulumi.DependsOn([]pulumi.Resource{
    vswitchId,
    }),
  • f

    future-ocean-92178

    10/30/2020, 8:44 AM
    I understand pulumi will solve the dependency automatically. however, in my case, the eni1 will fail to create at the first time to execute "pulumi up". it will sucess at second time to try "pulumi up". so I thought use dependson might able to solve the problem. but could not figure out how to use DependsOn.
  • q

    quiet-restaurant-29133

    11/01/2020, 7:55 AM
    Hi, is there any way to run the unit tests as part of
    pulumi preview
    , now I have to run
    go test
    command manually inside GitHub actions
  • c

    clever-byte-21551

    11/04/2020, 6:55 PM
    This is really bugging me, but I’m using #automation-api and have a program that uses pulumi-kubernetes and pulumi-aws and my binaries are huge (600>mb) and compilation takes 30-60 seconds because of the CGO compiler. Are you guys going to address that somehow? It’s really annoying to run my program during testing.
    l
    • 2
    • 10
  • r

    rich-exabyte-94739

    11/13/2020, 4:29 AM
    Hey All, Big fan of Pulumi - automation has done wonders for our deployments. We are running into an issue when restoring an RDS instance from a snapshot. We pass the snapshot ID to
    rds.Instance
    and
    pulumi up
    , everything works as expected. However - when we run
    pulumi up
    again to make other changes Pulumi tries to replace the database entirely, using the snapshot ID previously provided. We've tried modifying the
    rds.Instance
    , removing the snapshot ID in subsequent
    pulumi up
    commands but the same issue still persists. What are we doing wrong? How do we get Pulumi back to a good state where it's not trying to constantly try and replace our DB with the snapshot?
    c
    • 2
    • 3
  • c

    crooked-lunch-83455

    11/16/2020, 11:53 PM
    How do I access a
    StringMapOutput
  • c

    crooked-lunch-83455

    11/16/2020, 11:53 PM
    I have been trying to interface between TerraformRemoteStates and I have the Outputs Parsed but I can't range over it
  • i

    important-appointment-55126

    11/16/2020, 11:59 PM
    a
    StringMapOutput
    is really a promise that a string map will resolve sometime later; it's not concrete to range over at that point - You can use
    MapIndex
    on it to get a promise of an output that will come as a lookup of a key.. but if you really need to range over it, you'll have to use
    Apply
    which will cause your function to run once it's resolved - see https://www.pulumi.com/docs/intro/concepts/programming-model/#apply
    c
    • 2
    • 1
  • q

    quiet-restaurant-29133

    11/26/2020, 5:04 AM
    is it possible to convert
    pulumi.StringOutout
    to a
    string
    ?, the
    applyString
    is just a transformer. I have templates that need outputs from a pulumi
    resource
    output that takes in a
    string
    only
    c
    i
    • 3
    • 8
  • s

    strong-dusk-45926

    12/01/2020, 7:53 AM
    Hi, Is there a way to convert map[string]interface{} to Pulumi.Map?
    c
    l
    • 3
    • 2
  • g

    gifted-city-99717

    12/03/2020, 2:59 AM
    I’m running into the following error:
    $ pulumi version
    v2.15.0
    
    $ go test -v -cover ./...
    # gocloud.dev/blob/azureblob
    ../../../../../../pkg/mod/gocloud.dev@v0.20.0/blob/azureblob/azureblob.go:384:42: not enough arguments in call to dstBlobURL.StartCopyFromURL
    	have (context.Context, url.URL, azblob.Metadata, azblob.ModifiedAccessConditions, azblob.BlobAccessConditions)
    	want (context.Context, url.URL, azblob.Metadata, azblob.ModifiedAccessConditions, azblob.BlobAccessConditions, azblob.AccessTierType, azblob.BlobTagsMap)
    ../../../../../../pkg/mod/gocloud.dev@v0.20.0/blob/azureblob/azureblob.go:646:18: undefined: azblob.BlobItem
    FAIL	<http://maestro.corelight.io/research-infra/crunchmon/cmd/haven|maestro.corelight.io/research-infra/crunchmon/cmd/haven> [build failed]
    this came after removing the following from go.mod
    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
    b
    • 2
    • 2
  • i

    icy-helmet-84765

    12/07/2020, 4:17 PM
    I'm relatively new to pulumi and am having a bit of a hard time figuring out how to add a validation step to my infrastructure build out. What I am interested in doing is: 1. Build a VM via pulumi 2. Add DNS records via pulumi 3. Validate the DNS records have propagated via SOA & a few more things (I have code for this already, but am not sure how to tie it to the pulumi flow engine) 4. Add a final DNS record via pulumi It seemed to be
    dynamic providers
    but that isn't supported by golang with the docs on the site. Any pointers on how to add step 3 via golang?
    l
    • 2
    • 5
Powered by Linen
Title
i

icy-helmet-84765

12/07/2020, 4:17 PM
I'm relatively new to pulumi and am having a bit of a hard time figuring out how to add a validation step to my infrastructure build out. What I am interested in doing is: 1. Build a VM via pulumi 2. Add DNS records via pulumi 3. Validate the DNS records have propagated via SOA & a few more things (I have code for this already, but am not sure how to tie it to the pulumi flow engine) 4. Add a final DNS record via pulumi It seemed to be
dynamic providers
but that isn't supported by golang with the docs on the site. Any pointers on how to add step 3 via golang?
l

lemon-agent-27707

12/07/2020, 6:08 PM
Have you taken a look at Automation API? https://www.pulumi.com/blog/automation-api/ You could probably achieve this by doing a two part update. 1.
stack.up
using a program that does 1-2 2. plain go code that does (3) 3.
stack.up
using a program that does (1,2,4).
i

icy-helmet-84765

12/08/2020, 1:03 AM
I've looked at it a bit. While that could work, it largely defeats the simplicity of what pulumi appears to offer & results in 3 programs and state outside pulumi I need to mange to know which program to call... seems complex at best. Maybe I need to write providers that I can depend on for the transitions. I was hoping that this seeming common pattern of validation steps against a resource would be easy.
@lemon-agent-27707 should I use a custom provider to be able to inject something like what I'm wanting? Has anyone written anything like the before I try it?
I just realized when talking with a co-worker that maybe there is an opportunity for a generic provider that could take the custom logic code and provide a "user defined validation" pattern .... thoughts?
l

lemon-agent-27707

12/08/2020, 9:46 PM
I don't believe anyone in the community has tried to write a native pulumi provider. Might be good to put some notes about your use case in here: https://github.com/pulumi/pulumi/issues/3825
👍 1
View count: 3