bored-salesmen-65698
05/29/2024, 6:03 AMexport class EksRole extends pulumi.ComponentResource {
public readonly role: aws.iam.Role;
constructor(
name: string,
args: EksRoleArgs,
opts?: pulumi.ComponentResourceOptions
) {
super('custom:aws:eksRole', name, {}, opts);
const defaultArgs: EksRoleArgs = {
...xyz,
...args,
};
const assumeRolePolicy = aws.iam.getPolicyDocument({
statements: [
{
..........,
],
});
this.role = new aws.iam.Role(
name,
{
assumeRolePolicy: assumeRolePolicy.then((policy) => policy.json),
description: defaultArgs.roleDescription,
maxSessionDuration: defaultArgs.roleMaxSessionDuration,
name: defaultArgs.roleName,
path: defaultArgs.rolePath,
permissionsBoundary: defaultArgs.rolePermissionsBoundary,
tags: defaultArgs.roleTags,
},
{ parent: this }
);
this.attachInlinePolicy(defaultArgs.roleInlinePolicy);
this.registerOutputs({ role: this.role });
}
private attachInlinePolicy(policy: pulumi.Input<string> | undefined) {
if (policy) {
pulumi.all([this.role.name, policy]).apply(([role, policy]) => {
new aws.iam.RolePolicy(
`${role}-inline-policy`,
{
policy,
role,
},
{ parent: this }
);
});
}
}
}
lively-crayon-44649
05/29/2024, 8:43 AMasync
code from within a constructor. If your challenge is with the getPolicyDocument
function, you might replace it with getPolicyDocumentOutput
, which will return an Output<T>
instead of a Promise<T>
, which you should be able to slot in to your other resources without needing to worry about async
.lively-crayon-44649
05/29/2024, 8:44 AMgetPolicyDocument
will have an Output
variant that returns an Output
instead of a Promise
.little-cartoon-10569
05/29/2024, 11:13 PMbored-salesmen-65698
05/30/2024, 4:38 AMlively-crayon-44649
05/30/2024, 8:23 AMasync
constructors yet)