salmon-ghost-86211
03/24/2021, 4:15 PMconst iamGroup = pulumi.output(aws.iam.getGroup({
groupName: "myGroup",
}, { async: true }));
const usernames = iamGroup.apply(group => group.users.map(user => user.userName));
If I export
const usernames, I see
Outputs:
usernames: [
[0]: "username1"
[1]: "username2"
[2]: "username3"
]
However, later when attempting to use both .filter
and .map
on the usernames
list, I get
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 .apply
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.witty-candle-66007
03/24/2021, 4:29 PMconst thing = usernames.apply(names => {
return names.filter(filterFunction)
}
string[]
- it’s an Output<string[]>
so string methods are not available to it. Therefore, you need to work within the .apply()
block to strip that Output
aspect and get the value as a string[]
and then you can mess with it.
In the above, thing
will be an Output<string[]>
again but it will contain what you want for later use.salmon-ghost-86211
03/24/2021, 4:56 PM.apply()
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.