https://pulumi.com logo
Title
j

jolly-church-88521

10/18/2022, 3:48 PM
What’s the best way to convert
foo.Arn
(pulumi.StringOutput) to
string
? I’m kind of lost here and I cannot find any working example 😕 I’m trying to make it work with
foo.Arn.ApplyT(func(arn string) string { … }
but somehow it’s not working for me.
b

billowy-army-68599

10/18/2022, 3:54 PM
you can’t convert a
StringOutput
to a string
j

jolly-church-88521

10/18/2022, 3:55 PM
ohh ok, so looks like I’m trying to do something wrong…
thanks!
b

billowy-army-68599

10/18/2022, 3:55 PM
you can only resolve it and then do something with it inside an Apply
what are you trying to do?
j

jolly-church-88521

10/18/2022, 3:59 PM
I’m getting
roleArn
from user and it’s a string. So I’m doing something like:
if role.RoleArn == "" { }
to check if there is a RoleArn. If not I’m creating it and adding to one of the policy:
data := tmpArn{
		Version: "2012-10-17",
		Statement: []Statement{
			{
				Effect: "Allow",
				Principal: Principal{
					Aws: RoleArn,
				},
				Action: "sts:AssumeRole",
			},
		},
	}
b

billowy-army-68599

10/18/2022, 4:02 PM
although this:
if role.RoleArn == "" { }
is wrong, generally
you shouldn’t need to check if something exists with Pulumi
j

jolly-church-88521

10/18/2022, 4:05 PM
why?
btw - thanks for pointing me to those examples, I will need to refactor my code a bit to make it work
b

billowy-army-68599

10/18/2022, 4:42 PM
because Pulumi is declarative, if it doesn’t exist you should create it. if it does exist you should import it