how are people storing Arns from StringOutput in a...
# golang
s
how are people storing Arns from StringOutput in a struct?
b
StringOutputArray
?
oh, you mean like this:
Copy code
type MyStruct struct {
  Arns pulumi.StringOutputArray
}
s
@billowy-army-68599 ok, so that should fix this
Cannot use 'role.Arn' (type pulumi.StringOutput) as the type pulumi.String ?
b
hmm maybe, what’s throwing that error for you?
s
this function
Copy code
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
Copy code
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
I think this needs to be
Copy code
IamRoleName    pulumi.StringOutput
but hard to figure out on the fly
s
ok
yeah that seems to fix it, one would think that .Arn would return a pulumi.String
b
the StringOutput/StringInput types implement pulumi.String, so they’re better to use in situations like this
s
how can you print out a StringOutput with out using a ApplyT to All call?
b
you can’t
s
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
it’s because Go doesn’t have generics (yet), so it can’t represent any future values
s
it does and has since 1.18 its called a interface 🙂
b
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
<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
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