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

    lively-laptop-35163

    08/30/2022, 4:42 PM
    Hi All! New to Pulumi, great to meet the team! I had a couple of questions about the EKS / Kubernetes provider and state. We’re trying to create a library that abstracts away creating a EKS cluster with sane defaults explicit to our organizations. We’re getting state references from the stack we created that will be referenced (the library), how would you recommend managing state and kubernetes providers for this type of scenario? Thanks in advance!
  • p

    proud-machine-85126

    08/31/2022, 4:05 AM
    Say I have 200 ec2 instances I want to roll from A to B. Is there a way to limit the number in-flight ec2 instances that Pulumi will build/destroy at once? (Rate limiting the pulumi API isn't an option due to the number of calls needed to support the app.) Ideally what we want is for Pulumi to build 1, destroy 1, build 1, destroy 1 ... all night long.
    b
    • 2
    • 6
  • p

    prehistoric-sandwich-7272

    08/31/2022, 8:03 PM
    Hey guys! Any idea how can I add a statement to an existing S3 bucket policy permission? I have created a S3 bucket, and a folder inside it called ‘service1’ , created an OAI for the folder and cloudfront, and attached a bucket policy for containing the OAI & s3 folder. looks like this:
    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Sid": "my-bucket",
          "Effect": "Allow",
          "Action": "s3:GetObject",
          "Resource": [
            "arn:aws:s3:::my-bucket/*"
          ],
          "Principal": {
            "Oai": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity <ID>"
          }
        }
      ]
    }
    Now I have a second s3 folder, under the same bucket, for a second service, called ‘service2’. I created an OAI for the folder and cloudfront aswell, and I want to attach a new statement to the existing bucket policy. so something like this:
    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Sid": "my-bucket",
          "Effect": "Allow",
          "Action": "s3:GetObject",
          "Resource": [
            "arn:aws:s3:::my-bucket/*"
          ],
          "Principal": {
            "Oai": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity <123>"
          },
          {
          "Sid": "my-bucket",
          "Effect": "Allow",
          "Action": "s3:GetObject",
          "Resource": [
            "arn:aws:s3:::my-bucket/*"
          ],
          "Principal": {
            "Oai": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity <456>"
          }
        }
      ]
    }
    How can I achieve this?
    b
    • 2
    • 11
  • m

    most-mouse-38002

    09/01/2022, 4:49 PM
    Trying to ApplyT on a
    IDOutput
    I get
    panic: applier must have 1 input parameter assignable from pulumi.ID
    Code is as follows
    scope := x.ID().
    		ApplyT(func(data string) string {
    			return data + "providers/Microsoft.Network"
    		}).(pulumi.StringOutput)
  • r

    ripe-shampoo-80285

    09/01/2022, 8:30 PM
    I have a variable of type pulumi.Output. How can I cast it to pulumi.StringPtrOutput which is expected input type for a function?
    • 1
    • 1
  • s

    salmon-account-74572

    09/01/2022, 8:43 PM
    I have a working solution, but I’m not sure it’s the most efficient solution. I have a stack that creates a set of base AWS infrastructure (VPC, subnets, etc.). This base infra stack does export an array of subnet IDs:
    ctx.Export("privSubnetIds", pulumi.StringArray(privSubnetIds))
    I have a second stack in which I need to reference these subnet IDs to launch EC2 instances. I have a StackReference to the base infrastructure stack, but the only way I’ve been able to reference the private subnet IDs has been this incantation:
    privSubnetsOutput := ref.GetOutput(pulumi.String("privSubnetIds")).ApplyT(func(out interface{}) []string {
    	var res []string
    	if out != nil {
    		for _, v := range out.([]interface{}) {
    			res = append(res, v.(string))
    		}
    	}
    	return res
    })
    Followed by extracting the first subnet:
    firstPrivateSubnet := privSubnetsOutput.ApplyT(func(a []string) string {
    	var res string
    	if len(a) > 0 {
    		res = a[0]
    	}
    	return res
    }).(pulumi.StringOutput)
    If I want now to extract the second subnet, I’d have to repeat this but retrieving
    a[1]
    instead. Surely there’s a better way to go about this?
  • r

    ripe-shampoo-80285

    09/01/2022, 9:29 PM
    I’m trying to create a irsa role/policy for Karpenter. I’m keep getting this error. Anybody what am I doing wrong? error: program failed: waiting for RPCs: rpc error: code = Unknown desc = setting args: copying input “policies”: expected destination type to implement pulumi.Input or pulumi.Output, got provider.EKSServiceAccountPolicies error: an unhandled error occurred: program exited with non-zero exit code: 1
    • 1
    • 4
  • g

    gorgeous-sunset-66503

    09/07/2022, 3:57 PM
    👋 Hello, team!
  • g

    gorgeous-sunset-66503

    09/07/2022, 3:57 PM
    I am new to using Pulumi with Go and I was testing out creating a VPC in AWS
  • g

    gorgeous-sunset-66503

    09/07/2022, 3:58 PM
    vpc error.cpp
  • g

    gorgeous-sunset-66503

    09/07/2022, 4:00 PM
    I am hitting an error
  • g

    gorgeous-sunset-66503

    09/07/2022, 4:00 PM
    trying to upload the error
  • g

    gorgeous-sunset-66503

    09/07/2022, 4:00 PM
    can seem to upload
  • g

    gorgeous-sunset-66503

    09/07/2022, 4:03 PM
    cannot use 'ctx'(type*"github.com/pulumi/pulumi/sdk/v3/go/pulumi".Context) as the type*"github.com/pulumi/pulumi/sdk/go/pulumi".Context
  • s

    salmon-account-74572

    09/07/2022, 4:51 PM
    @gorgeous-sunset-66503 That looks generally correct. I am curious, though, why you’re throwing away the VPC value (
    _, err := ec2.NewVpc
    )? Typically you’ll need to keep that value so you can reference it later with other objects (subnets, route tables, etc.).
  • g

    gorgeous-sunset-66503

    09/07/2022, 5:00 PM
    I was just referencing the example from here . I was trying to figure why I was running into that error so I was taking example from the website to see if anything would change with the error I am getting
  • g

    gorgeous-sunset-66503

    09/07/2022, 5:00 PM
    https://www.pulumi.com/registry/packages/aws/api-docs/ec2/vpc/
  • g

    gorgeous-sunset-66503

    09/07/2022, 5:01 PM
    Cannot use 'pulumi.String("10.0.0/16")' (type pulumi.String) as the type pulumi.StringInput Type does not implement 'pulumi.StringInput' need the method: ToStringOutput() StringOutput have the method: ToStringOutput() StringOutput
  • g

    gorgeous-sunset-66503

    09/07/2022, 5:01 PM
    go 1.18
    
    require (
    	<http://github.com/pulumi/pulumi-aws/sdk|github.com/pulumi/pulumi-aws/sdk> v1.31.0
    	<http://github.com/pulumi/pulumi/sdk/v3|github.com/pulumi/pulumi/sdk/v3> v3.39.1
    )
  • s

    salmon-account-74572

    09/07/2022, 5:35 PM
    It looks like you’re using a much older version of the AWS SDK. In your
    import
    , you’re referencing
    <http://github.com/pulumi/pulumi-aws/sdk/go/aws/ec2|github.com/pulumi/pulumi-aws/sdk/go/aws/ec2>
    , but the example references v5 (
    <http://github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2|github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2>
    ). You may want to update your imports and
    go.mod
    and see if that helps.
  • g

    gorgeous-sunset-66503

    09/07/2022, 5:35 PM
    ok will do thanks
  • b

    bitter-kite-21926

    09/07/2022, 9:09 PM
    i’m not sure if it’s golang related or pulumi itself, but i’ve updated go -> 1.19.1, pulumi ->3.39.2 and now any command fails with
    failed: err=determining go version: exit status 2
  • m

    most-mouse-38002

    09/13/2022, 10:10 AM
    Are there any issues with building a pulumi package with Go 1.19? Apparently some dependencies need 1.18 and 1.19.
    l
    • 2
    • 2
  • s

    swift-machine-98066

    09/16/2022, 3:15 PM
    does anyone have a example of a 3-tier network setup in golang with outputs? I have code for the making the vpc, subnets but not sure how to make the igw, nats and rt's
    s
    • 2
    • 4
  • f

    flaky-arm-38472

    09/21/2022, 3:58 AM
    Has anyone implemented something similar to terraform templates?. I am trying to mimic the
    "template_file" "userdata" {}
    resource on Pulumi , specifically to use an
    userdata.sh
    file that contains the user data for an EC2 instance, but inside this file I want to extrapolate some variables from my program. In Terrafrom one could do:
    data "template_file" "userdata" {
     template = file("${path.module}/userdata.sh")
     vars = {
         env  = "dev"
    }
    And then on my
    userdata.sh
    file just reference the variable:
    #!/bin/bash -xe
    
    MYENV=${env}
    Something similar exist on Pulumi or do I have to make a go file to store the user data and do the replacement over there?
    • 1
    • 1
  • s

    swift-machine-98066

    09/21/2022, 9:00 PM
    question does anyone know how to properly work with a Export from a stack that contains json that was created by
    pulumi.StringMap
    trying to process it in another stack but getting a pointer address instead of the value. trying some thing along the lines of
    stackName := config.Require(ctx, "network:vpc")
    		region := config.Require(ctx, "aws:region")
    		s := fmt.Sprintf("%s-%s-subnets", region, stackName)
    		subnets := other.GetStringOutput(pulumi.String(s))
    		fmt.Println(string(subnets.ToStringOutput()))
    some reason ToStringOutput only returns a pulumi.StringOutput and not a string like I would expect it to be .
    f
    b
    • 3
    • 10
  • l

    lively-table-10226

    09/23/2022, 8:01 AM
    do we know if dynamic providers will be supported in Golang anytime soon?
    b
    • 2
    • 4
  • c

    curved-hair-82998

    09/23/2022, 8:27 PM
    HI all, I am facing the below issue
    Duplicate resource URN 'urn:pulumi:dev::awsBase-Pulumi::pulumi:pulumi:Stack::awsBase-Pulumi-dev'; try giving it a unique name
    [1:56 AM] this is my code structure
    - aws
       - resources
         s3.go
         vpc.go
       - main.go ( calling s3 and vpc)
       - go.sum
       - go.mod
       - pulumi.yaml
  • s

    swift-machine-98066

    09/24/2022, 1:27 AM
    question is there away to generate
    Egress: ec2.NetworkAclEgressArray{
    				&ec2.NetworkAclEgressArgs{
    					Action:    pulumi.String("allow"),
    					CidrBlock: pulumi.String("0.0.0.0/0"),
    					FromPort:  <http://pulumi.Int|pulumi.Int>(0),
    					Protocol:  pulumi.String("-1"),
    					RuleNo:    <http://pulumi.Int|pulumi.Int>(900),
    					ToPort:    <http://pulumi.Int|pulumi.Int>(0),
    				},
    ? As i'm going to have multiple subnets for various rules I need to generate
    f
    • 2
    • 1
  • d

    delightful-daybreak-41063

    09/26/2022, 10:32 PM
    I’m working on a Go CLI tool that I was hoping would spin up an AWS instance and install a server, and then stream data to the server for processing. I found pulumi in that search, and was excited it was written in go as well, hoping to integrate the two in go, instead of gluing things together with bash scripts. Currently, I can create the instance via
    pulumi up
    and install stuff via UserData, but now I’m hoping to sidestep the
    pulumi up
    command and just start the instance in the CLI app? I see that I can import github.com/pulumi/pulumi/pkg/v3/cmd/pulumi is made public in
    go mod
    , and I have access to the
    NewPulumiCmd() cobra.Cmd
    , which seems to be the only valuable thing that is exported. I assumed I could just call the
    NewPulumiCmd.Run()
    and pass in any cli parameters I would have normally passed in, but that package is “package main”, so go doesn’t want me to import it, giving the error:
    import "<http://github.com/pulumi/pulumi/pkg/v3/cmd/pulumi|github.com/pulumi/pulumi/pkg/v3/cmd/pulumi>" is a program, not an importable package
    . Is this a problem that has been asked about before? Is this the first time it has been asked? Is this just the wrong thing to be doing with the tool? Are we opposed to moving all the sub-commands to a nested package (i.e. /pkg/cmd/pulumi/cmds/up.go) and making them Public?
    b
    • 2
    • 5
Powered by Linen
Title
d

delightful-daybreak-41063

09/26/2022, 10:32 PM
I’m working on a Go CLI tool that I was hoping would spin up an AWS instance and install a server, and then stream data to the server for processing. I found pulumi in that search, and was excited it was written in go as well, hoping to integrate the two in go, instead of gluing things together with bash scripts. Currently, I can create the instance via
pulumi up
and install stuff via UserData, but now I’m hoping to sidestep the
pulumi up
command and just start the instance in the CLI app? I see that I can import github.com/pulumi/pulumi/pkg/v3/cmd/pulumi is made public in
go mod
, and I have access to the
NewPulumiCmd() cobra.Cmd
, which seems to be the only valuable thing that is exported. I assumed I could just call the
NewPulumiCmd.Run()
and pass in any cli parameters I would have normally passed in, but that package is “package main”, so go doesn’t want me to import it, giving the error:
import "<http://github.com/pulumi/pulumi/pkg/v3/cmd/pulumi|github.com/pulumi/pulumi/pkg/v3/cmd/pulumi>" is a program, not an importable package
. Is this a problem that has been asked about before? Is this the first time it has been asked? Is this just the wrong thing to be doing with the tool? Are we opposed to moving all the sub-commands to a nested package (i.e. /pkg/cmd/pulumi/cmds/up.go) and making them Public?
b

billowy-army-68599

09/26/2022, 10:38 PM
@delightful-daybreak-41063 you’re looking for Automation API I think https://www.pulumi.com/automation/ here’s a CLI example: https://github.com/jaxxstorm/pulumi-productionapp/tree/main/cli
d

delightful-daybreak-41063

09/27/2022, 1:41 AM
Awesome! Thanks for the guidance. I figured it would have been a solved problem by now, I just didn’t know where to look.
b

billowy-army-68599

09/27/2022, 1:18 PM
@delightful-daybreak-41063 is there anything you search for? I’d love t make this more discoverable
d

delightful-daybreak-41063

09/27/2022, 7:27 PM
That’s a good question. I think I just got started in the regular pulumi use case/docs, and then tunnel visioned myself into assuming that I had to use the /cmd/pulumi stuff. As far as my search queries: “run pulumi code inside application” “pulumi run from go program instead of cli” “import pulumi into go project” Those ones seem to be the most relevant until I went in search of the source code and tried to
go mod
import it I also tried adding in different use cases like “start ec2 instance programatically with pulumi”. But those got too far into the ec2 docs for pulumi and all that’s there. I also tried sprinkling in “reddit”/“stack overflow” to get away from the docs, but that didn’t help quite as much, and eventually I went searching for some official slack/discourse place for pulumi and ended up here.
Again, half of the problem was probably me just getting tunnel vision and not just reading the full manual.
View count: 7