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

    magnificent-restaurant-97310

    06/17/2022, 6:23 AM
    Hi, I’m having trouble with creating organization policies in GCP with golang (I am new to Go and trying to learn by doing 😅 ) Here’s what I’m trying:
    pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := orgpolicy.NewPolicy(ctx, "primary", &orgpolicy.PolicyArgs{
    			Parent: pulumi.String(org),
    			Name:   pulumi.String("gcp.resourceLocations"),
    			Spec: &orgpolicy.PolicySpecArgs{
    				Rules: orgpolicy.PolicySpecRuleArray{
    					&orgpolicy.PolicySpecRuleArgs{
    						Enforce: pulumi.String("TRUE"),
    						Values: orgpolicy.PolicySpecRuleValues{
    							AllowedValues: []string{"region1", "region2"},
    						},
    					},
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    but I’m getting an error :
    cannot use orgpolicy.PolicySpecRuleValues{...} (type orgpolicy.PolicySpecRuleValues) as type orgpolicy.PolicySpecRuleValuesPtrInput in field value:
            orgpolicy.PolicySpecRuleValues does not implement orgpolicy.PolicySpecRuleValuesPtrInput (missing ElementType method)
    anyone experienced this?
  • j

    jolly-church-88521

    06/17/2022, 7:57 AM
    Any idea what might be wrong and where I should look? 😐
    Diagnostics:
      pulumi:pulumi:Stack (foo.de-dev):
        fatal error: sync: Unlock of unlocked RWMutex
    • 1
    • 5
  • f

    fancy-spoon-7206

    06/17/2022, 4:01 PM
    Is there a way to convert
    pulumi.StringOutput
    to
    string
    ? Its becoming weirdly difficult for me to get the tags right with all the custom types that don't seem to have a straight forward way to convert to string. The below does not work as
    natgw
    is a string and
    publicSubnets[0].AvailabilityZone
    is a StringOutput
    natGatewayName := "natgw" + publicSubnets[0].AvailabilityZone
    b
    • 2
    • 5
  • f

    fancy-spoon-7206

    06/20/2022, 10:16 PM
    I am getting the below error with awsx using golang:
    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`
    I try installing the said plugin and the URL seems to be busted
    ➜ vpcx pulumi plugin install resource awsx v1.0.0-testplsignore.0 
    [resource plugin awsx-1.0.0-testplsignore.0] installing
    error: [resource plugin awsx-1.0.0-testplsignore.0] downloading from : 403 HTTP error fetching plugin from <https://get.pulumi.com/releases/plugins/pulumi-resource-awsx-v1.0.0-testplsignore.0-darwin-amd64.tar.gz>
    b
    • 2
    • 3
  • f

    fancy-spoon-7206

    06/20/2022, 10:17 PM
    Has anyone tried using awsx successfully using golang?
  • f

    fancy-spoon-7206

    06/20/2022, 10:17 PM
    Also, Is
    v1.0.0-testplsignore.0
    is a valid version?
  • m

    magnificent-helicopter-3467

    06/21/2022, 6:45 PM
    Hi folks, cross-posting this here
    • 1
    • 1
  • f

    fancy-spoon-7206

    06/22/2022, 12:04 AM
    Is there a way to tags resources more aptly when using awsx? I have the below starter code, but I only see a way to set tags at the VPC level and not for the other components that the vpcx module creates.
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		cidr := "192.168.0.0/16"
    		vpcName := "dna"
    		_, err := ec2x.NewVpc(ctx, vpcName, &ec2x.VpcArgs{
    			CidrBlock: &cidr,
    			Tags:      pulumi.ToStringMap(namedTags(ctx, vpcName)),
    		})
    		if err != nil {
    			log.Fatalln(err)
    		}
    		return nil
    	})
    }
    This code does what is needed but the names are like
    <vpc-name>-private-1
    for a subnet for example.
    b
    • 2
    • 9
  • m

    magnificent-helicopter-3467

    06/22/2022, 10:38 PM
    Hello all, I’m trying to create a service account (GCP) and attach an IAM policy to it. Considering the following snippet:
    sa, err := serviceaccount.NewAccount(ctx, s.Name, &serviceaccount.AccountArgs{
    			AccountId:   pulumi.String(s.Id),
    			DisplayName: pulumi.String("A service account for my app"),
    		})
    		if err != nil {
    			return err
    		}
    
    		fmt.Println("Service account email: ", sa.Email)
    		storageAdmin, err := organizations.LookupIAMPolicy(ctx, &organizations.LookupIAMPolicyArgs{
    			Bindings: []organizations.GetIAMPolicyBinding{
    				organizations.GetIAMPolicyBinding{
    					Role: "roles/compute.storageAdmin",
    					Members: []string{
    						sa.Email,
    					},
    				},
    			},
    		}, nil)
    2 questions here: • Can I rely on using
    sa.Email
    after calling
    serviceaccount.NewAccount
    ? Or does that run asynchronously and populate
    sa
    with promise-like values? • If I can use
    sa.Email
    where I have it, how do I convert this
    pulumi.StringOutput
    to
    String
    ?
  • b

    billowy-army-68599

    06/22/2022, 10:47 PM
    Can I rely on using sa.Email after calling serviceaccount.NewAccount? Or does that run asynchronously and populate sa with promise-like values?
    Yes, passing an output from one resource as an input to another resource creates a dependency between them implicitly
    If I can use sa.Email where I have it, how do I convert this pulumi.StringOutput to String?
    You cannot convert a
    pulumi.StringOutput
    to a
    String
    - you need to resolve the value using
    ApplyT
    and then use the string. See https://leebriggs.co.uk/blog/2021/05/09/pulumi-apply for more information
    🙏 1
  • f

    fancy-spoon-7206

    06/25/2022, 4:28 AM
    I am getting the below error after adding a simple integration test from the docs:
    func TestVpc(t *testing.T) {
    	awsRegion := "us-east-1"
    	cwd, _ := os.Getwd()
    
    	integration.ProgramTest(t, &integration.ProgramTestOptions{
    		Quick:       true,
    		SkipRefresh: true,
    		Dir:         path.Join(cwd, "..", "..", "aep-base-infra"),
    		Config: map[string]string{
    			"aws:region": awsRegion,
    		},
    	})
    }
    Error:
    ➜ resources (main) ✗ go test ./...
    panic: proto: duplicate enum registered: pulumirpc.EnforcementLevel
    
    goroutine 1 [running]:
    <http://github.com/golang/protobuf/proto.RegisterEnum({0x101cb7b88|github.com/golang/protobuf/proto.RegisterEnum({0x101cb7b88>, 0x1a}, 0x14000359a10?, 0x140003599e0?)
    	/Users/dinesh.auti/go/pkg/mod/github.com/golang/protobuf@v1.4.3/proto/registry.go:104 +0xb8
    <http://github.com/pulumi/pulumi/sdk/v2/proto/go.init.0()|github.com/pulumi/pulumi/sdk/v2/proto/go.init.0()>
    	/Users/dinesh.auti/go/pkg/mod/github.com/pulumi/pulumi/sdk/v2@v2.25.2/proto/go/analyzer.pb.go:963 +0x44
    exit status 2
    FAIL	<http://github.com/aetion/aep-base-infra/internal/resources|github.com/aetion/aep-base-infra/internal/resources>	0.393s
    Has anyone seen this before? I am using Pulumi version 3.35.1
    l
    • 2
    • 2
  • f

    fancy-spoon-7206

    07/04/2022, 9:24 PM
    What is the recommended way to ingest config for tests? I see that most of the examples online and in the official docs are hardcoded like below.
    func TestInfrastructure(t *testing.T) {
    	cwd, err := os.Getwd()
    	if err != nil {
    		t.FailNow()
    	}
        
        //  This gives an invalid memory address error!!!! 
        //	conf := config.New(ctx, "aep")
    	//  conf.RequireObject("config", &InternalConfig)
    
    	test := integration.ProgramTestOptions{
    		DestroyOnCleanup: true,
    		Quick:            true,
    		SkipRefresh:      true,
    		Verbose:          true,
    		Dir:              path.Join(cwd, "..", ".."),
    		// There seems to an issue with ingesting config from the stack yaml file using
    		// the Pulumi helper.ConfInit function. All the examples that I see on their site are hardcoded too.
    		Config: map[string]string{
    			"aws:region":  "us-east-1",
    			"aws:profile": "sandbox",
    .
    .
    .
    I tried using the RequireObject method to get the config from the stack yaml file and it failed with an
    invalid memory address or nil pointer dereference
    .
  • f

    fancy-spoon-7206

    07/04/2022, 9:27 PM
    === RUN   TestInfrastructure
    --- FAIL: TestInfrastructure (0.00s)
    panic: runtime error: invalid memory address or nil pointer dereference [recovered]
            panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x2 addr=0x30 pc=0x104ec8580]
  • p

    prehistoric-sandwich-7272

    07/10/2022, 1:04 PM
    Hey Guys, I have an issue with Pulumi on Golang. I am trying to create a new EKS Cluster, and pass the
    clusterArgs
    the subnet ID’s of the VPC I have created in a different stack. I am getting the output from the stack reference like this:
    stack, err := pulumi.NewStackReference(ctx, Name, nil)
    if err != nil {
       log.Fatalf("Got error while trying to get a new stack reference! Error: %s", err)
    }
    VpcPublicSubnetIdsOutput := stack.GetStringOutput(pulumi.String("vpcPublicSubnetIds"))
    vpcPrivateSubnetIdsOutput := stack.GetStringOutput(pulumi.String("vpcPrivateSubnetIds"))
    
    VpcPublicSubnetIds := pulumi.ToStringArrayOutput([]pulumi.StringOutput{VpcPublicSubnetIdsOutput})
    vpcPrivateSubnetIds := pulumi.ToStringArrayOutput([]pulumi.StringOutput{vpcPrivateSubnetIdsOutput})
    So VpcPublicSubnetIds & vpcPrivateSubnetIds are both of type
    pulumi.StringArrayOutput
    But I can’t figure out how to pass the subnet ID’s to the clusterArgs, by indexing the elements from VpcPublicSubnetIds & vpcPrivateSubnetIds ! I tried doing it like this:
    eksCluster, err := eks.NewCluster(ctx, values.Name, &eks.ClusterArgs{
       Name:  pulumi.StringPtr(values.Name),
       VpcId: vpcId,
       PublicSubnetIds: pulumi.StringArray{
          pulumi.StringInput(VpcPublicSubnetIds.Index(<http://pulumi.Int|pulumi.Int>(0))),
          pulumi.StringInput(VpcPublicSubnetIds.Index(<http://pulumi.Int|pulumi.Int>(1))),
          pulumi.StringInput(VpcPublicSubnetIds.Index(<http://pulumi.Int|pulumi.Int>(2))),
          pulumi.StringInput(VpcPublicSubnetIds.Index(<http://pulumi.Int|pulumi.Int>(3))),
       },
       PrivateSubnetIds: pulumi.StringArray{
          pulumi.StringInput(vpcPrivateSubnetIds.Index(<http://pulumi.Int|pulumi.Int>(0))),
          pulumi.StringInput(vpcPrivateSubnetIds.Index(<http://pulumi.Int|pulumi.Int>(1))),
          pulumi.StringInput(vpcPrivateSubnetIds.Index(<http://pulumi.Int|pulumi.Int>(2))),
          pulumi.StringInput(vpcPrivateSubnetIds.Index(<http://pulumi.Int|pulumi.Int>(3))),
       },
    what am I doing wrong?
    b
    • 2
    • 15
  • b

    billowy-nightfall-59212

    07/11/2022, 9:37 PM
    Hi, I am trying to get string array output for TargetTags for the
    gcp firewall
    from
    gcp nodepool
    _, err = compute.NewFirewall(ctx, "prometheus-k8s-firewall", &compute.FirewallArgs{
    			Allows: compute.FirewallAllowArray{
    				&compute.FirewallAllowArgs{
    					Ports: pulumi.StringArray{
    						pulumi.String("8443"),
    					},
    					Protocol: pulumi.String("tcp"),
    				},
    			},
    			Direction: pulumi.String("INGRESS"),
    			Name:      pulumi.String("prometheus-k8s-firewall"),
    			Network:   network.SelfLink,
    			Project:   pulumi.String(c.Project),
    			SourceRanges: pulumi.StringArray{
    				pulumi.String(c.Cluster.MasterCIDR),
    			},
    			TargetTags: pool.NodeConfig.Tags().ToStringArrayOutput(),
    		}, pulumi.Protect(true))
    • 1
    • 2
  • d

    damp-ocean-83573

    07/12/2022, 9:19 PM
    Hey! Just joined Slack, having an issue with creating an internal load balancer on GKE, wondered if any of y’all could help? Using type
    LoadBalancer
    along with the annotation
    <http://networking.gke.io/load-balancer-type|networking.gke.io/load-balancer-type>: Internal
    , seems like Pulumi isn’t populating the ingress IP correctly, i.e.
    status.LoadBalancer.Ingress
    has length of 0. Anyone run into this problem before? Can’t seem to find anything online about it.
  • r

    ripe-shampoo-80285

    07/14/2022, 1:26 AM
    I am trying to upgrade to the latest go pulumi-eks module: Why am I get this error? module github.com/pulumi/pulumi-eks/sdk@upgrade found (v0.41.0), but does not contain package github.com/pulumi/pulumi-eks/sdk/go
  • f

    fancy-spoon-7206

    07/18/2022, 4:07 PM
    Is there a simple way to export a slice of a struct?
    type subnet struct {
    		Id pulumi.StringOutput
    		Az string
    	}
    
    	publicSubnet := make([]subnet, 0, 1)
    	for index, az := range azs {
    		publicSubnet = append(publicSubnet, subnet{
    			Id: PublicSubnets.Index(<http://pulumi.Int|pulumi.Int>(index)),
    			Az: az,
    		})
    	}
    I would like to export publicSubnet, but that is not valid.
  • f

    fancy-spoon-7206

    07/18/2022, 4:07 PM
  • f

    fancy-spoon-7206

    07/18/2022, 4:09 PM
    The idea is to get an Outputs similar to
    {
      "publicSubnets": [
        {
          "id": "subnet-02d7930bd",
          "az": "us-east-2a"
        },
        {
          "id": "subnet-0a89e59bb",
          "az": "us-east-2b"
        },
        {
          "id": "subnet-04658194f",
          "az": "us-east-2c"
        }
      ],
      "privateSubnets": [
        {
          "id": "subnet-00a9f3a9d6",
          "az": "us-east-2a"
        },
        {
          "id": "subnet-026eed9351,
          "az": "us-east-2b"
        },
        {
          "id": "subnet-0bfabcc5f666637c1",
          "az": "us-east-2c"
        }
      ]
    }
  • b

    bland-florist-27487

    07/19/2022, 12:35 PM
    Hi! Are there any decision documents I can refer to when trying to understand why Pulumi defines its own string- and array-types?
    b
    • 2
    • 5
  • b

    bumpy-byte-21437

    07/21/2022, 12:19 PM
    hi i am fairly new to pulumi and go.. in the below code i’m using resource components. Somebody knows how to produce outputs.
  • b

    bumpy-byte-21437

    07/21/2022, 12:19 PM
    package aks
    
    import (
      "fmt"
    
      "<http://github.com/pulumi/pulumi-azure-native/sdk/go/azure/containerservice|github.com/pulumi/pulumi-azure-native/sdk/go/azure/containerservice>"
      "<http://github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core|github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core>"
      "<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi>"
    )
    
    type Aks struct {
      pulumi.ResourceState
      resourceId pulumi.StringOutput
      name       pulumi.StringOutput
    }
    
    type AksArgs struct {
      EnableRBAC        pulumi.BoolInput
      ResourceName      pulumi.StringInput
      KubernetesVersion pulumi.StringInput
      NodeResourceGroup pulumi.StringInput
      ResourceGroup     pulumi.StringInput
      NodeCount         pulumi.IntInput
      Location          pulumi.StringInput
    }
    
    func CreateAks(ctx *pulumi.Context, name string, args *AksArgs, opts ...pulumi.ResourceOption) (*Aks, error) {
      aks := &Aks{}
    
      err := ctx.RegisterComponentResource("resource:index:Aks", name, aks, opts...)
      if err != nil {
        return nil, err
      }
    
      rgs, err := core.NewResourceGroup(ctx, "resourceGroups", &core.ResourceGroupArgs{
        Name:     args.ResourceGroup,
        Location: args.Location,
      }, pulumi.Parent(aks))
    
      if err != nil {
        return nil, fmt.Errorf("error creating resource group: %v", err)
      }
    
      k8s, err := containerservice.NewManagedCluster(ctx, "akss", &containerservice.ManagedClusterArgs{
        Location: rgs.Location,
        AgentPoolProfiles: containerservice.ManagedClusterAgentPoolProfileArray{
          &containerservice.ManagedClusterAgentPoolProfileArgs{
            Count:              args.NodeCount,
            EnableAutoScaling:  pulumi.Bool(false),
            EnableNodePublicIP: pulumi.Bool(true),
            Mode:               pulumi.String("System"),
            Name:               pulumi.String("default"),
            OsType:             pulumi.String("Linux"),
            Type:               pulumi.String("VirtualMachineScaleSets"),
            VmSize:             pulumi.String("Standard_B2s"),
          },
        },
        DnsPrefix:         pulumi.String("akss"),
        EnableRBAC:        args.EnableRBAC,
        Identity:          &containerservice.ManagedClusterIdentityArgs{Type: containerservice.ResourceIdentityTypeSystemAssigned},
        KubernetesVersion: args.KubernetesVersion,
        NodeResourceGroup: args.NodeResourceGroup,
        ResourceGroupName: rgs.Name,
        ResourceName:      args.ResourceName,
        Sku: &containerservice.ManagedClusterSKUArgs{
          Name: pulumi.String("Basic"),
          Tier: pulumi.String("Free"),
        },
      }, pulumi.Parent(rgs))
    
      if err != nil {
        return nil, fmt.Errorf("error creating cluster: %v", err)
      }
    
      ctx.RegisterResourceOutputs(aks, pulumi.Map{
        "resourceId": k8s.ID(),
        "name":       k8s.Name,
      })
      return aks, nil
    }
    q
    b
    • 3
    • 44
  • b

    busy-island-31180

    07/21/2022, 11:05 PM
    does anyone have some good examples for testing in Pulumi, maybe just some basic stuff, like property value assertions using mocks
  • b

    busy-island-31180

    07/21/2022, 11:06 PM
    I find the examples in the documentation to be too simple
  • d

    dry-engine-17210

    07/22/2022, 12:15 AM
    Breaking my brain on this...
  • b

    busy-island-31180

    07/22/2022, 1:08 AM
    I’m also a bit confused about how to use ApplyT and All on types such as:
    type ManagedFieldsEntryArrayOutput struct{ *pulumi.OutputState }
    such as in
    go/kubernetes/meta/v1/pulumiTypes.go
  • b

    busy-island-31180

    07/22/2022, 1:08 AM
    any help would be appreciated
  • g

    gorgeous-accountant-60580

    07/22/2022, 9:19 PM
    Hello! I'm looking at writing integration tests for a component resource. We use bazel, so to set up the test run I have to inject all the tools needed. The way it seems to be done using integration.ProgramTest() that also includes Go itself, which feels a bit awkward. Is it possible to run a precompiled Go program? Am I better off using e.g. the Automation API for testing?
  • b

    bland-florist-27487

    07/25/2022, 5:52 PM
    Should we expect AWS Crosswalk for the go client down the line?
    f
    • 2
    • 3
Powered by Linen
Title
b

bland-florist-27487

07/25/2022, 5:52 PM
Should we expect AWS Crosswalk for the go client down the line?
f

fancy-spoon-7206

07/25/2022, 5:54 PM
There is already a go way for awsx, if thats what you are asking.
b

bland-florist-27487

07/25/2022, 5:55 PM
oh nice, must have missed it
Browsing the library now, thanks for the quick correction 🙂
😄 1
View count: 5