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

    04/19/2022, 5:30 PM
    Will support for Dynamic Providers be released for Golang?
    b
    e
    • 3
    • 2
  • q

    quaint-hair-91883

    04/21/2022, 1:45 PM
    How do I get the actual
    string
    value out of
    pulumi.StringOutput
    or
    pulumi,StringPtrOutput
    ?
    e
    • 2
    • 1
  • q

    quaint-hair-91883

    04/21/2022, 1:48 PM
    I essentially have a
    Params
    struct that I use to set the values for a function and I need to get the output into the struct
  • q

    quaint-hair-91883

    04/21/2022, 1:50 PM
    I am creating a Kubernetes namespace and then I want to create a service account in that namespace.
    q
    • 2
    • 2
  • a

    astonishing-gpu-28317

    04/22/2022, 2:11 PM
    is there a way to convert an output to an input?
  • a

    astonishing-gpu-28317

    04/22/2022, 2:12 PM
    i’m trying to get a value out of the config, get it’s concrete string value using ApplyT, and then use that string value in a text template. i then return that template string in the ApplyT function, and I’d like to use the file contents in a resource
    b
    • 2
    • 6
  • b

    brave-lizard-56518

    04/24/2022, 3:49 PM
    I used the (*pulumi.Context).Export() function to export a pulumi.StringArray of subnet IDs, and a few other metadata. At the bottom is an excerpt of my stack output as stored in my state file, which I’m already able to load using pulumi.NewStackReference(), and read a plain string like the “eip-1”, for example. My code for reading the eip-1 (which works) is:
    nsr, _ := pulumi.NewStackReference(ctx, vpcStackRef, nil)
    eip1 := nsr.GetStringOutput(pulumi.String("eip-1"))
    Now what I can’t figure out is how to read “data-subnets” into a slice. Can anybody help?
    "resources": [
                    {
                        "urn": "urn:pulumi:dev::vpc::pulumi:pulumi:Stack::dev",
                        "custom": false,
                        "type": "pulumi:pulumi:Stack",
                        "outputs": {
                            "data-subnets": [
                                "subnet-abcddaed530b25d91",
                                "subnet-abcdcfacd0c04fe74",
                                "subnet-abcd693e4a8ae4ca8"
                            ],
                            "eip-1": "eipalloc-abcdcfa5cf063576d"
    e
    • 2
    • 2
  • b

    bulky-agent-73210

    04/26/2022, 1:22 PM
    Hi all, can you point me towards and example on how to create a custom resource in Golang SDK? I want to generate PGP keys. I tried some things with ComponentResource, but the output generation code runs on every
    pulumi up
    , and the output changes. So I assume I’m using the wrong approach here.
    e
    s
    • 3
    • 4
  • n

    nice-airline-86891

    04/28/2022, 4:51 AM
    are there any examples for alternatives to a huge main func? for creating a bunch of resources? vpc + eks type things?
    b
    • 2
    • 5
  • s

    salmon-account-74572

    05/02/2022, 10:07 PM
    This may be due to an error on my part, but I was just running into a problem running
    pulumi preview
    against one of my stacks (I’ll post the full error output in the thread). This is with Pulumi 3.29.1 on macOS running Go 1.18.1. The fix ended up being upgrading
    <http://golang.org/x/sys|golang.org/x/sys>
    (via
    go get -u <http://golang.org/x/sys|golang.org/x/sys>
    ), and then
    pulumi preview
    seemed to work just fine. Posting here in case someone else runs into a similar problem.
    🙌 1
    • 1
    • 2
  • c

    clean-truck-93285

    05/03/2022, 6:58 PM
    Howdy Team, when unit testing. How do you test functions that have parameters? I getting type errors when trying to run tests against my functions. For example, my SQL server function needs information about a vnet, so I pass in a vnet object. When I get to testing, I don't have a vnet object available.
    • 1
    • 1
  • b

    busy-island-31180

    05/09/2022, 11:50 PM
    how do you convert a
    *string
    to a
    pulumi.StringPtrInput
    ?
    • 1
    • 1
  • b

    bored-spoon-83710

    05/11/2022, 2:55 PM
    Hello, following the announcement of multi-language availability for AWS crosswalk, I’m wondering if Go support is already there: when I do a
    go get <http://github.com/pulumi/pulumi-awsx/sdk|github.com/pulumi/pulumi-awsx/sdk>
    it brings me a strange
    v1.0.0-testplsignore.0
    version, and when I try a
    pulumi up
    , I get the following error
    Diagnostics:
      pulumi:providers:awsx (default):
        error: no resource plugin 'pulumi-resource-awsx' found in the workspace at version v1.0.0-testplsignore.0 or on your $PATH, install the plugin using `pulumi plugin install resource awsx v1.0.0-testplsignore.0`
    This makes me think Go support isn’t ready yet. However, the relase notes talk about Go SDK: https://github.com/pulumi/pulumi-awsx/releases. What’s the current situation?
    f
    • 2
    • 10
  • f

    fancy-library-39649

    05/11/2022, 5:43 PM
    A constructor (resource A) needs a
    *string
    but all I can provide is a
    pulumi.StringOutput
    from resource B. How do I force the resolution of the StringOutput before A is initialized? I do not want to init A inside the
    Apply
    functions of B's outputs, because that gives me inaccurate previews.
  • g

    glamorous-holiday-25694

    05/11/2022, 7:01 PM
    Hi everyone. Trying Pulumi out for the first time using
    Go
    and
    AWS
    . Having a weird issue when trying to update a stack containing
    EKS
    . No matter what changes I add (a new node group or simply adding a Helm chart) an
    EKS cluster replace
    is always included in the changes. Is there something obvious Im missing? Thank you!
    b
    • 2
    • 6
  • b

    bored-spoon-83710

    05/12/2022, 3:26 PM
    Hello, trying to create an EKS cluster with a managed node group using EKS crosswalk for AWS, I get a strange error which doesn’t speak to me. Here is the code
    cluster, err := eks.NewCluster(ctx, "test",
    	&eks.ClusterArgs{
    		ProviderCredentialOpts: &eks.KubeconfigOptionsArgs{
    			RoleArn: pulumi.String("<arn>"),
    		},
    		CreateOidcProvider:   pulumi.Bool(true),
    		SkipDefaultNodeGroup: pulumi.Bool(true),
    	},
    )
    if err != nil {
    	return fmt.Errorf("failed to create EKS cluster: %w", err)
    }
    
    _, err = eks.NewManagedNodeGroup(ctx, "ng1",
    	&eks.ManagedNodeGroupArgs{
    		Cluster: cluster.Core,
    	},
    )
    if err != nil {
    	return fmt.Errorf("failed to create EKS managed node group: %w", err)
    }
    and here is the error
    Previewing update (test):
         Type                 Name                      Plan     Info
         pulumi:pulumi:Stack  pulumi-test-test           1 error; 2 messages
     
    Diagnostics:
      pulumi:pulumi:Stack (pulumi-test-test):
        error: program failed: waiting for RPCs: marshaling properties: awaiting input property cluster: expected a ec2.SecurityGroup, got a resource of type ec2.SecurityGroup
        exit status 1
     
        error: an unhandled error occurred: program exited with non-zero exit code: 1
    Do you know what this error means? Should I post this message in #aws instead?
    • 1
    • 2
  • b

    bored-spoon-83710

    05/13/2022, 2:30 PM
    Hello, I’m trying to use the Kubernetes Provider of my EKS Cluster (field Provider on the Cluster type https://pkg.go.dev/github.com/pulumi/pulumi-eks/sdk/go/eks#Cluster) to create resources in this cluster. However, I don’t know how to use it. I cannot just pass
    pulumi.Provider(cluster.Provider)
    as a resource option on a
    NewNamespace()
    call as its type is
    kubernetes.ProviderOutput
    which doesn’t seem to be compatible with
    pulumi.ProviderResource
    . Any idea?
    g
    • 2
    • 2
  • s

    steep-translator-9040

    05/17/2022, 7:54 AM
    Hi there 🙂! I’m trying to use config.RequireObject to load configuration into my struct. When I try to run a simple integration test, it panics, as it always says I haven’t set the configuration variables (even though I see them being set in the test). Am I understanding the functionality wrong? My expectation is that when provided no namespace, it uses the default one (in my example it is
    pulumi-project-name
    ), I then provide RequireObject the key of the object I want to load from configuration (in my example
    stack
    ), and it should deserialise it accordingly.
    import (
    	"<http://github.com/pulumi/pulumi/pkg/v3/testing/integration|github.com/pulumi/pulumi/pkg/v3/testing/integration>"
    	"<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi>"
    	"os"
    	"testing"
    )
    
    type Configuration struct {
    	Project string
    	Region
    	Ephemeral bool
    }
    
    type Region struct {
    	LongName  string
    	ShortName string
    }
    
    //	Pulumi.test.yaml
    // 	encryptionsalt: ...........
    //	config:
    //  	gcp:project: my-gcp-project-name
    //  	pulumi-project-name:stack:
    //    		project: my-gcp-project-name
    //    		region:
    //      		long: us-east1-b
    //      		short: US
    //    		ephemeral: false
    
    // results in error:
    // panic: missing required configuration variable 'pulumi-project-name:stack'; run `pulumi config` to set
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		var configuration Configuration
    		cfg := config.New(ctx, "")
    		cfg.RequireObject("stack", &configuration)
    	})
    }
    
    func TestExamples(t *testing.T) {
    	cwd, _ := os.Getwd()
    	integration.ProgramTest(t, &integration.ProgramTestOptions{
    		Quick:       true,
    		SkipRefresh: true,
    		Dir:         cwd,
    		Config: map[string]string{
    			"gcp:project":                            "my-gcp-project-name",
    			"pulumi-project-name:stack.project":      "my-gcp-project-name",
    			"pulumi-project-name:stack.region.short": "US",
    			"pulumi-project-name:stack.region.long":  "us-east1-b",
    			"pulumi-project-name:stack.ephemeral":    "true",
    		},
    	})
    }
    ✅ 1
    • 1
    • 1
  • b

    busy-honey-73811

    05/18/2022, 12:39 PM
    Is there a way to use a stack transformation to tag all AWS (actually
    aws-native
    ) resources in Golang? I have a real hard time to figure out how to do this (see all the
    ???
    in below example). The main problem is that
    aws-native
    uses no common (shared) types for tags and sets of tags, instead it uses generated
    interface
    types specific to each taggable resource.
    package aws
    
    import (
    	"fmt"
    	"reflect"
    	"strings"
    
    	"<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi>"
    )
    
    type Tagger struct {
    	tags map[string]string
    }
    
    func NewTagger() *Tagger {
    	return &Tagger{}
    }
    
    func (*Tagger) isTaggable(ctx *pulumi.Context, typeName string, t reflect.Type) bool {
    	if strings.HasPrefix(typeName, "aws-native:") {
    		if field, found := t.FieldByName("Tags"); found {
    			switch field.Type.Kind() {
    			case reflect.Slice:
    				return true
    			}
    		}
    	}
    	return false
    }
    
    func (t *Tagger) Apply(ctx *pulumi.Context) error {
    	return ctx.RegisterStackTransformation(
    		func(args *pulumi.ResourceTransformationArgs) *pulumi.ResourceTransformationResult {
    			if t.isTaggable(ctx, args.Type, args.Props.ElementType()) {
    				ptr := reflect.ValueOf(args.Props)
    				val := ptr.Elem()
    				tags := val.FieldByName("Tags")
    				var tagList ???
    				if !tags.IsZero() {
    					tagList = tags.Interface().(???)
    				} else {
    					tagList = ???{}
    				}
    				for k, v := range t.tags {
    					tagList = append(tagList, ???{ Key: pulumi.String(k), Value: pulumi.String(v)})
    				}
    				tags.Set(reflect.ValueOf(tagList))
    				return &pulumi.ResourceTransformationResult{
    					Props: args.Props,
    					Opts:  args.Opts,
    				}
    			}
    			ctx.Log.Warn(fmt.Sprintf("isTaggable(%s) -> false", args.Type), nil)
    			return nil
    		},
    	)
    }
    t
    • 2
    • 6
  • g

    gray-sunset-39305

    05/20/2022, 7:10 PM
    Hey all! 👋 I'm currently hitting this bug on a new stack: https://github.com/pulumi/pulumi-docker/issues/320 Does anyone have a workaround? Here's my
    main.go
    file if helpful:
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Build the container image
    		image, err := docker.NewImage(ctx, "trustified-api", &docker.ImageArgs{
    			Build: &docker.DockerBuildArgs{
    				Context:    pulumi.String("../"),
    				Dockerfile: pulumi.String("dev.Dockerfile"),
    			},
    			ImageName: pulumi.String("trustified-api:dev"),
    			SkipPush:  pulumi.Bool(true),
    		})
    		if err != nil {
    			fmt.Printf("Error building image: %s", err.Error())
    		}
    		ctx.Export("baseImageName", image.BaseImageName)
    		ctx.Export("fullImageName", image.ImageName)
    		return nil
    	})
    }
    • 1
    • 3
  • g

    gray-sunset-39305

    05/20/2022, 11:18 PM
    Hi, I’m looking for some docs and unable to find them. I’m hoping someone can point me in the right direction. I’m trying to launch a docker container in a network. I’ve created the network:
    network, err := docker.NewNetwork(ctx, "trustified", &docker.NetworkArgs{
       Attachable: pulumi.Bool(true),
       Name:       pulumi.String("trustified-" + stack),
    })
    And now trying to launch a container in that network, but I’m not certain what to put in the “NetworksAdvanced” field. It seems like my network var should be the right thing but it errors because networks doesn’t implement ContainerNetworksAdvancedArrayInput. Here’s the code I’m using:
    apiContainer, err := docker.NewContainer(ctx, "api", &docker.ContainerArgs{
       Envs:             pulumi.ToStringArray(apiEnvVars),
       Healthcheck:      nil,
       Image:            api.ImageName,
       Name:             pulumi.String("api"),
       NetworksAdvanced: network,
       Ports:            nil,
       Volumes:          nil,
    })
    How do I transform the network I created to a ContainerNetworksAdvancedArrayInput type?
  • b

    billions-wolf-76466

    05/21/2022, 5:26 PM
    Hi Does anyone know if it's possible to get the command that was run within my application? I'm adding some telemetry to track deployments etc and I'd like to know if someone ran
    pulumi up
    or
    pulumi preview
    g
    o
    • 3
    • 4
  • a

    alert-dream-49584

    05/26/2022, 5:36 PM
    Hi, I am looking to create an Aurora serverless V2 cluster for AWS Postgres DB using Pulumi golang API. I see https://github.com/pulumi/pulumi-aws/issues/1929 referencing a Terraform update, when will this be supported in the golang API?
    o
    • 2
    • 1
  • f

    flat-laptop-90489

    06/01/2022, 7:40 PM
    Is there any chance there's a golang version of this example: https://github.com/pulumi/pulumi-eks/blob/f60263061a85d2817ecd0fd4c3dbc6505e4a8df9/examples/oidc-iam-sa/index.ts#L37-L51 I'm struggling to translate this functionality to my code.
    n
    • 2
    • 6
  • b

    broad-parrot-2692

    06/05/2022, 12:59 AM
    Is there a good place I can go to learn more about good patterns and practices when working with Pulumi in golang?
  • m

    most-airline-68480

    06/06/2022, 9:24 PM
    Help with AWS IAM policies. Hi everyone! I’m a bit stuck with IAM policy creation using pulumi AWS. The policy document as described here should be a string, however, if you want to restrict it to a specific resource you created before you need to convert resource ARN to a string. I looked into the examples in the doc but they are not very helpful with that. What are the options here to pass the resource ARN you created to a policy document (or in other words convert
    pulumi.StringOutput
    to
    string
    )?
    f
    • 2
    • 6
  • b

    broad-parrot-2692

    06/11/2022, 5:02 AM
    https://www.pulumi.com/registry/packages/gcp/api-docs/provider/ how do I use the
    google-beta
    provider? The syntax in the documentation seems off from what I actually need. EDIT: The documentation here helped me get the correct syntax down. https://www.pulumi.com/docs/intro/concepts/resources/providers/ Anyone know where I can report this documentation discrepancy?
    g
    • 2
    • 1
  • m

    mammoth-planet-78700

    06/14/2022, 9:18 PM
    regarding the aws-native library; is there a generic tags interface? It looks like with AWS classic you can feed a
    pulumi.Map{}
    for tags, but with native each resource has its own type
    b
    • 2
    • 1
  • j

    jolly-church-88521

    06/16/2022, 3:10 PM
    Hi, I’m a bit lost with the RouteTable function. I’m trying to create a RouteTable and I’m getting
    ""
    as a CidrBlock. Not sure why. This is my code:
    routeTable, err := ec2.NewRouteTable(ctx, n.genUniqName("route-private", i), &ec2.RouteTableArgs{
    			VpcId: n.VPC.ID(),
    			Routes: ec2.RouteTableRouteArray{
    				&ec2.RouteTableRouteArgs{
    					CidrBlock: subnet.CidrBlock
    and
    subnet.CidrBlock
    is from
    []*ec2.Subnet
    . When I’m doing
    fmt.Println()
    on it, I see
    {0xc0003c93b0}
    .
    b
    g
    • 3
    • 7
  • c

    cold-orange-37453

    06/17/2022, 5:58 AM
    Just starting out with pulumi, In the automation api, the engine events have a field PropertyDiff, here InputDiff is defined as
    InputDiff is true if this is a difference between old and new inputs rather than old state and new inputs.
    , am I correct to understand that whenever there is some external change made to a resource, for example a tag is changed for AWS sqs, the InputDiff for that change will be False, whereas if I change the tag for AWS SQS in pulumi code, then InputDiff will be True ? I am writing pulumi code in golang. Currently for both of these cases I am seeing InputDiff as False
Powered by Linen
Title
c

cold-orange-37453

06/17/2022, 5:58 AM
Just starting out with pulumi, In the automation api, the engine events have a field PropertyDiff, here InputDiff is defined as
InputDiff is true if this is a difference between old and new inputs rather than old state and new inputs.
, am I correct to understand that whenever there is some external change made to a resource, for example a tag is changed for AWS sqs, the InputDiff for that change will be False, whereas if I change the tag for AWS SQS in pulumi code, then InputDiff will be True ? I am writing pulumi code in golang. Currently for both of these cases I am seeing InputDiff as False
View count: 3