sparse-intern-71089
02/03/2022, 11:20 PMlittle-cartoon-10569
02/03/2022, 11:26 PMbored-table-20691
02/03/2022, 11:28 PMfunc GetStringArrayOutput(ref *pulumi.StackReference, key string) pulumi.StringArrayOutput {
output := ref.GetOutput(pulumi.String(key))
return output.ApplyT(func(input interface{}) []string {
vals := make([]string, len(input.([]interface{})))
for idx, val := range input.([]interface{}) {
vals[idx] = val.(string)
}
return vals
}).(pulumi.StringArrayOutput)
}bored-table-20691
02/03/2022, 11:28 PMbored-table-20691
02/03/2022, 11:30 PMApply, but then I try and avoid creating resources in Apply. The other option is to call the Index(i) method, but thereās no way to know the length (unless you also export that).
This is the kind of stuff I meanlittle-cartoon-10569
02/03/2022, 11:32 PMlittle-cartoon-10569
02/03/2022, 11:34 PMlittle-cartoon-10569
02/03/2022, 11:35 PMbored-table-20691
02/03/2022, 11:37 PMbored-table-20691
02/03/2022, 11:37 PMawsx (because itās not available for Go as the main reason š ), but what you said is exactly the type of thing I am thinking about.
An example is I want to create some R53 records in my infrastructure stack, and then I want some downstream stack to be able to leverage those and create something based on them (e.g. a cert or something). Itās hard because of these types of issues, and usually requires a lot of gymnastics in order to avoid.proud-angle-89904
02/03/2022, 11:39 PMfunc Firewall(ctx *pulumi.Context, instances []*linode.Instance, region string) (*linode.Firewall, error) {
var linodes pulumi.IntArray
for _, instance := range instances {
instanceId := instance.ID().ToStringOutput().ApplyT(parseString()).(pulumi.IntInput)
linodes = append(linodes, instanceId)
}
var wall, err = linode.NewFirewall(ctx, "Firewall", &linode.FirewallArgs{
Label: pulumi.String("Firewall"),
Tags: pulumi.StringArray{
pulumi.String("test"),
},
InboundPolicy: pulumi.String("DROP"),
OutboundPolicy: pulumi.String("DROP"),
Linodes: linodes,
})
...bored-table-20691
02/03/2022, 11:42 PMctx.Export("my-key", someStringArrayOutput)
And when you import it on the other side, itāll be a pulumi.AnyOutput and you have to do some casting magic to get it to be pulumi.StringArrayOutputbored-table-20691
02/03/2022, 11:44 PMinstances array is actually a real array/slice, so you can iterate over it. And even your linodes is a []<http://pulumi.Int|pulumi.Int> (just typedefāed to IntArray).little-cartoon-10569
02/03/2022, 11:45 PMlittle-cartoon-10569
02/03/2022, 11:45 PMlittle-cartoon-10569
02/03/2022, 11:45 PMlittle-cartoon-10569
02/03/2022, 11:46 PMbored-table-20691
02/03/2022, 11:46 PMlittle-cartoon-10569
02/03/2022, 11:48 PMRecord.get() inside your component resource's constructor. Then you'll have a real (but read-only) instance of the Record.proud-angle-89904
02/03/2022, 11:49 PMbored-table-20691
02/03/2022, 11:50 PM