I have to say that sometimes getting to a pulumi o...
# typescript
I have to say that sometimes getting to a pulumi output value and passing it to other things can be maddening. I am retrieving all of the usernames from an AWS IAM group to use in other places.
Copy code
const iamGroup = pulumi.output(aws.iam.getGroup({
    groupName: "myGroup",
}, { async: true }));

const usernames = iamGroup.apply(group => group.users.map(user => user.userName));
If I
const usernames, I see
Copy code
    usernames: [
        [0]: "username1"
        [1]: "username2"
        [2]: "username3"
However, later when attempting to use both
on the
list, I get
Copy code
TSError: ⨯ Unable to compile TypeScript:
    index.ts(312,13): error TS2488: Type 'Output<string[]>' must have a '[Symbol.iterator]()' method that returns an iterator.
    index.ts(469,42): error TS2339: Property 'map' does not exist on type 'Output<string[]>'.
I have tried many variations of
but am so far unable to use the above methods or return this list from the function it is in. I have read the Inputs and Outputs doc many times but it is still painful to figure out how to make it work.
Did you try something like:
Copy code
const thing = usernames.apply(names => {
   return names.filter(filterFunction)
👀 1
The challenge (and it is a bit maddening as you said) is that usernames is not a
- it’s an
so string methods are not available to it. Therefore, you need to work within the
block to strip that
aspect and get the value as a
and then you can mess with it. In the above,
will be an
again but it will contain what you want for later use.
Thank you @witty-candle-66007. I thought I understood using
but sometimes it just doesn't seem to work the way I hope it will. I appreciate your explanation. It is helpful indeed. I will work with the suggestion you provided and see where I can take it.