AWS create-policy MalformedPolicyDocument

0

Hello,

I did not find the solution here so I need to ask you for some help. I am trying to create a new simple aws policy (cli) with powershell and I have the error:

An error occurred (MalformedPolicyDocument) when calling the CreatePolicy operation: Syntax errors in policy.

This is the command I use:

aws iam create-policy --policy-name TEST-POLICY --policy-document file://policy.json

And this is the policy.json file:

{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"iam:GetUser",
"iam:GetGroup"
],
"Resource": [
"arn:aws:iam::(arn id):user/(arn id)",
"arn:aws:iam::(arn id):group/(arn id)"
]
}
]
}

It is strange because when I use the AWS website JSON editor it works fine. But when I try it on my windows pc does not.
Maybe there is something missing on the cmdlet?

PS: I wrote (arn id) but there is an ID in the real file

gefragt vor 3 Jahren1147 Aufrufe
2 Antworten
1

Solved. It was because the encoding UTF-8-BOM. It must be UTF-8

beantwortet vor 3 Jahren
0

In general use CloudTrail to troubleshoot the error. Refer to this guide : https://aws.amazon.com/premiumsupport/knowledge-center/cloudformation-malformed-policy-errors/

AWS
gromit
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen