[英]How can we connect to Amazon CloudWatch using boto3 with IAM role without using secret access key
client = boto3.client('logs','us-west-2')
response = client.attach_role_policy(
RoleName='',
PolicyArn=''
)
The above code is giving me error:上面的代码给了我错误:
AttributeError: 'CloudWatchLogs' object has no attribute 'attach_role_policy'
AttributeError: 'CloudWatchLogs' 对象没有属性 'attach_role_policy'
The client you have defined is a CloudWatch Logs client, which has no method called attach_role_policy
- this is a method on the IAM client, so for example:您定义的客户端是 CloudWatch Logs 客户端,它没有名为
attach_role_policy
的方法 - 这是 IAM 客户端上的一个方法,例如:
logs_client = boto3.client('logs','us-west-2')
iam_client = boto3.client('iam', 'us-west-2')
and then you can use然后你可以使用
iam_client.attach_role_policy(...)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.