https://pulumi.com logo
Title
s

swift-machine-98066

10/03/2022, 7:05 PM
how are people storing Arns from StringOutput in a struct?
b

billowy-army-68599

10/03/2022, 7:06 PM
StringOutputArray
?
oh, you mean like this:
type MyStruct struct {
  Arns pulumi.StringOutputArray
}
s

swift-machine-98066

10/03/2022, 7:07 PM
@billowy-army-68599 ok, so that should fix this
Cannot use 'role.Arn' (type pulumi.StringOutput) as the type pulumi.String ?
b

billowy-army-68599

10/03/2022, 7:09 PM
hmm maybe, what’s throwing that error for you?
s

swift-machine-98066

10/03/2022, 7:10 PM
this function
func (f *flowLog) CreateIAMRole(name string) *flowLog {
	role, err := iam.NewRole(f.vpcSetupCreateHelper.ctx, name, &iam.RoleArgs{
		AssumeRolePolicy: pulumi.Any(fmt.Sprintf(`{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "",
      "Effect": "Allow",
      "Principal": {
        "Service": "<http://vpc-flow-logs.amazonaws.com|vpc-flow-logs.amazonaws.com>"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}
`)),
	})
	if err != nil {
		panic(err)
	}
	f.IamRoleName = role.Arn
	return f
}
struct is such
type flowLog struct {
	Name           String
	CloudwatchArgs cloudwatch.LogGroupArgs
	FlowlogArgs    ec2.FlowLogArgs
	IamRoleName    pulumi.String
	GroupName      pulumi.String
	TrafficType    String
	UseS3          bool
	S3BucketName   String

	vpcSetupCreateHelper *vpcSetupCreateHelper
	provider             pulumi.ProviderResource
}
b

billowy-army-68599

10/03/2022, 7:11 PM
I think this needs to be
IamRoleName    pulumi.StringOutput
but hard to figure out on the fly
s

swift-machine-98066

10/03/2022, 7:20 PM
ok
yeah that seems to fix it, one would think that .Arn would return a pulumi.String
b

billowy-army-68599

10/03/2022, 7:23 PM
the StringOutput/StringInput types implement pulumi.String, so they’re better to use in situations like this
s

swift-machine-98066

10/03/2022, 7:23 PM
how can you print out a StringOutput with out using a ApplyT to All call?
b

billowy-army-68599

10/03/2022, 7:25 PM
you can’t
s

swift-machine-98066

10/03/2022, 7:25 PM
yeah, I know thats the one of the most annoying things about pulumi and most cloud libraries, doing the retype of
string
into their own string type.
just use a string as a string 🙂
it would be interesting to know the design reason why people do this all the time
b

billowy-army-68599

10/03/2022, 7:28 PM
it’s because Go doesn’t have generics (yet), so it can’t represent any future values
s

swift-machine-98066

10/03/2022, 7:28 PM
it does and has since 1.18 its called a interface 🙂
b

billowy-army-68599

10/03/2022, 7:29 PM
yeah sorry, let me rephrase: Generic weren’t introduced when we wrote the SDK
there is a roadmap item to rewrite with it
in any case, a Go “string” is known at runtime. Any value that is returned from the API isn’t known at runtime, so it’s not really possible to “use a string as a string”
s

swift-machine-98066

10/03/2022, 7:30 PM
<strike>ok that makes sense so is the go sdk based off 1.14 or 1.15?</strike>
So does this output method issue exist in python or any other language ? wondering if this StringOutput thing is a golang issue
b

billowy-army-68599

10/03/2022, 7:32 PM
we wrote the SDK at 1.16 (i think). you can track the generics implementation here: https://github.com/pulumi/pulumi/issues/9143
the “outputty” types all exist in the other languages yeah, but implementation wise it’s a little easier sometimes