https://pulumi.com logo
#getting-started
Title
# getting-started
i

important-sandwich-62391

05/06/2021, 9:24 PM
Hi, as an input to a CloudFormation template, it takes an array of string Subnet IDs, as a parameter to the Template. (can’t control this). So, I have my two subnet objects, but I can’t figure out how to reasonablly combine them into a single StringInput?
Copy code
// not valid, but basically what I want to do:
		strings.Join([]string{subnetA.ID(), subnetB.ID()}, ",")


		// howto convert this into "foo,bar" (comma separated string)
		subnetsIDs := pulumi.StringArray{subnetA.ID(), subnetB.ID()}.ToStringArrayOutput().ApplyT(func(input []string) string {
			return strings.Join(input, ",")
		})
		// subnetsIDs is not a StringInput??
example of trying to use it with the CF template:
Copy code
err := cloudformation.NewStack(ctx, "thing", &cloudformation.StackArgs{
			TemplateUrl: pulumi.String(stack_5_3_1),
			Parameters: pulumi.StringMap{
				"Subnets":                   subnetsIDs, // this isn't a valid type for StringMap

			},
		})
oh, I think.. this is the All() use case.
maybe?
hmm
gross? but kinda works?
Copy code
func Join(args []interface{}, sep string) pulumi.StringOutput {
	// gross? but works?
	format := strings.TrimSuffix(strings.Repeat("%s,", len(args)), ",")
	return pulumi.Sprintf(format, args)
}
3 Views