[英]Attaching IAM user to IAM Group using Boto3
I am trying to create an IAM policy, to an IAM group using Boto3.我正在尝试为使用 Boto3 的 IAM 组创建 IAM 策略。 So far, I am not able to add IAM user to an IAM group.到目前为止,我无法将 IAM 用户添加到 IAM 组。 For "response = iam.add_user_to_group( ", I am getting an error, "Exception has occurred: AttributeError 'iam.ServiceResource' object has no attribute 'add_user_to_group'"对于“response = iam.add_user_to_group(”,我收到一个错误,“发生异常:AttributeError 'iam.ServiceResource' object has no attribute 'add_user_to_group'”
import boto3
iam = boto3.resource('iam') #using resource representing IAM
created_user = iam.create_user(
UserName='some_random_user'
)
print(created_user)
create_group_response = iam.create_group(GroupName = 'Tester')
response = iam.add_user_to_group(
UserName = 'some_random_user', #Name of user
GroupName = 'Tester'
)
response = iam.attach_user_policy(
UserName = 'some_random_user', #Name of user
PolicyArn = 'arn:aws:iam::196687784845:policy/boto-test'
# Policy ARN which you want to asign to user
)
Not sure what seems to be the problem, I am very new to python and boto so might be a very small thing.不确定似乎是什么问题,我对 python 和 boto 很陌生,所以可能是一件非常小的事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.