https://pulumi.com logo
Title
l

little-market-63455

07/13/2021, 6:00 PM
This is not a question but rather a discussion/feature-request. Don't know if this is the right place for it so bear with me please I have been using Pulumi with TypeScript for a while now and got familiar with the idioms and practices but I still find several related issues to result in "not so nice" code. 1. Pulumi with TypeScript lacks top-level await support which makes using
async/await
really awkward. you need to wrap the main code in an async funtion then call that from
index.ts
using the
then/catch/finally
syntax. Not the end of the world but truly annoying 2. You could wrap all async code in
pulumi.output
which is perfect for things that are resources or resource-like but not really needed for other async API calls 3. Certain things like IAM policies which are arguably part of almost every single AWS program don't support
Input<T>
properties. I don't want to create an independent IAM policy for every IAM role/user (mainly because that indicates they are re-usable and then you need to assign them an intuitive name) so I tend to use inline policies which suffer from the aforementioned problem. I feel either those should accept
Input<T>
or there should be dedicated
IamInlinePolicyDocument
type that does. Wrapping everything in
all()/apply()
is just resulting in ugly looking code when used excessively
s

steep-toddler-94095

07/13/2021, 6:44 PM
regarding 3, are you sure? The type
PolicyDocument
and the nested types within all accept
Input<T>
l

little-market-63455

07/13/2021, 7:23 PM
Can you please link to that type as I cannot seem to find it
I found this article about the `PolicyDocument` type but that type doesn't expose any
Output<T>
properties like a JSON representation of the policy so I still cannot use it with inline policies, but thanks for pointing it out.
After a second look, it seems like I should ditch
inline_policies
in favor of other resources like
BucketPolicy
or
RolePolicy
s

steep-toddler-94095

07/13/2021, 8:44 PM
If you use an IDE like VS Code the hinting will show
Input<T>
as the type for the property keys. But here's the path to the typings file in node_modules
node_modules/@pulumi/aws/iam/documents.d.ts
h

helpful-tent-95136

07/14/2021, 1:14 AM
regarding 1. you can export an async function that returns stack outputs
export = async () => {
  // do stuff
  return {
    myStackOutput: foo.name
  };
};
l

little-market-63455

07/14/2021, 7:43 AM
I am doing that at the moment Anthony
Ah welp
PolicyDocument
doesn't support
CanonicalUser
for
Principal
😞