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

    gifted-city-99717

    05/27/2020, 4:10 PM
    trying again: has anyone seen this error while running tests? I could use a sanity check.
    ♥ λ 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]
    thanks!
    b
    • 2
    • 10
  • g

    gifted-city-99717

    05/28/2020, 10:05 PM
    I have a go-related / design question - When defining a custom component, in the examples I’ve seen (eg: s3folder component) - there is an exported args struct and a shadowed, non-exported args struct.
    type folderArgs struct {
    }
    
    type FolderArgs struct {
    }
    I’ve applied this pattern, but I’m not sure why. Is this a state management thing? I see the
    ElementType
    function below and see some reflection going on… Where would be the best place to read up on this in pulumi source or docs? Thanks!
  • l

    lemon-agent-27707

    05/28/2020, 10:59 PM
    Not necessary, check out this example: https://github.com/pulumi/examples/blob/master/azure-go-webserver-component/webserver.go
    👍 1
  • g

    gifted-city-99717

    05/29/2020, 8:20 PM
    What’s the recommended way to pass complex config types (
    []string{}
    ,
    map[string]string
    ) into integration.ProgramTest - The
    Config
    attribute in integration.ProgramTestOptions is a
    map[string]string{}
    l
    • 2
    • 2
  • g

    gifted-city-99717

    06/02/2020, 4:57 PM
    It appear functions like
    ec2.LookupVpc
    don’t perform lookups in [unit] tests. Are there any examples of mocking them out?
    l
    • 2
    • 3
  • a

    adventurous-book-24480

    06/09/2020, 1:53 PM
    I'm currently discovering an ECS Cluster name using a
    pulumi.NewRemoteStateReference
    that points to a terraform state file in S3. The resulting type is
    pulumi.StringOutput
    . I need to now call
    ecs.LookupCluster()
    to discover the cluster's Arn. How do I get my
    pulumi.StringOutput
    to satisfy
    string
    for the input?
  • a

    adventurous-book-24480

    06/09/2020, 2:33 PM
    Solved it!
  • a

    adventurous-book-24480

    06/09/2020, 2:33 PM
    🦆
  • w

    wet-egg-6347

    06/09/2020, 3:25 PM
    is there a plan/timeline for supporting dynamic resource providers in Go?
  • g

    gifted-city-99717

    06/12/2020, 2:28 AM
    what’s the best way to get a string from an stringOutput? I only see
    // Helpers for accessing properties are not yet available in Go.
    in the docs
    l
    • 2
    • 1
  • g

    gifted-city-99717

    06/12/2020, 3:41 AM
    My integration test is timing out. Is there a way to override the test timeout? I have a 30m timeout set on the resource, but it doesn’t seem to propagate up
    [ oyments/ci-telemetry/escluster ]  +  pulumi:pulumi:Stack escluster-p-it-loptaploca-escluster-cd98c21a creating
    [ oyments/ci-telemetry/escluster ]  +  citelemetry:elasticsearch:ESClusterComponent insights-ci-es-dev creating
    [ oyments/ci-telemetry/escluster ]  +  aws:ec2:SecurityGroup insights-ci-es-dev-sg creating
    [ oyments/ci-telemetry/escluster ]  +  aws:iam:ServiceLinkedRole insights-ci-es-dev-linked-role creating
    [ oyments/ci-telemetry/escluster ]  +  aws:iam:ServiceLinkedRole insights-ci-es-dev-linked-role created
    [ oyments/ci-telemetry/escluster ]  +  aws:ec2:SecurityGroup insights-ci-es-dev-sg created
    [ oyments/ci-telemetry/escluster ]  +  aws:elasticsearch:Domain insights-ci-es-dev creating
    [ oyments/ci-telemetry/escluster ] @ Updating....[ oyments/ci-telemetry/escluster ] Still running command '/usr/local/bin/pulumi up --non-interactive --yes --skip-preview --event-log /var/folders/30/1ks5_94n54x29jjdkhvj974m0000gn/T/p-it-loptaploca-escluster-cd98c21a-events.json' (/Users/jws/code/gocode/src/stackName-1591932181711912000)...
    [ oyments/ci-telemetry/escluster ] .[ oyments/ci-telemetry/escluster ] .[ oyments/ci-telemetry/escluster ] .[ oyments/ci-telemetry/escluster ] .[ oyments/ci-telemetry/escluster ] .[ oyments/ci-telemetry/escluster ] .[ oyments/ci-telemetry/escluster ] Still running command '/usr/local/bin/pulumi up --non-interactive --yes --skip-preview --event-log /var/folders/30/1ks5_94n54x29jjdkhvj974m0000gn/T/p-it-loptaploca-escluster-cd98c21a-events.json' (/Users/jws/code/gocode/src/stackName-1591932181711912000)...
    [ oyments/ci-telemetry/escluster ] .[ oyments/ci-telemetry/escluster ] .[ oyments/ci-telemetry/escluster ] .[ oyments/ci-telemetry/escluster ] .[ oyments/ci-telemetry/escluster ] .[ oyments/ci-telemetry/escluster ] .coverage: 0.0% of statements
    panic: test timed out after 10m0s
    
    goroutine 31 [running]:
    testing.(*M).startAlarm.func1()
    	/usr/local/Cellar/go/1.14.3/libexec/src/testing/testing.go:1459 +0xdf
    created by time.goFunc
    	/usr/local/Cellar/go/1.14.3/libexec/src/time/sleep.go:168 +0x44
    anyone figure out how to override the timeout in an integration test?
    l
    • 2
    • 4
  • s

    salmon-account-74572

    06/23/2020, 3:48 PM
    I'm not new to Pulumi (been using it w/ TypeScript for a while), but I am new to Go and using Go with Pulumi. I've been trying to run some of the Go examples from the GitHub examples repo (https://github.com/pulumi/examples/) as well as trying to run some simple code of my own based on those examples. No matter what I do, I just get a panic/crash. I'm at a bit of a loss on how to proceed, especially since I can't even make the examples work. Any suggestions for where I should start troubleshooting?
  • l

    lemon-agent-27707

    06/23/2020, 3:55 PM
    @salmon-account-74572 can you post an example of code you're trying to run, and the panic you're getting?
  • l

    lemon-agent-27707

    06/23/2020, 3:56 PM
    Given the lack of generics in go, we use reflection and runtime type assertions (panics) to achieve similar behavior to the other languages Input/Output systems.
  • l

    lemon-agent-27707

    06/23/2020, 3:56 PM
    Typically when you get a panic, this will be due to an improper type signature or type assertion from within an apply method.
  • s

    salmon-account-74572

    06/23/2020, 4:03 PM
    @lemon-agent-27707 Sure, let me start a thread here with some additional information.
    l
    • 2
    • 32
  • s

    salmon-account-74572

    06/24/2020, 1:26 AM
    Another question from a newcomer to Go: I'm trying to create a VPC in AWS with subnets in each AZ for that region. I have code that looks up the number of AZs in the region, and then I'm using a
    for
    loop to create a subnet in each AZ. The problem I'm having is this: how do I capture the subnet IDs as they are created? Code included in a thread below.
    g
    • 2
    • 7
  • s

    salmon-account-74572

    06/24/2020, 5:27 PM
    Anyone have an example of defining a
    Route
    when creating a
    DefaultRouteTable
    in Go? There's no example in the API reference for Go, and I can't seem to get the syntax quite right.
  • e

    echoing-librarian-76448

    06/24/2020, 7:50 PM
    Hey, first time posting. I'm running into an issue when trying to create an Azure SQL Server resource in Go. When I run
    pulumi preview
    it gives me the following error message:
    .\main.go:153:30: undefined: mssql.ServerAzureadAdministratorPtr
    .\main.go:154:4: undefined: mssql.ServerAzureadAdministratorArgs
    .\main.go:161:27: undefined: mssql.NewServer
    .\main.go:162:4: undefined: mssql.ServerArgs
    Here's the code I'm using:
    // SQLServerInput is a struct to define required Sql Server properties
    // <https://www.pulumi.com/docs/reference/pkg/azure/mssql/server/#inputs>
    type SQLServerInput struct {
    	AdministratorLogin         string
    	AdministratorLoginPassword string
    	Location                   string
    	Name                       string
    	ResourceGroupName          string
    	Version                    string
    }
    
    // SQLServerAzureADAdministrator is a struct to define Sql Server Azure AD Administrator properties
    // <https://www.pulumi.com/docs/reference/pkg/azure/mssql/server/#serverazureadadministrator>
    type SQLServerAzureADAdministrator struct {
    	LoginUsername string
    	ObjectID      string
    	TenantID      string
    }    
    
        // Validate and load SQL Server config from Stack yaml file
        sqlServerInput := []*SQLServerInput{}
        if err := cfg.TryObject("sqlServers", &sqlServerInput); err != nil {
            return err
        }
    
        // Validate and load ServerAzureADAdministrator Args
        azureADAdministratorInput := []*SQLServerAzureADAdministrator{}
        if err := cfg.TryObject("azureAdAdministrator", &azureADAdministratorInput); err != nil {
            return err
        }
    
        // Convert ServerAzureadAdministratorArgs into ServerAzureadAdministratorPtrInput per
        // <https://pkg.go.dev/github.com/pulumi/pulumi-azure/sdk/v3@v3.9.3/go/azure/mssql?tab=doc#ServerArgs>
        azureADAdministratorArgs := mssql.ServerAzureadAdministratorPtr(
            &mssql.ServerAzureadAdministratorArgs{
                LoginUsername: pulumi.String(azureADAdministratorInput[0].LoginUsername),
                ObjectId:      pulumi.String(azureADAdministratorInput[0].ObjectID),
                TenantId:      pulumi.StringPtr(azureADAdministratorInput[0].TenantID),
            })
    
        // Create the SQL Server
        preprodSQLServer, err := mssql.NewServer(ctx, sqlServerInput[0].Name,
            &mssql.ServerArgs{
                Name:                       pulumi.StringPtr(sqlServerInput[0].Name),
                ResourceGroupName:          pulumi.String(sqlServerInput[0].ResourceGroupName),
                AdministratorLogin:         pulumi.String(sqlServerInput[0].AdministratorLogin),
                AdministratorLoginPassword: pulumi.String(sqlServerInput[0].AdministratorLoginPassword),
                AzureadAdministrator:       azureADAdministratorArgs,
                Location:                   pulumi.StringPtr(sqlServerInput[0].Location),
                Version:                    pulumi.String(sqlServerInput[0].Version),
                Tags:                       tags,
            })
        if err != nil {
            return err
        }
    g
    • 2
    • 5
  • s

    salmon-account-74572

    06/25/2020, 10:27 PM
    Another Go newbie question here: I'm hoping someone can help me understand why different resources handle/require different types. More details and sample code threaded below.
    w
    l
    • 3
    • 20
  • b

    blue-computer-71271

    07/01/2020, 6:11 PM
    hi cross posting here since this is probably specific to the golang sdk https://pulumi-community.slack.com/archives/C84L4E3N1/p1593617389089700
    l
    • 2
    • 24
  • s

    salmon-account-74572

    07/01/2020, 8:19 PM
    Hi all, I was running into a problem with type mismatches that was fixed by a recent commit (see https://pulumi-community.slack.com/archives/CCWP5TJ5U/p1593124071219300 and the resulting thread). However, it now appears that the use of
    Pulumi.Map
    to create maps for assigning AWS tags is broken. Sample code is threaded below.
    l
    • 2
    • 6
  • s

    salmon-account-74572

    07/01/2020, 10:48 PM
    All the examples of using
    ec2.NewSecurityGroup
    only have a single ingress rule. What's the syntax for specifying multiple ingress rules?
    l
    • 2
    • 3
  • b

    blue-computer-71271

    07/02/2020, 1:52 AM
    is there a clean way to convert map[string]string to a StringMap that i'm not seeing in the api?
  • i

    important-appointment-55126

    07/02/2020, 1:55 AM
    you’ll have to loop over it and construct it afaik; i’m not aware of a helper just to do the
    pulumi.String
    wrapping for you
  • i

    important-appointment-55126

    07/02/2020, 1:55 AM
    only a few lines though
  • l

    lemon-agent-27707

    07/02/2020, 2:49 AM
    No helpers at the moment. I agree it's a little verbose. Feel free to add a 👍 or comment to this issue if you'd like to see helpers added: https://github.com/pulumi/pulumi/issues/3861
    b
    • 2
    • 1
  • s

    salmon-account-74572

    07/02/2020, 8:46 PM
    I'd like to define a set of tags that are applied to all resources, but still have additional tags that are defined per-resource. What's the best way to do that in Go?
    b
    l
    • 3
    • 4
  • e

    echoing-rain-5741

    07/06/2020, 2:48 PM
    Hi guys! I’m having some trouble understanding the difference between a
    pulumi.Output
    and a
    Pulumi.OutputState
    . I’m creating a config file ( in the form of a
    pulumi.StringMap
    ) that includes various references to other pulumi resources, hence I used the
    pulumi.All(arg1, arg2,...).ApplyT(func(args []interface{}) (pulumi.StringMap,error){...})
    (as suggested in the docs,) which supposedly returns a
    pulumi.Output
    To be able to use it to create a kubernetes ConfigMap, i need to have a OutputState. What would the best way be to convert the output to the output state be, and what is the difference? I managed to convert the
    pulumi.Output
    config to a output state using
    configMapData.Apply(func(x interface{}) (interface{}, error) { return x, nil }).OutputState
    but this seems overly convoluted.
    w
    l
    • 3
    • 4
  • m

    magnificent-baker-63834

    07/16/2020, 7:40 AM
    Can anyone tell me if it's possible to use Pulumi within a Go application without having to use the
    pulumi
    cli commands? I'd like to use it as part of a larger application but can't seem to find any documentation on how or even if it's possible.
    g
    b
    l
    • 4
    • 9
Powered by Linen
Title
m

magnificent-baker-63834

07/16/2020, 7:40 AM
Can anyone tell me if it's possible to use Pulumi within a Go application without having to use the
pulumi
cli commands? I'd like to use it as part of a larger application but can't seem to find any documentation on how or even if it's possible.
g

gentle-diamond-70147

07/16/2020, 7:50 AM
It's not currently possible, but something we're hoping to enable soon! Please follow https://github.com/pulumi/pulumi/issues/3901 and add any additional context on your use case there.
In the meantime you could wrap the
pulumi
cli in your application, but the issue I linked is focused on making this a first-class programmatic interface.
m

magnificent-baker-63834

07/16/2020, 7:51 AM
Ah, that's a shame. It's the sole reason we looked at using Pulumi over Terraform. 😞
Is the CLI output machine-readable enough for that to be reliable? We're looking at building a service that'll manage Kubernetes clusters and underlying infrastructure for many, many teams over as many different AWS accounts so needs to be able to handle failures.
g

gentle-diamond-70147

07/16/2020, 7:54 AM
The resulting state file from a
preview
or
up
is machine-readable as JSON so could certainly be handled programmatically.
We have several customers doing a similar "managed service" type solution so we'd be happy to talk to you about this in more detail if you're interested. If so, please send an email to support@pulumi.com and I can help setup a call.
💯 1
m

magnificent-baker-63834

07/16/2020, 7:56 AM
Thanks!
b

boundless-island-27202

07/16/2020, 3:16 PM
huge +1 to this, I assumed this was already in place too considering you have a programmatic model.
l

lemon-agent-27707

08/29/2020, 3:41 PM
Just wanted to follow up and mention that we merged the first PR for the Automation API Go SDK! https://github.com/pulumi/pulumi/pull/4977 It's in alpha and there will be (mostly additive) breaking changes in the coming weeks. There are complete godocs here that you can check out: https://godoc.org/github.com/pulumi/pulumi/sdk/go/x/auto In addition, there are still a bunch of holes that we'll be plugging over the next few weeks. Here's a list of known issues that we're tracking: https://github.com/pulumi/pulumi/issues?q=is%3Aissue+is%3Aopen+label%3Aarea%2Fautomation-api If you'd like to try it out, you'll need to build pulumi/pulumi as there are CLI changes. We'll cut a CLI release early next week that will make it easier to try all of this out. I'll be updating https://github.com/pulumi/pulumi/issues/3901 with instructions and a call for feedback early next week, but I thought I'd let ya'll know in the mean time in case you're eager to kick the tires. If the feedback on the design is positive, we'll follow up with all of the supported pulumi languages.
View count: 3