def validate(self): credentials = self.get_credentials() if None in (credentials.get('AccessKeyId'), credentials.get('SecretAccessKey')) and not credentials.get('AllowEnvironmentCredentials') \ and not aws_conf.has_iam_metadata(): raise ValueError( 'Can\'t create AWS client, credential is not configured') return True
def _init_clients(): global CLIENT_CACHE if CLIENT_CACHE is not None: return CLIENT_CACHE = {} for identifier in conf.AWS_ACCOUNTS.keys(): CLIENT_CACHE[identifier] = _make_client(identifier) # If default configuration not initialized, initialize client connection with IAM metadata if 'default' not in CLIENT_CACHE and conf.has_iam_metadata(): CLIENT_CACHE['default'] = Client()
def _init_clients(): global CLIENT_CACHE if CLIENT_CACHE is not None: return CLIENT_CACHE = {} # Can't convert this to django cache, because S3FileSystem is not pickable for identifier in list(aws_conf.AWS_ACCOUNTS.keys()): CLIENT_CACHE[_get_cache_key(identifier)] = _make_client(identifier) # If default configuration not initialized, initialize client connection with IAM metadata if not CLIENT_CACHE.has_key(_get_cache_key()) and aws_conf.has_iam_metadata(): CLIENT_CACHE[_get_cache_key()] = _make_client('default')
def from_config(cls, conf): access_key_id = conf.ACCESS_KEY_ID.get() secret_access_key = conf.SECRET_ACCESS_KEY.get() security_token = conf.SECURITY_TOKEN.get() env_cred_allowed = conf.ALLOW_ENVIRONMENT_CREDENTIALS.get() if None in (access_key_id, secret_access_key ) and not env_cred_allowed and not has_iam_metadata(): raise ValueError( 'Can\'t create AWS client, credential is not configured') return cls(aws_access_key_id=access_key_id, aws_secret_access_key=secret_access_key, aws_security_token=security_token, region=conf.REGION.get())
def from_config(cls, conf): access_key_id = conf.ACCESS_KEY_ID.get() secret_access_key = conf.SECRET_ACCESS_KEY.get() security_token = conf.SECURITY_TOKEN.get() env_cred_allowed = conf.ALLOW_ENVIRONMENT_CREDENTIALS.get() if None in (access_key_id, secret_access_key) and not env_cred_allowed and not has_iam_metadata(): raise ValueError('Can\'t create AWS client, credential is not configured') return cls( aws_access_key_id=access_key_id, aws_secret_access_key=secret_access_key, aws_security_token=security_token, region=conf.REGION.get(), proxy_address=conf.PROXY_ADDRESS.get(), proxy_port=conf.PROXY_PORT.get(), calling_format=conf.CALLING_FORMAT.get(), is_secure=conf.IS_SECURE.get() )
def from_config(cls, conf): access_key_id = conf.ACCESS_KEY_ID.get() secret_access_key = conf.SECRET_ACCESS_KEY.get() security_token = conf.SECURITY_TOKEN.get() env_cred_allowed = conf.ALLOW_ENVIRONMENT_CREDENTIALS.get() if None in (access_key_id, secret_access_key ) and not env_cred_allowed and not has_iam_metadata(): raise ValueError( 'Can\'t create AWS client, credential is not configured') return cls(aws_access_key_id=access_key_id, aws_secret_access_key=secret_access_key, aws_security_token=security_token, region=conf.REGION.get(), proxy_address=conf.PROXY_ADDRESS.get(), proxy_port=conf.PROXY_PORT.get(), calling_format=conf.CALLING_FORMAT.get(), is_secure=conf.IS_SECURE.get())