Context Vars
aws.access-key-idaws.secret-access-keyaws.session-tokenaws.regionaws.endpoint
Values
DEFAULT_REGION
DEFAULT_REGION: Str "us-east-1"
Functions
get-credentials of ::aws::core/get-credentials
fn (): Credentials
Get AWS credentials from context (aws.access-key-id, aws.secret-access-key, aws.session-token). Returns an Err naming the variables when they aren't set.
Example
creds ::aws::core/get-credentials()
creds.access_key_id
aws.access-key-id, aws.secret-access-key, aws.session-token
get-region of ::aws::core/get-region
fn (): Str
Get AWS region from context (aws.region). Defaults to us-east-1 if not
set. An Err when it isn't a plain region name; see check-region.
Example
region ::aws::core/get-region()
::aws::core/sqs-endpoint(region)
aws.region, aws.endpoint
resolve of ::aws::core/resolve
fn (opts: Map?): Map
fn (): Map
Settings for one call: opts over the context variables, over the defaults.
Returns {credentials, region, endpoint?, transport?, path-style?}, or an Err
when no credentials are available.
opts keys, all optional:
access-key-id,secret-access-key,session-token: per-call credentials. When they are given the context credentials are ignored for that call. An access key or secret that is present but null or blank is an Err: leave it out instead. A null or blanksession-tokenmeans no session token.credentials: a readyCredentialsvalue, instead of the three keys.region: signing region and endpoint region. It goes into a hostname, so it must be a plain AWS region name likeus-east-1, or an Err comes back. With a custom endpoint it only signs, so a store's own name likeautois fine.endpoint: base URL replacing the AWS endpoint (LocalStack, a VPC endpoint, an S3-compatible store). It needs credentials in the same opts, so the project's access key id and signatures never go to a host set per call. Theaws.endpointcontext variable sets one for the project, used with any credentials.path-style: aws-s3 only, see its README.transport: a function taking the signedHttpRequestand returning anHttpResponse, used instead of the network. For tests.
Per-call credentials stay in the call. Nothing is written to ctx, so parallel flows and tenants never share them, and they are masked in the run's call records.
Example
resolved ::aws::core/resolve({access-key-id: "AKIAEXAMPLE", secret-access-key: "secret", region: "eu-west-1"})
resolved.region // "eu-west-1"
aws.access-key-id, aws.secret-access-key, aws.session-token, aws.region, aws.endpoint
sign-request of ::aws::core/sign-request
fn (method: Str, url: Str, region: Str, service: Str, credentials: Credentials, headers: Map, payload: Str | Bytes | Null): Map
fn (method: Str, url: Str, region: Str, service: Str, credentials: Credentials, headers: Map, payload: Str | Bytes | Null, amz-date: Str): Map
Sign a request using AWS Signature V4. Returns headers map with Authorization header.
url is the URL as it will be sent, with path segments and query values already
encoded (uri-encode, uri-encode-path). The Host header always comes from url:
the HTTP client sends that host whatever the headers say. The arity with amz-date
(YYYYMMDD'T'HHMMSS'Z') signs at that time instead of now. An Err when the URL's host or
the region isn't plain; see check-signing-target.
Example
creds ::aws::core/get-credentials()
headers ::aws::core/sign-request("GET", "https://sqs.us-east-1.amazonaws.com/", "us-east-1", "sqs", creds, {}, null)
// Signed headers, ready to send
headers.Authorization
headers.x-amz-date
Types
AwsError of ::aws::core/AwsError
AwsError type {
status: Int,
code: Str?,
message: Str?,
request_id: Str?,
body: Any
}
Error response from an AWS service request.
Credentials of ::aws::core/Credentials
Credentials type {
access_key_id: Str,
secret_access_key: Str,
session_token: Str?
}
AWS credentials used for signing requests.
Region of ::aws::core/Region
Region type {
name: Str
}
AWS region identifier.