Python botocore.exceptions.InvalidConfigError() Examples
The following are 20
code examples of botocore.exceptions.InvalidConfigError().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
botocore.exceptions
, or try the search function
.
Example #1
Source File: credentials.py From faces with GNU General Public License v2.0 | 5 votes |
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 }
Example #2
Source File: credentials.py From aws-builders-fair-projects with Apache License 2.0 | 5 votes |
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, )
Example #3
Source File: credentials.py From aws-builders-fair-projects with Apache License 2.0 | 5 votes |
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)
Example #4
Source File: credentials.py From aws-builders-fair-projects with Apache License 2.0 | 5 votes |
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 )
Example #5
Source File: credentials.py From aws-builders-fair-projects with Apache License 2.0 | 5 votes |
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) ))
Example #6
Source File: credentials.py From runway with Apache License 2.0 | 5 votes |
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
Example #7
Source File: credentials.py From aws-extender with MIT License | 5 votes |
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 }
Example #8
Source File: credentials.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
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) ))
Example #9
Source File: credentials.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
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) ))
Example #10
Source File: credentials.py From bash-lambda-layer with MIT License | 5 votes |
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) ))
Example #11
Source File: credentials.py From deepWordBug with Apache License 2.0 | 5 votes |
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) ))
Example #12
Source File: credentials.py From faces with GNU General Public License v2.0 | 5 votes |
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 }
Example #13
Source File: credentials.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 4 votes |
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
Example #14
Source File: credentials.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 4 votes |
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 )
Example #15
Source File: credentials.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 4 votes |
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
Example #16
Source File: credentials.py From bash-lambda-layer with MIT License | 4 votes |
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 )
Example #17
Source File: credentials.py From bash-lambda-layer with MIT License | 4 votes |
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
Example #18
Source File: credentials.py From aws-builders-fair-projects with Apache License 2.0 | 4 votes |
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
Example #19
Source File: credentials.py From deepWordBug with Apache License 2.0 | 4 votes |
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 )
Example #20
Source File: credentials.py From deepWordBug with Apache License 2.0 | 4 votes |
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