Export AWS Access Credentials If Needed #194
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
Workaround for #192 so that we don't have to change anything in
titiler-pgstac
Changes
VEDA_RASTER_EXPORT_ASSUME_ROLE_CREDS_AS_ENVS
toAPISettings
VEDA_RASTER_EXPORT_ASSUME_ROLE_CREDS_AS_ENVS=True
as defaults to UAH dev/staging env secretsVEDA_RASTER_EXPORT_ASSUME_ROLE_CREDS_AS_ENVS
inget_gdal_config
to know if it should export the assume-role creds. The reason this check exists is b/c we know Lambdas already injectAWS_*
os env vars and this is a VERY hacky solution so we don't want to get used to these things being exported and also want to have a trail of why we did this for future usWhy It Works
rasterio.Env
uses thread local which means it inits a new empty context per threadSo by the the time
CustomSTACReader
is retrieving the image in this line it's running inside of multiple threads. Each thread'sCustomSTACReader
triggers self.ctx (which is justrasterio.Env
) and it has to start all over again with empty context when accessing the image.However, because we now export the AWS credentials into os env vars the nested
rasterio.Env
lookup will hit this check and re-init a new session: https://github.com/rasterio/rasterio/blob/main/rasterio/env.py#L204-L205