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


Python exceptions.InvalidConfigError方法代码示例

本文整理汇总了Python中botocore.exceptions.InvalidConfigError方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.InvalidConfigError方法的具体用法?Python exceptions.InvalidConfigError怎么用?Python exceptions.InvalidConfigError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在botocore.exceptions的用法示例。


在下文中一共展示了exceptions.InvalidConfigError方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_role_config_values

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import InvalidConfigError [as 别名]
def _get_role_config_values(self):
        # This returns the role related configuration.
        profiles = self._loaded_config.get('profiles', {})
        try:
            source_profile = profiles[self._profile_name]['source_profile']
            role_arn = profiles[self._profile_name]['role_arn']
            mfa_serial = profiles[self._profile_name].get('mfa_serial')
        except KeyError as e:
            raise PartialCredentialsError(provider=self.METHOD,
                                          cred_var=str(e))
        external_id = profiles[self._profile_name].get('external_id')
        role_session_name = \
            profiles[self._profile_name].get('role_session_name')
        if source_profile not in profiles:
            raise InvalidConfigError(
                error_msg=(
                    'The source_profile "%s" referenced in '
                    'the profile "%s" does not exist.' % (
                        source_profile, self._profile_name)))
        source_cred_values = profiles[source_profile]
        return {
            'role_arn': role_arn,
            'external_id': external_id,
            'source_profile': source_profile,
            'mfa_serial': mfa_serial,
            'source_cred_values': source_cred_values,
            'role_session_name': role_session_name
        } 
开发者ID:skarlekar,项目名称:faces,代码行数:30,代码来源:credentials.py

示例2: _validate_credential_source

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import InvalidConfigError [as 别名]
def _validate_credential_source(self, parent_profile, credential_source):
        if self._credential_sourcer is None:
            raise InvalidConfigError(error_msg=(
                'The credential_source "%s" is specified in profile "%s", '
                'but no source provider was configured.' % (
                    credential_source, parent_profile)
            ))
        if not self._credential_sourcer.is_supported(credential_source):
            raise InvalidConfigError(error_msg=(
                'The credential source "%s" referenced in profile "%s" is not '
                'valid.' % (credential_source, parent_profile)
            )) 
开发者ID:QData,项目名称:deepWordBug,代码行数:14,代码来源:credentials.py

示例3: _load_sso_config

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import InvalidConfigError [as 别名]
def _load_sso_config(self):
        """Load sso config."""
        loaded_config = self._load_config()
        profiles = loaded_config.get('profiles', {})
        profile_name = self._profile_name
        profile_config = profiles.get(self._profile_name, {})

        if all(c not in profile_config for c in self._SSO_CONFIG_VARS):
            return None

        config = {}
        missing_config_vars = []
        for config_var in self._SSO_CONFIG_VARS:
            if config_var in profile_config:
                config[config_var] = profile_config[config_var]
            else:
                missing_config_vars.append(config_var)

        if missing_config_vars:
            missing = ', '.join(missing_config_vars)
            raise InvalidConfigError(
                error_msg=(
                    'The profile "%s" is configured to use SSO but is missing '
                    'required configuration: %s' % (profile_name, missing)
                )
            )

        return config 
开发者ID:onicagroup,项目名称:runway,代码行数:30,代码来源:credentials.py

示例4: _validate_source_profile

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import InvalidConfigError [as 别名]
def _validate_source_profile(self, parent_profile_name,
                                 source_profile_name):
        profiles = self._loaded_config.get('profiles', {})
        if source_profile_name not in profiles:
            raise InvalidConfigError(
                error_msg=(
                    'The source_profile "%s" referenced in '
                    'the profile "%s" does not exist.' % (
                        source_profile_name, parent_profile_name)
                )
            )

        source_profile = profiles[source_profile_name]

        # Make sure we aren't going into an infinite loop. If we haven't
        # visited the profile yet, we're good.
        if source_profile_name not in self._visited_profiles:
            return

        # If we have visited the profile and the profile isn't simply
        # referencing itself, that's an infinite loop.
        if source_profile_name != parent_profile_name:
            raise InfiniteLoopConfigError(
                source_profile=source_profile_name,
                visited_profiles=self._visited_profiles
            )

        # A profile is allowed to reference itself so that it can source
        # static credentials and have configuration all in the same
        # profile. This will only ever work for the top level assume
        # role because the static credentials will otherwise take
        # precedence.
        if not self._has_static_credentials(source_profile):
            raise InfiniteLoopConfigError(
                source_profile=source_profile_name,
                visited_profiles=self._visited_profiles
            ) 
开发者ID:aws-samples,项目名称:aws-builders-fair-projects,代码行数:39,代码来源:credentials.py

示例5: _resolve_credentials_from_profile

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import InvalidConfigError [as 别名]
def _resolve_credentials_from_profile(self, profile_name):
        profiles = self._loaded_config.get('profiles', {})
        profile = profiles[profile_name]

        if self._has_static_credentials(profile) and \
                not self._profile_provider_builder:
            # This is only here for backwards compatibility. If this provider
            # isn't given a profile provider builder we still want to be able
            # handle the basic static credential case as we would before the
            # provile provider builder parameter was added.
            return self._resolve_static_credentials_from_profile(profile)
        elif self._has_static_credentials(profile) or \
                not self._has_assume_role_config_vars(profile):
            profile_providers = self._profile_provider_builder.providers(
                profile_name=profile_name,
                disable_env_vars=True,
            )
            profile_chain = CredentialResolver(profile_providers)
            credentials = profile_chain.load_credentials()
            if credentials is None:
                error_message = (
                    'The source profile "%s" must have credentials.'
                )
                raise InvalidConfigError(
                    error_msg=error_message % profile_name,
                )
            return credentials

        return self._load_creds_via_assume_role(profile_name) 
