resource_tracker.s3_upload
#
Upload data to S3 using temporary STS credentials.
Minimal, zero-dependency implementation (stdlib only) of AWS Signature V4
authenticated PUT requests, designed for uploading gzipped CSV metric
files via the Sentinel API's temporary STS credentials.
Functions:
| Name | Description |
|---|---|
put_bytes_with_sts |
Upload raw bytes to S3 using temporary STS credentials. |
put_object_with_sts |
Upload a local file to S3 using temporary STS credentials. |
put_bytes_with_sts
#
put_bytes_with_sts(*, s3_uri, body, access_key, secret_key, session_token, region=None, timeout=DEFAULT_UPLOAD_TIMEOUT)
Upload raw bytes to S3 using temporary STS credentials.
This is the core upload primitive used by the streaming module to push gzipped CSV data without writing a temporary file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s3_uri
|
str
|
Target S3 URI ( |
required |
body
|
bytes
|
Raw bytes to upload. |
required |
access_key
|
str
|
AWS STS access key ID. |
required |
secret_key
|
str
|
AWS STS secret access key. |
required |
session_token
|
str
|
AWS STS session token. |
required |
region
|
str | None
|
AWS region of the target bucket. |
None
|
timeout
|
int
|
HTTP request timeout in seconds. |
DEFAULT_UPLOAD_TIMEOUT
|
Returns:
| Type | Description |
|---|---|
str
|
The S3 URI that was written to (same as s3_uri). |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the upload fails. |
Source code in resource_tracker/s3_upload.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
put_object_with_sts
#
put_object_with_sts(*, s3_uri, file_path, access_key, secret_key, session_token, region, timeout=DEFAULT_UPLOAD_TIMEOUT)
Upload a local file to S3 using temporary STS credentials.
Convenience wrapper around :func:put_bytes_with_sts that reads the file
contents first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s3_uri
|
str
|
Target S3 URI ( |
required |
file_path
|
Path
|
Path to the local file to upload. |
required |
access_key
|
str
|
AWS STS access key ID. |
required |
secret_key
|
str
|
AWS STS secret access key. |
required |
session_token
|
str
|
AWS STS session token. |
required |
region
|
str
|
AWS region of the target bucket. |
required |
timeout
|
int
|
HTTP request timeout in seconds. |
DEFAULT_UPLOAD_TIMEOUT
|
Returns:
| Type | Description |
|---|---|
str
|
The S3 URI that was written to (same as s3_uri). |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the upload fails. |