I am trying to use a long policy document for AWS in Pulumi that sits on disk.
const policyDocument = new pulumi.asset.FileAsset("./policy.json");
However, when I try to use the variable later like this:
export const jobPolicy = new aws.iam.Policy(`${ jobName }-policy`, {
path: `/${ stage }`,
description: `Policy for ETL job ${ jobName }`,
policy: JSON.stringify(policyDocument)
});
I get the following:
+ policy : "{\"__pulumiAsset\":true,\"path\":{}}"
Is there a way to somehow use a JSON file in Pulumi + TypeScript?
I also tried:
import * as fs from 'fs';
const policyDocument = fs.readFileSync('policy.json', 'utf8');
The result is:
Error: ENOENT: no such file or directory, open 'policy.json'
at Object.openSync (node:fs:585:3)