b

    brave-lizard-56518

    5 months ago
    I used the (*pulumi.Context).Export() function to export a pulumi.StringArray of subnet IDs, and a few other metadata. At the bottom is an excerpt of my stack output as stored in my state file, which I’m already able to load using pulumi.NewStackReference(), and read a plain string like the “eip-1”, for example. My code for reading the eip-1 (which works) is:
    nsr, _ := pulumi.NewStackReference(ctx, vpcStackRef, nil)
    eip1 := nsr.GetStringOutput(pulumi.String("eip-1"))
    Now what I can’t figure out is how to read “data-subnets” into a slice. Can anybody help?
    "resources": [
                    {
                        "urn": "urn:pulumi:dev::vpc::pulumi:pulumi:Stack::dev",
                        "custom": false,
                        "type": "pulumi:pulumi:Stack",
                        "outputs": {
                            "data-subnets": [
                                "subnet-abcddaed530b25d91",
                                "subnet-abcdcfacd0c04fe74",
                                "subnet-abcd693e4a8ae4ca8"
                            ],
                            "eip-1": "eipalloc-abcdcfa5cf063576d"
    e

    echoing-dinner-19531

    5 months ago
    You can use
    GetOutput("data-subnets")
    which will return any
    AnyOutput
    . If you
    ApplyT
    that you can get the
    interface{}
    value inside and I think it should be castable to a string slice.
    b

    brave-lizard-56518

    5 months ago
    @echoing-dinner-19531, I was looking for a canned function, but there appears to be none. Anyway, I’ve tried it with the ApplyT, and got it to work. Thanks!.