Package: boto-endpoint-url-shim
Boto Endpoint URL shimConfigureboto3andbotocoreendpoint URL via environment variables or
shared configuration file.This project is motivated by the yet-to-be-mergedboto3PR#2746, and
follows theaws-sdkproposal #230(updated for commitb912470).Quick startTo use the main interface described inproposal #230, set up either
service-specific environment variables orendpoint_urlin a service-specific
sub-section of the shared configuration file and set up the proposed endpoint
URL resolution.importboto_endpoint_url_shimimportboto3boto_endpoint_url_shim.proposed_endpoint_url_resolution()s3=boto3.resource("s3")# uses custom endpoint URLEndpoint URL resolution orderThe core functionality of this package is exposed through theproposed_endpoint_url_resolutionfunction which sets up the proposed endpoint
resolution order ofproposal #230:endpoint_urlkeyword argumentimportboto3boto3.resource("s3",endpoint_url="http://localhost:8088")configuration via service-specific environment variableconfiguration via global environment variableconfiguration via service sub-sections of the shared configuration fileconfiguration via global parameter in shared configuration filefallback to default endpoint determination ofbotocoreThe first truthy value provided by one of the steps will be used as endpoint URL
for the clients and resources, otherwise the resolution continues to the next
step.Any other endpoint URL resolution order, can be set up using thecustom_endpoint_url_resolutionfunction, with passing the configuration
functions as variadic arguments in the order they should be used.boto_endpoint_url_shim.custom_endpoint_url_resolution(step1,step2,...,stepN)Endpoint URL configuration optionsProposed interfaceTheproposal #230includes four main methods for endpoint resolution, two
service-specific endpoint configuration and two global.This main interface can be set up usingproposed_endpoint_url_resolution().Configuration via service-specific environment variableImplementation:read_service_env_var.Read the configuration from environment variablesAWS_<SERVICE_ID>_ENDPOINT_URLin which<SERVICE_ID>is theServiceIdof
the of a specific service as defined in itsServiceModel, transformed with
spaces replaced with underscores and letters upper-cased.AWS_ENDPOINT_URL_DYNAMODB=http://localhost:8024AWS_ENDPOINT_URL_ELASTIC_BEANSTALK=http://localhost:8053Configuration via global environment variableImplementation:read_global_env_var.Read the configuration from the global environment variableAWS_ENDPOINT_URLand use this endpoint URL for all services.AWS_ENDPOINT_URL=http://localhost:8099Configuration via service sub-sections of the shared configuration fileImplementation:read_service_config_file.Read the configuration from the shared configuration file, as theendpoint_urlparameter under theservice_idsub-section in theservicesdefinition. As
above,service_idis a transform for theServiceIdwith spaces replaced with
underscores and letters lower-cased. Theservicesdefinition to use is
referenced by key in the profile via theservicesparameter.[services local-db-eb]dynamodb=endpoint_url=http://localhost:8024elastic_beanstalk=endpoint_url=http://localhost:8053[profile testing]services=local-db-ebConfiguration via global parameter in shared configuration fileImplementation:read_global_config_file.Read the configuration from theendpoint_urlparameter at the top level of aservicesdefinition and use this endpoint URL for all services. Theservicesdefinition to use is referenced by key in the profile via theservicesparameter.[services local-services]endpoint_url=http://localhost:8099[profile testing]services=local-servicesAlternative interfacesSeveral more interfaces are included in theproposal #230, they have been
implemented as functions in this package.As a convenience, the proposed interface above followed by the global
environment variable and global configuration file methods can be set up usingglobal_endpoint_url_resolution.Configuration via mapping in global environment variableImplementation:read_mapping_env_var.Read the configuration from the global environment variableAWS_ENDPOINT_URL,
containing a mapping of lower-caseservice_ids to endpoint URLs.AWS_ENDPOINT_URL="dynamodb=http://localhost:8024,elastic_beanstalk=http://localhost:8053"NB.The mapping is loaded once on the first use of the function and cached
for later uses.Configuration via named top level parameters in shared configuration fileImplementation:read_named_top_level_config_file.Read the configuration from the<service_id>_endpoint_urlparameter at the top
level of a profile, with<service_id>the lower-caseservice_id.[profile local-services]dynamodb_endpoint_url=http://localhost:8024elastic_beanstalk_endpoint_url=http://localhost:8053Custom interfaceUsers are free to define and use functions to obtain the endpoint URL of a
service.The custom functions must adhere to the following signature:deffunc(session:botocore.session.Session,service_id:str)->str|None:...with:sessionabotocore.session.Sessionservice_idtheServiceIdof a specific service as defined in itsServiceModel, transformed with spaces replaced with underscores and letters
lower-casedreturnsastr | Noneeither the endpoint URL or None to continue to the
next step in the resolution chain