Currently, I am in the process of working with a cdk script and I have the need to specify multiple principals like so:
"Principal": {
"AWS": [
"arn:aws:iam::AWS-account-ID:user/user-name-1",
"arn:aws:iam::AWS-account-ID:user/user-name-2"
]
}
While this is quite simple in a JSON document, I am facing some uncertainty when attempting to write it within a policy document.
My current approach is as follows:
const principals : Array<IPrincipal> = ['arn:aws:iam::AWS-account-ID:user/user-name-1', 'arn:aws:iam::AWS-account-ID:user/user-name-2']
const myPolicy = new PolicyDocument({
statements: [
new PolicyStatement({
actions: ['*'],
effect: Effect.ALLOW,
principals: principals,
resources: ['*'],
}),
],
});
However, this is throwing an error message stating:
Cannot read property 'principalJson' of undefined