开发者ID:aws-samples,项目名称:aws-builders-fair-projects,代码行数:31,代码来源:credentials.py

示例6: _assume_role_with_web_identity

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import InvalidConfigError [as 别名]
def _assume_role_with_web_identity(self):
        token_path = self._get_config('web_identity_token_file')
        if not token_path:
            return None
        token_loader = self._token_loader_cls(token_path)

        role_arn = self._get_config('role_arn')
        if not role_arn:
            error_msg = (
                'The provided profile or the current environment is '
                'configured to assume role with web identity but has no '
                'role ARN configured. Ensure that the profile has the role_arn'
                'configuration set or the AWS_ROLE_ARN env var is set.'
            )
            raise InvalidConfigError(error_msg=error_msg)

        extra_args = {}
        role_session_name = self._get_config('role_session_name')
        if role_session_name is not None:
            extra_args['RoleSessionName'] = role_session_name

        fetcher = AssumeRoleWithWebIdentityCredentialFetcher(
            client_creator=self._client_creator,
            web_identity_token_loader=token_loader,
            role_arn=role_arn,
            extra_args=extra_args,
            cache=self.cache,
        )
        # The initial credentials are empty and the expiration time is set
        # to now so that we can delay the call to assume role until it is
        # strictly needed.
        return DeferredRefreshableCredentials(
            method=self.METHOD,
            refresh_using=fetcher.fetch_credentials,
        ) 
开发者ID:aws-samples,项目名称:aws-builders-fair-projects,代码行数:37,代码来源:credentials.py

示例7: _get_role_config

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import InvalidConfigError [as 别名]
def _get_role_config(self, profile_name):
        """Retrieves and validates the role configuration for the profile."""
        profiles = self._loaded_config.get('profiles', {})

        profile = profiles[profile_name]
        source_profile = profile.get('source_profile')
        role_arn = profile['role_arn']
        credential_source = profile.get('credential_source')
        mfa_serial = profile.get('mfa_serial')
        external_id = profile.get('external_id')
        role_session_name = profile.get('role_session_name')
        duration_seconds = profile.get('duration_seconds')

        role_config = {
            'role_arn': role_arn,
            'external_id': external_id,
            'mfa_serial': mfa_serial,
            'role_session_name': role_session_name,
            'source_profile': source_profile,
            'credential_source': credential_source
        }

        if duration_seconds is not None:
          try:
            role_config['duration_seconds'] = int(duration_seconds)
          except ValueError:
            pass

        # Either the credential source or the source profile must be
        # specified, but not both.
        if credential_source is not None and source_profile is not None:
            raise InvalidConfigError(
                error_msg=(
                    'The profile "%s" contains both source_profile and '
                    'credential_source.' % profile_name
                )
            )
        elif credential_source is None and source_profile is None:
            raise PartialCredentialsError(
                provider=self.METHOD,
                cred_var='source_profile or credential_source'
            )
        elif credential_source is not None:
            self._validate_credential_source(
                profile_name, credential_source)
        else:
            self._validate_source_profile(profile_name, source_profile)

        return role_config 
开发者ID:QData,项目名称:deepWordBug,代码行数:51,代码来源:credentials.py

示例8: _validate_source_profile

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import InvalidConfigError [as 别名]
def _validate_source_profile(self, parent_profile_name,
                                 source_profile_name):
        profiles = self._loaded_config.get('profiles', {})
        if source_profile_name not in profiles:
            raise InvalidConfigError(
                error_msg=(
                    'The source_profile "%s" referenced in '
                    'the profile "%s" does not exist.' % (
                        source_profile_name, parent_profile_name)
                )
            )

        source_profile = profiles[source_profile_name]

        # Ensure the profile has valid credential type
        if not self._source_profile_has_credentials(source_profile):
            raise InvalidConfigError(
                error_msg=(
                    'The source_profile "%s" must specify either static '
                    'credentials or an assume role configuration' % (
                        source_profile_name)
                )
            )

        # Make sure we aren't going into an infinite loop. If we haven't
        # visited the profile yet, we're good.
        if source_profile_name not in self._visited_profiles:
            return

        # If we have visited the profile and the profile isn't simply
        # referencing itself, that's an infinite loop.
        if source_profile_name != parent_profile_name:
            raise InfiniteLoopConfigError(
                source_profile=source_profile_name,
                visited_profiles=self._visited_profiles
            )

        # A profile is allowed to reference itself so that it can source
        # static credentials and have configuration all in the same
        # profile. This will only ever work for the top level assume
        # role because the static credentials will otherwise take
        # precedence.
        if not self._has_static_credentials(source_profile):
            raise InfiniteLoopConfigError(
                source_profile=source_profile_name,
                visited_profiles=self._visited_profiles
            ) 
开发者ID:QData,项目名称:deepWordBug,代码行数:49,代码来源:credentials.py


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