{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": [
"codedeploy.amazonaws.com"
]
},
"Action": "sts:AssumeRole"
}
]
}
并将文件另存为
service-role.json
aws iam create-role --role-name MyServiceRole --assume-role-policy-document file://service-role.json
我得跑了。。。最终。返回了一些JSON:
{
"Role": {
"Path": "/",
"RoleName": "MyServiceRole",
"RoleId": "SOMESTRINGOFRANDOMALPHANUMERICS",
"Arn": "arn:aws:iam::1123445569:role/MyServiceRole",
"CreateDate": "2018-08-31T03:18:24Z",
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": [
"codedeploy.amazonaws.com"
]
},
"Action": "sts:AssumeRole"
}
]
}
}
}
所有这些看起来都是正确的,所以我试着跑:
aws iam attach-role-policy --role-name MyServiceRole --policy-arn arn:aws:iam::1123445569:role/MyServiceRole
还有。。。我得到了回应
An error occurred (InvalidInput) when calling the AttachRolePolicy operation: ARN arn:aws:iam::1123445569:role/MyServiceRole is not valid.
我已经在互联网上寻找解决办法,因为看起来我做了什么
this