当前位置: 首页>>代码示例>>Python>>正文


Python boto.iam方法代码示例

本文整理汇总了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 
开发者ID:DataBiosphere,项目名称:toil,代码行数:25,代码来源:context.py

示例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) 
开发者ID:bcbio,项目名称:bcbio-nextgen-vm,代码行数:16,代码来源:iam.py

示例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 
开发者ID:DataBiosphere,项目名称:toil,代码行数:11,代码来源:context.py

示例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 
开发者ID:DataBiosphere,项目名称:toil,代码行数:10,代码来源:context.py

示例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 
开发者ID:DataBiosphere,项目名称:toil,代码行数:8,代码来源:context.py

示例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') 
开发者ID:DataBiosphere,项目名称:toil,代码行数:4,代码来源:context.py

示例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) 
开发者ID:canvasnetworks,项目名称:canvas,代码行数:15,代码来源:__init__.py

示例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) 
开发者ID:dump247,项目名称:aws-mock-metadata,代码行数:7,代码来源:__init__.py

示例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() 
开发者ID:dump247,项目名称:aws-mock-metadata,代码行数:11,代码来源:__init__.py

示例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 
开发者ID:dump247,项目名称:aws-mock-metadata,代码行数:12,代码来源:__init__.py


注:本文中的boto.iam方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。