freezing-twilight-25806
03/01/2023, 10:02 AMDiagnostics:
aws:iam:Policy (doc-mgmt-dev):
error: 1 error occurred:
* creating IAM Policy doc-mgmt-dev-ef9a0e5: MalformedPolicyDocument: Partition "
1" is not valid for resource "arn:
1: o.apply(v => v.toJSON())
2: o.apply(v => JSON.stringify(v))
See <https://pulumi.io/help/outputs> for more details.
This function may throw in a future version of @pulumi/pulumi.:*".
Here is the code I use:
import * as pulumi from "@pulumi/pulumi";
import { Sqs } from './sqs';
import { IamPolicy } from './iamPolicy';
const stackName = pulumi.getStack();
const projectName = pulumi.getProject();
const tags = {
project: projectName,
environment: stackName,
}
const sqsQueue1 = new Sqs(`${projectName}-${stackName}`, {
createDlq: true,
tags: tags,
});
const iamLambdaPolicy = new IamPolicy(`${projectName}-${stackName}`, {
path: "/",
description: `${projectName}-${stackName}-Lambda-policies`,
listOfStatements: JSON.stringify({
Version: "2012-10-17",
Statement: [
{
Action: [
"sqs:*"
],
Effect: "Allow",
Resource: [
sqsQueue1.sqs.arn.apply(v => JSON.stringify(v)),
],
},
{
Action: [
"sqs:ReceiveMessage"
],
Effect: "Allow",
Resource: [
sqsQueue1.sqsDlq?.arn.apply(v => JSON.stringify(v)),
],
},
]
}),
tags: tags,
});
export const iamLambdaPoliciyArn = iamLambdaPolicy.policy.arn;
I tried to use pulumi.all([sqsQueue1.sqs.arn, sqsQueue1.sqsDlq?.arn]).apply(([sqs1Arn, sqs1DlqArn])...
it works, but with such approach I don't see the policy resource is going to be created during pulumi preview
echoing-dinner-19531
03/01/2023, 10:28 AMJSON.stringify
, use Output.jsonStringify
it will handle the nested output values for you.freezing-twilight-25806
03/01/2023, 10:31 AMResource: [
sqsQueue1.sqs.arn.apply(v => JSON.stringify(v)),
],
echoing-dinner-19531
03/01/2023, 11:54 AMlistOfStatements: JSON.stringify({
=>
listOfStatements: pulumi.output.jsonStringify({
I always forget this is on the module not the type 🤦freezing-twilight-25806
03/01/2023, 11:56 AMechoing-dinner-19531
03/01/2023, 11:57 AMouput
? Just pulumi.jsonStringify
?freezing-twilight-25806
03/01/2023, 12:03 PM