# AWS CLI v2 plugin: send an exe.dev VM token with every S3 request, so the # AWS CLI can reach an S3 API that stays private behind exe.dev login. # # The token goes in X-Exedev-Authorization, which exe.dev's proxy reads and # strips. It is added after the request is signed, so it isn't part of the # SigV4 signature. Set EXEDEV_TOKEN to the token (from # `ssh exe.dev ssh-key generate-api-key --vm=`); without it, the plugin # does nothing. # # ~/.aws/config: # [plugins] # cli_legacy_plugin_path = /path/to/the/directory/with/this/file # exedev_token = exedev_token # # and, in the profile's s3 settings, preferred_transfer_client = classic: # the CRT transfer client used by `aws s3 cp` and `sync` doesn't send # headers added here. import os def _add_token(request, **kwargs): token = os.environ.get("EXEDEV_TOKEN") if token: request.headers["X-Exedev-Authorization"] = "Bearer " + token def awscli_initialize(cli): cli.register("before-send.s3", _add_token)