Reputation: 11
I'm currently working on an AWS course, and have been using the Windows CLI in order to setup demo infrastructure in my AWS VPC. I was attempting to create a role called "bastion-role" via using the following command:
aws iam create-role --role-name bastion-role --assume-role-policy-document file://role-policy.json
but it yields this error:
Error parsing parameter
--assume-role-policy-document
: Unable to load paramfile file://role-policy.json: [Errno 2] No such file or directory: 'role-policy.json'
I'm assuming it's having a problem referencing the local directory that I'm currently in. I've attempted the following troubleshooting measures:
file://
part and just the name 'role-policy.json'. This didn't workfile://c:\role-policy-json
file://../role-policy.json
file:///role-policy.json
file:///c:\role-policy.json
Unfortunately, none of these combinations have worked. I'm assuming I'm missing something, but I can't figure it out. If someone could shed some light on this problem, I'd appreciate it.
Upvotes: 1
Views: 1781
Reputation: 59
Probably its too late to provide this answer, but the right way to execute this command is like this:
aws iam --region us-east-2 create-role --role-name <YOUR_ROLE_NAME> --assume-role-policy-document file://C:\Users\<USERNAME>\FULL\PATH\TO\file_containing_policy.json
After successful execution you should see something like this:
{
"Role": {
"Path": "/",
"RoleName": "YOUR_ROLE_NAME",
"RoleId": "AROXXXXXXXXXXXXXXXXXX",
"Arn": "arn:aws:iam::XXXXXXXXXXXX:role/YOUR_ROLE_NAME",
"CreateDate": "2020-11-17T04:53:35+00:00",
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": "<SERVICE>.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
}
}
Upvotes: 1