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

    limited-rainbow-51650

    11/14/2022, 6:23 AM
    If you are using our Azure Native provider with the Go SDK, please read the Go SDK deprecation and migration discussion on Github. Please provide any feedback you might have! 🙏🏼
  • s

    some-cartoon-66940

    11/14/2022, 7:43 PM
    Hi, Is there some ETA on the Example Usage sections in the documentation?
  • s

    some-cartoon-66940

    11/14/2022, 7:44 PM
    It went from barely usable to non-existent (on top of all the other problems with pulumi and go).
    b
    • 2
    • 4
  • a

    aloof-tiger-61862

    11/15/2022, 1:29 PM
    When calling New{resource} and this resource present, will it act as Get{resource}?
    f
    • 2
    • 1
  • j

    jolly-church-88521

    11/15/2022, 4:51 PM
    I’m getting a list of namespaces for my EKS cluster and for each I’m calling:
    namespace, err := corev1.NewNamespace(ctx, name, ...)
    	if err != nil {
    		return nil, nil
    	}
    to create them. But there are some exceptions, like
    kube-system
    , which is already in EKS. Pulumi is failing with:
    namespaces "kube-system" already exists
    because obviously this namespace is already there. I tried to catch error message like
    if err.Error() == "…"
    or/and
    return nil, nil
    . But it’s still the same error message. Is there any way to workaround this?
    f
    • 2
    • 1
  • s

    some-cartoon-66940

    11/17/2022, 10:17 AM
    I already asked but let's try again. I am trying to create an Azure Application Gateway and I am looking for a way to avoid using hard coded values for the HttpListeners. From the Application Gateway docs (the link is from the Wayback Machine, since they are unavailable currently on the pulumi page): https://web.archive.org/web/20220526083650/https://www.pulumi.com/registry/packages/azure-native/api-docs/network/applicationgateway/ HttpListeners: []network.ApplicationGatewayHttpListenerArgs{ &network.ApplicationGatewayHttpListenerArgs{ FrontendIPConfiguration: &network.SubResourceArgs{ Id: pulumi.String("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/applicationGateways/appgw/frontendIPConfigurations/appgwfip"), }, FrontendIPConfiguration is configured before HttpListeners in the example - is there someway to plug that instead of using hardcoded Id of FrontendIPConfiguration?
  • s

    some-cartoon-66940

    11/17/2022, 10:34 AM
    Second question - I am trying to create the PostgreSQL flexible server on Azure. Using the example given, I get the following error: dbforpostgresql.ServerPropertiesForDefaultCreate{} (type dbforpostgresql.ServerPropertiesForDefaultCreate) as type pulumi.Input in field value: dbforpostgresql.ServerPropertiesForDefaultCreate does not implement pulumi.Input (missing ElementType method) Looking up this error I stumbled upon these issues (which are from February and onward and still opened): https://github.com/pulumi/pulumi-azure-native/issues/1553 https://github.com/pulumi/pulumi/issues/8918 https://github.com/pulumi/pulumi-azure-native/issues/1578 Was there any progress on this? Or am I supposed to use the Azure classic?
  • g

    great-mouse-52242

    11/22/2022, 5:25 PM
    Hi all. Are there any good examples of production stacks out there? We're looking for some non-trivial examples to read through, especially around combining multiple providers, organization of code, stacks, etc.
  • s

    some-cartoon-66940

    11/24/2022, 5:14 PM
    Since I have exhausted every other avenue of inquiry, let's try this channel. All of the gory details - https://github.com/pulumi/pulumi-azure-native/issues/2091. Any help is appreciated.
  • b

    brash-gigabyte-81569

    12/01/2022, 3:15 PM
    In the latest release of pulumi-eks a bunch of the properties were changed to plain. Since I am passing in a SecurityGroupOutput how do I go about converting that to a SecurityGroup so that I can now pass it in plainly?
  • l

    little-soccer-5693

    12/01/2022, 5:02 PM
    I notice auto.OutputValue.Value's type is interface{} rather than string: https://github.com/pulumi/pulumi/blob/master/sdk/go/auto/stack.go#L769-L773 however the documentation comment says it provides "plaintext value". why isn't Value's type string?
  • b

    bored-spoon-83710

    12/02/2022, 6:11 PM
    Hello! I’ve upgraded the dependencies of my project and running
    pulumi up
    after that, I got the following error:
    # <http://github.com/pjbgf/sha1cd/cgo|github.com/pjbgf/sha1cd/cgo>
        vendor/github.com/pjbgf/sha1cd/cgo/sha1.go:3:11: fatal error: lib/sha1.h: No such file or directory
            3 | // #include <lib/sha1.h>
              |           ^~~~~~~~~~~~
        compilation terminated.
    
        error: error in compiling Go: unable to run `go build`: exit status 2
    The concerned package is an indirect dependency of the Go Pulumi SDK:
    ❯ go mod why <http://github.com/pjbgf/sha1cd/cgo|github.com/pjbgf/sha1cd/cgo>
    # <http://github.com/pjbgf/sha1cd/cgo|github.com/pjbgf/sha1cd/cgo>
    <my-pulumi-go-project>
    <http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi>
    <http://github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin|github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin>
    <http://github.com/pulumi/pulumi/sdk/v3/go/common/workspace|github.com/pulumi/pulumi/sdk/v3/go/common/workspace>
    <http://github.com/go-git/go-git/v5/plumbing|github.com/go-git/go-git/v5/plumbing>
    <http://github.com/go-git/go-git/v5/plumbing/hash|github.com/go-git/go-git/v5/plumbing/hash>
    <http://github.com/pjbgf/sha1cd/cgo|github.com/pjbgf/sha1cd/cgo>
    I did some search and I came across this pull request which should have solved the problem: https://github.com/pjbgf/sha1cd/pull/5. However, this is not the case because Pulumi doesn’t seem to build Go programs using
    CGO_ENABLED=0
    . What’s the reason why
    CGO_ENABLED=0
    is not used?
    m
    • 2
    • 5
  • b

    bored-spoon-83710

    12/04/2022, 10:25 AM
    Hello, when a
    pulumi.<Type>PtrIntput
    is expected, one can pass a
    pulumi.<Type>
    without error most of the time and I’d like to know if this is an intended and supported behaviour? Indeed, I use it a lot, but it recently broke here: https://github.com/pulumi/pulumi-aws/blob/c984ddfba812c33e5ebf7267cdf9c1498174f3d4/sdk/go/aws/rds/instance.go#L362.
  • g

    gifted-fall-44000

    12/04/2022, 11:11 PM
    đź‘‹ Attempting to run integration tests with project level configuration. I'm running into errors when doing so. I believe that it's failing to properly unmarshal the config from the Pulumi.yaml when attempting to run.
    b
    • 2
    • 1
  • t

    thousands-train-46386

    12/06/2022, 3:29 PM
    I’m attempting to create an AWS IAM policy and provide the resulting ARN to a Role. Using Go + Pulumi it seems I must write custom code to take the Pulumi output value from one resource so it can be provided as an input to another resource which expects Go native types. The same scenario seems to exist for values I extract with the
    ApplyT
    method on previously created resources. Am I headed in the right direction or is there a simpler way?
    l
    f
    • 3
    • 6
  • t

    thousands-train-46386

    12/08/2022, 12:10 PM
    Looking for some more guidance on inputs to a resource 🙂 . I’m wanting to create an AWS IAM policy using the
    iam.GetPolicyDocument
    resource. In the policy statement, I need to provide a federated principle with an identifier value of an ARN provided by resource created earlier in the stack:
    myPolicy, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
    	Statements: []iam.GetPolicyDocumentStatement{
    		{
    			Sid:    pulumi.StringRef(""),
    			Effect: pulumi.StringRef("Allow"),
    			Principals: []iam.GetPolicyDocumentStatementPrincipal{
    				{
    					Type:        "Federated",
    					Identifiers: <ARN>, // <----- this input
    				},
    			},
    .......
    })
    The field
    Identifiers
    takes in a slice of strings but I’m needing to provide an ARN value which is not known until earlier stack resources are created and presented in type
    pulumi.StringOutput
    . Is this possible?
    l
    f
    • 3
    • 7
  • g

    gifted-fall-44000

    12/11/2022, 10:35 PM
    Would it be a fair assessment that unit testing would be far easier in Typescript compared to golang. Seeing quite the disparity specifically within testing. I want to use TDD to develop all our Infrastructure, but continually running into roadblocks where I feel like I am writing a vast majority of the mocking boilerplate to get things accomplished.
    c
    • 2
    • 1
  • q

    quaint-salesclerk-22166

    12/12/2022, 11:37 AM
    Hey! I am using the inline program way to create resources in a golang cli. I dont know why every time I want to create 2 snowflake databases the following happens: DB number 1 is created, then number 1 is deleted and finally DB number 2 is created...
    m
    • 2
    • 5
  • g

    gifted-fall-44000

    12/12/2022, 5:53 PM
    Anyone have a nice pattern to apply Tags to the AWS Native Resources which now have custom specific Tag Array Type?
    &ec2.SubnetArgs{
    			AvailabilityZone: pulumi.String(azResult.Azs[i]),
    			CidrBlock:        cidr,
    			VpcId:            infra.Vpc.ID(),
    			Tags: &ec2.SubnetTagArray{},
    		}
    m
    • 2
    • 2
  • f

    flaky-school-70251

    12/12/2022, 8:59 PM
    Hi all, I've got a
    pulumi.StringInput
    that I need to convert into a regular golang
    string
    so I can
    fmt.Printf
    it, can anyone help me out?
    g
    f
    • 3
    • 73
  • q

    quaint-salesclerk-22166

    12/13/2022, 1:30 PM
    Is it possible to set Pulumi to perform async stack updates? I am creating Azure Managed Instances, which takes more than 4 hours. I would like to just run
    res, err = globalStack.Up(globalCtx, stdoutStreamer)
    and let Pulumi service run independently. Now it runs for a while but then it fails since the golang cli from where I am running stack updates is no longer running.
    m
    e
    • 3
    • 27
  • g

    gifted-fall-44000

    12/14/2022, 9:21 PM
    Anyone have any idea how to pass the correct JSON to the Paramters key for this resource. Have tried a formatted json string, marshaled JSON, etc. Doesn't seem to create properly and AWS throws back an error that it expects a JSONObject.
  • f

    flaky-arm-38472

    12/20/2022, 9:15 AM
    How can I compose a tag key from an output?. I tried:
    Tags: pulumi.StringMap{
    					string(exampleResource.ApplyT(func(tagKey string) string {
    						return "chained-name-" + tagKey
    					}).(pulumi.StringOutput))[:]:                    pulumi.String("test"),
    }
    b
    • 2
    • 4
  • b

    busy-room-61756

    12/20/2022, 3:24 PM
    Hi - can I create a provider that contains components made up from resources in the same provider? The closest I've found so far is this example from pulumi-go-provider, but the components are actually using resources from
    pulumi-random
    . For now I plan to create two separate providers for my resources and components, but I'm fairly sure I've just missed something obvious and it's easy for them to co-exist. Any pointers gratefully received.
    b
    a
    • 3
    • 7
  • b

    billions-accountant-89861

    12/26/2022, 7:18 AM
    i want to use pulumi with vultr, how to do that ?
    m
    • 2
    • 3
  • r

    refined-pilot-45584

    12/27/2022, 9:57 AM
    Hey All, Is there an easy way to Append a pulumi.String(“Hello”) object to a Pulumi.StringArray object. I am trying implement something like this…
    var denyPorts pulumi.StringArray
    for _, denyPort := range local.DenyPorts {
    	append(denyPorts, pulumi.String(denyPort))
    }
    I basically receive the following error:
    append(denyPorts, pulumi.String(denyPort)) (value of type pulumi.StringArray) is not used
    I assume there must be a way to combine pulumi.String and pulumi.StringArray If not what would be the suggested approach? Is there a different way to convert a []string object in go to pulumi.StringArray? Thanks in advance.
    s
    e
    w
    • 4
    • 14
  • r

    refined-pilot-45584

    12/27/2022, 10:04 AM
    Also in addition I am curious about this… Still struggling with a couple of the Pulumi Types… I am also trying to build out a whole firewall structure using a series of conditions this requires me to construct firewall objects in isolation and then feed them back into the primary arguments of the create statement… I am trying to work around this error:
    cannot use fwDenyArray (variable of type *compute.FirewallDenyArgs) as type compute.FirewallDenyArrayInput in struct literal:
            *compute.FirewallDenyArgs does not implement compute.FirewallDenyArrayInput (missing ToFirewallDenyArrayOutput method)
    How I am trying to achieve this is as follows:
    firewallArgs := &compute.FirewallArgs{
    					Network:     gcpVPC.SelfLink,
    					Allows:      fwAllowArray,
    }
    Where fwAllowArray is defined as :
    fwAllowArray := &compute.FirewallAllowArgs{}
    for _, allowArgument := range firewallRule.Allow {
    	fwAllowArgs := &compute.FirewallAllowArgs{}
        fwAllowArgs.Protocol = pulumi.String(allowArgument.Protocol)
     	var allowPorts pulumi.StringArray
    	for _, allowPort := range allowArgument.Ports {
    		append(allowPorts, pulumi.String(allowPort))
    	}
    	fwAllowArgs.Ports = allowPorts
    }
    I would appreciate any feedback. I would really like to resolve these two issues but simultaneously understand where any I have gone wrong… I am not quite sure whats happening under the hood between the types and maybe I am just abusing a process I am not aware of. Thanks.
  • a

    adventurous-apartment-93389

    12/30/2022, 10:49 AM
    I'm just following on from Tim Jones post about converting StringOutputs to regular strings.... Use Case: I want to create reusable code in the form of golang packages BUT I need to parameterise the URN and pad it with data such as the project Id e.g. I want to create x3 GCP Projects and each has a VPC all called VPC-1 I get a name clash in the URN, I can
    fmt.Sprintf("%s-%s", projectID, args.Name)
    but I need to get the projectId from the output of a previous run that creates the project Id (which is a pulumi.StringOutput). I've tried everything with the ApplyT but it doesn't seem to work.... These pulumi types are killing me here, any ideas? my programme:
    var project project.Project
             var vpc  vpc.Vpc
     
             pulumi.Run(func(ctx *pulumi.Context) error {
                     project.Args.Name = "b1-services"
                     project.Args.FolderId = "folders/415061719873"
                     project.Args.BillingAccount = "01504C-A2522F-2110FA"
                     project.Args.AutoCreateNetwork = false
     
                     project.Args.Services = []string{"<http://compute.googleapis.com|compute.googleapis.com>", "<http://container.googleapis.com|container.googleapis.com>"}
     
                     prj, err := project.Create(ctx)
                     if err != nil {
                             log.Println(err)
                     }
     
                     vpc.Args.Name = "vpc-1"
                     vpc.Args.ProjectId = prj.ProjectId
                     //vpc.Args.Project = pulumi.Sprintf("%s", prj.ProjectId)
     
     
                     vpcNetwork, err := vpc.Create(ctx)
                     if err != nil {
                             log.Println(err)
                     }
    my package:
    package vpc 
     
     import (
             "<http://github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/compute|github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/compute>"
             "<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi>"
             "fmt"
     )
     
     type VpcArgs struct {
             Name                        string
             Description                 string
             ProjectId                   pulumi.StringOutput
             RoutingMode                 string
             AutoCreateSubnetworks       bool
             DeleteDefaultRoutesOnCreate bool
             EnableUIaInternalIpv6       bool
             InternalIpv6Range           bool
     }
     
     type Vpc struct {
             Args VpcArgs
             Name string
     }
     
     func (vpc *Vpc) Create(ctx *pulumi.Context) (vpcNetwork *compute.Network, err error) {
             args := &compute.NetworkArgs{}
             args.Name = pulumi.String(vpc.Args.Name)
             args.Project = vpc.Args.ProjectId
             args.AutoCreateSubnetworks = pulumi.Bool(vpc.Args.AutoCreateSubnetworks)
     
             var projectId string
             vpc.Args.ProjectId.ApplyT(func(p string) error {
                     projectId = fmt.Sprintf("%s", p)
                     return nil
             })  
     
             fmt.Println(projectId)
     
             vpcNetwork, err = compute.NewNetwork(ctx, fmt.Sprintf("%s-%s",projectId,args.Name), args)
             ctx.Export("vpc", vpcNetwork)
             return vpcNetwork, err 
     }
    b
    • 2
    • 6
  • g

    gorgeous-architect-28903

    01/09/2023, 10:51 AM
    I would really like to set a value on the underlying
    context.Context
    of a
    pulumi.Context
    but I guess it isn’t possible unless I create my own
    pulumi.Context
    which would mean I have to more or less duplicate the code for setting up the
    pulumi.RunInfo
    from the environment. Anyone else run into this?
    e
    • 2
    • 4
  • g

    gorgeous-vegetable-57900

    01/09/2023, 8:03 PM
    I'm struggling to use
    aws/secretsmanager
    to do a
    LookupSecret
    followed by a
    GetSecretVersion
    reference, _ := pulumi.NewStackReference(ctx, fmt.Sprintf("prefix/%v", stackName), nil)
    secretArn := reference.GetStringOutput(pulumi.String("SecretARN"))
    
    secret := secretArn.ApplyT(func(arn string) string {
      // I'm disappointed that I seem to have to do this within an Apply
      secret, _ := secretsmanager.LookupSecret(ctx,
        &secretsmanager.LookupSecretArgs{
          Arn: &arn,
        },
        nil,
      )
    
      // Error: cannot use secret.Id (variable of type string) as type pulumi.IDInput in argument to secretsmanager.GetSecretVersion
      secretVersion, _ := secretsmanager.GetSecretVersion(ctx, secret.Name, secret.Id, nil, nil)
    
      return secretVersion.SecretString
    })
    How can I convert
    secret.Id
    from a
    string
    to a
    pulumi.IDInput
    for use with
    GetSecretVersion
    ?
    d
    • 2
    • 3
Powered by Linen
Title
g

gorgeous-vegetable-57900

01/09/2023, 8:03 PM
I'm struggling to use
aws/secretsmanager
to do a
LookupSecret
followed by a
GetSecretVersion
reference, _ := pulumi.NewStackReference(ctx, fmt.Sprintf("prefix/%v", stackName), nil)
secretArn := reference.GetStringOutput(pulumi.String("SecretARN"))

secret := secretArn.ApplyT(func(arn string) string {
  // I'm disappointed that I seem to have to do this within an Apply
  secret, _ := secretsmanager.LookupSecret(ctx,
    &secretsmanager.LookupSecretArgs{
      Arn: &arn,
    },
    nil,
  )

  // Error: cannot use secret.Id (variable of type string) as type pulumi.IDInput in argument to secretsmanager.GetSecretVersion
  secretVersion, _ := secretsmanager.GetSecretVersion(ctx, secret.Name, secret.Id, nil, nil)

  return secretVersion.SecretString
})
How can I convert
secret.Id
from a
string
to a
pulumi.IDInput
for use with
GetSecretVersion
?
Looks like I should use
secretVersion, _ := secretsmanager.LookupSecretVersion(ctx, &secretsmanager.LookupSecretVersionArgs{
			SecretId: secret.Id,
		}, nil)
!
🦆
d

delightful-camera-97029

01/11/2023, 12:58 PM
I dont understand, have u tried to do it like this?
reference, _ := pulumi.NewStackReference(ctx, fmt.Sprintf("prefix/%v", stackName), nil)
secretArn := reference.GetStringOutput(pulumi.String("SecretARN"))

secret := secretArn.ApplyT(func(arn string) string {
  // I'm disappointed that I seem to have to do this within an Apply
  secret, _ := secretsmanager.LookupSecret(ctx,
    &secretsmanager.LookupSecretArgs{
      Arn: &arn,
    },
    nil,
  )

  // Error: cannot use secret.Id (variable of type string) as type pulumi.IDInput 
  // in argument to secretsmanager.GetSecretVersion
  secretVersion, _ := secretsmanager.GetSecretVersion(ctx, secret.Name, secret.Id, nil, nil)

  return secretVersion.SecretString
})
View count: 7