本文整理汇总了Python中boto.iam方法的典型用法代码示例。如果您正苦于以下问题:Python boto.iam方法的具体用法?Python boto.iam怎么用?Python boto.iam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boto
的用法示例。
在下文中一共展示了boto.iam方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_iam_ec2_role
# 需要导入模块: import boto [as 别名]
# 或者: from boto import iam [as 别名]
def setup_iam_ec2_role(self, role_name, policies):
aws_role_name = self.to_aws_name(role_name)
try:
self.iam.create_role(aws_role_name, assume_role_policy_document=json.dumps({
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {"Service": ["ec2.amazonaws.com"]},
"Action": ["sts:AssumeRole"]}
]}))
except BotoServerError as e:
if e.status == 409 and e.error_code == 'EntityAlreadyExists':
pass
else:
raise
self.__setup_entity_policies(aws_role_name, policies,
list_policies=self.iam.list_role_policies,
delete_policy=self.iam.delete_role_policy,
get_policy=self.iam.get_role_policy,
put_policy=self.iam.put_role_policy)
return aws_role_name
示例2: bootstrap
# 需要导入模块: import boto [as 别名]
# 或者: from boto import iam [as 别名]
def bootstrap(args):
import boto.iam
import boto.ec2
conn = boto.iam.connect_to_region(args.region)
config = create_keypair(args.econfig, region=args.region)
config.update(_bcbio_iam_user(conn, args))
config.update(bcbio_s3_instance_profile(conn, args))
ec2_conn = boto.ec2.connect_to_region(args.region)
config["ec2_region"] = ec2_conn.region.name
config["ec2_url"] = "https://" + ec2_conn.region.endpoint
econfig = _write_elasticluster_config(config, args.econfig)
print("\nWrote elasticluster config file at: %s" % econfig)
if args.nocreate:
print(NOIAM_MSG)
示例3: iam
# 需要导入模块: import boto [as 别名]
# 或者: from boto import iam [as 别名]
def iam(self):
"""
:rtype: IAMConnection
"""
if self.__iam is None:
self.__iam = self.__aws_connect(iam, 'universal')
return self.__iam
# VPCConnection extends EC2Connection so we can use one instance of the former for both
示例4: account
# 需要导入模块: import boto [as 别名]
# 或者: from boto import iam [as 别名]
def account(self):
try:
arn = self.iam.get_user().arn
except BaseException:
# Agent boxes run with IAM role credentials instead of user credentials.
arn = get_instance_metadata()['iam']['info']['InstanceProfileArn']
_, partition, service, region, account, resource = arn.split(':', 6)
return account
示例5: iam_user_name
# 需要导入模块: import boto [as 别名]
# 或者: from boto import iam [as 别名]
def iam_user_name(self):
try:
return self.iam.get_user().user_name
except BaseException:
log.warning("IAMConnection.get_user() failed.", exc_info=True)
return None
示例6: _get_all_roles
# 需要导入模块: import boto [as 别名]
# 或者: from boto import iam [as 别名]
def _get_all_roles(self):
return self._pager(self.iam.list_roles, 'roles')
示例7: connect_iam
# 需要导入模块: import boto [as 别名]
# 或者: from boto import iam [as 别名]
def connect_iam(aws_access_key_id=None, aws_secret_access_key=None, **kwargs):
"""
:type aws_access_key_id: string
:param aws_access_key_id: Your AWS Access Key ID
:type aws_secret_access_key: string
:param aws_secret_access_key: Your AWS Secret Access Key
:rtype: :class:`boto.iam.IAMConnection`
:return: A connection to Amazon's IAM
"""
from boto.iam import IAMConnection
return IAMConnection(aws_access_key_id, aws_secret_access_key, **kwargs)
示例8: iam
# 需要导入模块: import boto [as 别名]
# 或者: from boto import iam [as 别名]
def iam(self):
return boto.iam.connect_to_region(
self.region,
aws_access_key_id=self.access_key,
aws_secret_access_key=self.secret_key)
示例9: _load_user
# 需要导入模块: import boto [as 别名]
# 或者: from boto import iam [as 别名]
def _load_user(self):
self.user = get_value(
self.iam.get_user(),
'get_user_response',
'get_user_result',
'user')
if self.mfa_enabled:
self._load_mfa_device()
示例10: _load_mfa_device
# 需要导入模块: import boto [as 别名]
# 或者: from boto import iam [as 别名]
def _load_mfa_device(self):
mfa_device = first_item(get_value(
self.iam.get_all_mfa_devices(self.user.user_name),
'list_mfa_devices_response',
'list_mfa_devices_result',
'mfa_devices'))
self.mfa_serial_number = mfa_device.serial_number\
if mfa_device\
else None