05/21/2023, 5:09 AM
I am having issue getting promised value working inside of
, I feel there maybe some reason on when the
get interpolated.
Here is my code:
const role = new aws.iam.Role(
    { provider: config.providers[configEnvironment] as aws.Provider },
  const keyPolicy = aws.iam.getPolicyDocument(
      statements: [
          actions: ['kms:Encrypt'],
          effect: 'Allow',
          principals: [
              type: 'AWS',
              identifiers: [`${role?.arn}`],
          resources: ['*'],
          sid: 'Allow use of the key.',
This is the error message:
[0]: "Calling [toString] on an [Output<T>] is not supported.\n\nTo get the value of an Output<T> as an Output<string> consider either:\n1: o.apply(v => `prefix${v}suffix`)\n2: pulumi.interpolate `prefix${v}suffix`\n\nSee <> for more details.\nThis function may throw in a future version of @pulumi/pulumi."
is the value I want.


05/21/2023, 8:19 PM
That's right. getPolicyDocument isn't a resource constructor and doesn't handle Input values like resources do. You need to either put the entire call to getPolicyDocument inside a call to apply, or use the PolicyDocument type instead. I recommend using the type. It should be as simple as removing the call to getPolicyDocument. I think the rest of it should just work.