Values

AWS_REGION_PATTERN

AWS_REGION_PATTERN: Str "^[a-z]{2,}(-[a-z]+)+-[0-9]+$"

BUCKET_PATTERN

BUCKET_PATTERN: Str "^[A-Za-z0-9][A-Za-z0-9._-]{1,253}[A-Za-z0-9]$"

CREDENTIAL_OPTS

CREDENTIAL_OPTS: Vec [
  "credentials",
  "access-key-id",
  "secret-access-key"
]

HOST_PATTERN

HOST_PATTERN: Str "^([A-Za-z0-9._-]+|\\[[0-9A-Fa-f:.]+\\])(:[0-9]+)?$"

MISSING_CREDENTIALS

MISSING_CREDENTIALS: Str "aws: credentials are not set. Set aws.access-key-id and aws.secret-access-key in Context Variables, or pass {access-key-id: ..., secret-access-key: ...} in the call's opts."

STORE_REGION_PATTERN

STORE_REGION_PATTERN: Str "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$"

UNSAFE_URL_PATTERN

UNSAFE_URL_PATTERN: Str "[\\x00-\\x1F\\x7F\\\\]"

VIRTUAL_HOST_BUCKET_PATTERN

VIRTUAL_HOST_BUCKET_PATTERN: Str "^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$"

Functions

bedrock-endpoint

fn (region: Str): Str

Get the Bedrock control plane endpoint URL for a given region

Example

::aws::core/bedrock-endpoint("us-east-1")  // "https://bedrock.us-east-1.amazonaws.com"

bedrock-runtime-endpoint

fn (region: Str): Str

Get the Bedrock runtime endpoint URL for model invocation

Example

::aws::core/bedrock-runtime-endpoint("us-east-1")  // "https://bedrock-runtime.us-east-1.amazonaws.com"

canonical-headers

fn (headers: Map): Str

Create canonical headers string for AWS Signature V4: lowercase names sorted by name, values trimmed with runs of spaces collapsed.

Example

::aws::core/canonical-headers({Host: "example.com", "X-Amz-Date": "20261109T120000Z"})
// "host:example.com\nx-amz-date:20261109T120000Z\n"

canonical-uri

fn (path: Str, service: Str): Str

The canonical URI of a request path. S3 signs the path as sent, single-encoded. Every other service encodes the sent path again, so a path segment a%3Ab signs as a%253Ab. / is never encoded in either case.

Example

::aws::core/canonical-uri("/a%3Ab", "s3")  // "/a%3Ab"
::aws::core/canonical-uri("/a%3Ab", "sqs")  // "/a%253Ab"

check-bucket

fn (bucket: Any): Any

bucket when it is a valid S3 bucket name (3 to 255 letters, numbers, dots, hyphens and underscores, starting and ending with a letter or number, no ..), else an Err that doesn't echo the value. Dotted names are valid; see is-virtual-host-bucket.

Example

::aws::core/check-bucket("my.dotted.bucket")  // "my.dotted.bucket"
is-err(::aws::core/check-bucket("a..b"))  // true

check-region

fn (region: Any, source: Str, has-endpoint: Bool): Any

region when it is safe to use, else an Err naming source and not echoing the value. Without a custom endpoint it goes into an AWS hostname and must be a plain AWS region name like us-east-1. With one (has-endpoint) it only signs, so a store's own name like auto passes, but still nothing that could leave its place.

Example

::aws::core/check-region("us-east-1", "opts.region", false)  // "us-east-1"
::aws::core/check-region("auto", "opts.region", true)  // "auto"
is-err(::aws::core/check-region("auto", "opts.region", false))  // true

check-signing-target

fn (url: Str, region: Any): Any

Null when url and region are safe to sign for: a plain host with no user info, no backslash or control characters in the URL, and a region that stays one segment of the signing scope. Else an Err that doesn't echo them.

Example

::aws::core/check-signing-target("https://s3.us-east-1.amazonaws.com/my-bucket", "us-east-1")  // null
is-err(::aws::core/check-signing-target("https://user@evil.example/", "us-east-1"))  // true

create-canonical-request

fn (method: Str, path: Str, query: Str, headers-str: Str, signed-headers-str: Str, payload-hash: Str): Str

Create AWS Signature V4 canonical request string

Example

::aws::core/create-canonical-request("GET", "/", "a=1", "host:example.com\n", "host", "UNSIGNED-PAYLOAD")
// "GET\n/\na=1\nhost:example.com\n\nhost\nUNSIGNED-PAYLOAD"

create-string-to-sign

fn (amz-date: Str, date-stamp: Str, region: Str, service: Str, canonical-request-hash: Str): Str

Create AWS Signature V4 string to sign

Example

::aws::core/create-string-to-sign("20261109T120000Z", "20261109", "us-east-1", "s3", "abc123")
// "AWS4-HMAC-SHA256\n20261109T120000Z\n20261109/us-east-1/s3/aws4_request\nabc123"

derive-signing-key

fn (secret_key: Str, date_stamp: Str, region: Str, service: Str): Bytes

Derive AWS signing key using HMAC-SHA256 chain

Example

key ::aws::core/derive-signing-key(::hot::ctx/get("aws.secret-access-key"), "20261109", "us-east-1", "s3")

// Bytes, ready for hmac-sha256 over the string to sign
::hot::hmac/hmac-sha256(key, "string to sign")

dynamodb-endpoint

fn (region: Str): Str

Get the DynamoDB endpoint URL for a given region

Example

::aws::core/dynamodb-endpoint("us-east-1")  // "https://dynamodb.us-east-1.amazonaws.com"

encode-query-param

fn (param: Str): Str

URL-encode the name and value of a query parameter, keeping existing %XX escapes. A parameter with no = gets an empty value (uploads becomes uploads=).

Example

::aws::core/encode-query-param("prefix=a b")  // "prefix=a%20b"
::aws::core/encode-query-param("uploads")  // "uploads="

error-fields

fn (body: Any): Map

The code, message and request_id an AWS error body carries, from JSON (__type, code, message) or XML (<Code>, <Message>, <RequestId>). A field the body doesn't carry is missing. Exposed for testing.

Example

fields ::aws::core/error-fields({__type: "ThrottlingException", message: "Rate exceeded"})
fields.code  // "ThrottlingException"
fields.message  // "Rate exceeded"

::aws::core/error-fields("<Error><Code>NoSuchKey</Code></Error>").code  // "NoSuchKey"

get-amz-date

fn (): Str

Get current UTC timestamp in AWS format (YYYYMMDD'T'HHMMSS'Z')

Example

amz-date ::aws::core/get-amz-date()

// Sign a request at this exact time
::aws::core/sign-request("GET", "https://sqs.us-east-1.amazonaws.com/", "us-east-1", "sqs", ::aws::core/get-credentials(), {}, null, amz-date)

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
Context Vars: aws.access-key-id, aws.secret-access-key, aws.session-token

get-date-stamp

fn (): Str

Get current UTC date in AWS format (YYYYMMDD)

Example

date-stamp ::aws::core/get-date-stamp()
`${date-stamp}/us-east-1/s3/aws4_request`

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)
Context Vars: aws.region, aws.endpoint

is-virtual-host-bucket

fn (bucket: Str): Bool

True when a bucket can be a hostname label: 3 to 63 lowercase letters, numbers and hyphens. Dotted names don't match the TLS wildcard certificate, and uppercase legacy names don't survive a hostname, so those use path-style.

Example

::aws::core/is-virtual-host-bucket("my-bucket")  // true
::aws::core/is-virtual-host-bucket("my.dotted.bucket")  // false

lambda-endpoint

fn (region: Str): Str

Get the Lambda endpoint URL for a given region

Example

::aws::core/lambda-endpoint("us-east-1")  // "https://lambda.us-east-1.amazonaws.com"

normalize-encoding

fn (s: Str): Str

URI encode s, keeping valid %XX escapes (in uppercase) so already-encoded input isn't encoded twice. A % that doesn't start an escape becomes %25.

Example

::aws::core/normalize-encoding("a%2fb c")  // "a%2Fb%20c"
::aws::core/normalize-encoding("100%")  // "100%25"

opt-str

fn (value: Any): Str?

Str(value), keeping null as null. For JSON fields that AWS sends as numbers (epoch dates) and the response types declare Str?.

Example

::aws::core/opt-str(1700000000)  // "1700000000"
::aws::core/opt-str(null)  // null

parse-int

fn (value: Any): Int?

A whole non-negative number from a header or XML text, or null when it is absent or isn't one. Never fails.

Example

::aws::core/parse-int("1024")  // 1024
::aws::core/parse-int("12.5")  // null
::aws::core/parse-int(null)  // null

parse-json-body

fn (response: Result): Any

Return response as an HttpResponse, with a JSON body parsed when the runtime left it as Bytes (application/x-amz-json-1.0 and -1.1 responses). A transport in opts can return a plain Map, so the result is typed here for AwsError(response) to run its arrow.

Example

response ::hot::http/HttpResponse({
  status: 200,
  headers: {"content-type": "application/x-amz-json-1.0"},
  body: Bytes("{\"QueueUrl\":\"https://example.test/q\"}")
})
::aws::core/parse-json-body(response).body  // {QueueUrl: "https://example.test/q"}

parse-url

fn (url: Str): Map

Parse a URL into components: {host, path, query}

Example

parts ::aws::core/parse-url("https://s3.us-east-1.amazonaws.com:443/my/key?list-type=2")
parts.host  // "s3.us-east-1.amazonaws.com"
parts.path  // "/my/key"
parts.query  // "list-type=2"

regional-url

fn (prefix: Str, region: Str): Str

https://<prefix>.<region>.amazonaws.com, or an Err when region isn't a plain AWS region name.

Example

::aws::core/regional-url("bedrock-runtime", "us-west-2")  // "https://bedrock-runtime.us-west-2.amazonaws.com"
is-err(::aws::core/regional-url("sqs", "not a region"))  // true

replace-all-char

fn (s: Str, from: Str, to: Str): Str

Replace all occurrences of char in string

Example

::aws::core/replace-all-char("a.b.c", ".", "-")  // "a-b-c"

request

fn (method: Str, url: Str, service: Str, region: Str, headers: Map, body: Str | Bytes): ::hot::http/HttpResponse
fn (method: Str, url: Str, service: Str, region: Str, headers: Map, body: Str | Bytes, credentials: Credentials): ::hot::http/HttpResponse
fn (method: Str, url: Str, service: Str, region: Str, headers: Map, body: Str | Bytes, opts: Map): ::hot::http/HttpResponse

Make an authenticated request to an AWS service endpoint.

Handles credential retrieval and Signature V4 signing automatically. Used internally by all AWS service packages.

Example

region ::aws::core/get-region()
url `${::aws::core/sqs-endpoint(region)}/`
headers {"Content-Type": "application/x-amz-json-1.0", "X-Amz-Target": "AmazonSQS.ListQueues"}

response ::aws::core/request("POST", url, "sqs", region, headers, "{}")
response.status

// With another tenant's credentials
tenant ::aws::core/request("POST", url, "sqs", region, headers, "{}", {
  access-key-id: ::hot::ctx/get("tenant.aws-access-key-id"),
  secret-access-key: ::hot::ctx/get("tenant.aws-secret-access-key")
})
tenant.body

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 blank session-token means no session token.
  • credentials: a ready Credentials value, 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 like us-east-1, or an Err comes back. With a custom endpoint it only signs, so a store's own name like auto is 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. The aws.endpoint context variable sets one for the project, used with any credentials.
  • path-style: aws-s3 only, see its README.
  • transport: a function taking the signed HttpRequest and returning an HttpResponse, 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"
Context Vars: aws.access-key-id, aws.secret-access-key, aws.session-token, aws.region, aws.endpoint

resolve-from

fn (opts: Map?, ctx-values: Map): Map

The one resolver, pure: settings for a call from opts first, then ctx-values (a Map of context variables), then defaults. Returns {credentials, region, endpoint?, transport?, path-style?}, or an Err when credentials are missing or only partly given, or when access-key-id, secret-access-key or credentials is present in opts but null or blank (naming the key; it never falls back to context), when opts sets endpoint without credentials of its own, or when the region, from either place, isn't a plain region name (check-region). Credentials in opts mean the context credentials, session token included, are ignored for the call. Nothing is written to ctx. Exposed for testing; resolve feeds it the context.

Example

settings ::aws::core/resolve-from({region: "eu-west-1"}, {
  "aws.access-key-id": ::hot::ctx/get("aws.access-key-id"),
  "aws.secret-access-key": ::hot::ctx/get("aws.secret-access-key")
})
settings.region
settings.credentials.access_key_id

response-header

fn (response: Any, name: Str): Str?

Read a header from an HTTP response by name, in any case. HTTP responses carry lowercase header names.

Example

response {headers: {"content-type": "application/json"}}
::aws::core/response-header(response, "Content-Type")  // "application/json"
::aws::core/response-header(response, "ETag")  // null

s3-endpoint

fn (bucket: Str, region: Str): Str

Get the S3 URL of a bucket in a region: virtual-hosted, https://<bucket>.s3.<region>.amazonaws.com, the standard form in every region including us-east-1. A bucket that can't be a hostname label (dots, legacy uppercase names) gets the path-style form, https://s3.<region>.amazonaws.com/<bucket>. An Err when the bucket or region isn't valid.

Example

::aws::core/s3-endpoint("my-bucket", "us-east-1")  // "https://my-bucket.s3.us-east-1.amazonaws.com"
::aws::core/s3-endpoint("my.dotted.bucket", "us-east-1")  // "https://s3.us-east-1.amazonaws.com/my.dotted.bucket"

secrets-manager-endpoint

fn (region: Str): Str

Get the Secrets Manager endpoint URL for a given region

Example

::aws::core/secrets-manager-endpoint("us-east-1")  // "https://secretsmanager.us-east-1.amazonaws.com"

send-signed

fn (method: Str, url: Str, service: Str, resolved: Map, headers: Map, body: Str | Bytes): ::hot::http/HttpResponse

Sign a request with resolved (from resolve) and send it, through resolved.transport when set. The Host header comes from url. JSON bodies are parsed whatever the JSON content type. Used by all AWS service packages.

Example

resolved ::aws::core/resolve({region: "eu-west-1"})
url `${::aws::core/service-url(resolved, "sqs")}/`
headers {"Content-Type": "application/x-amz-json-1.0", "X-Amz-Target": "AmazonSQS.ListQueues"}

response ::aws::core/send-signed("POST", url, "sqs", resolved, headers, "{}")
response.status
response.body.QueueUrls

service-url

fn (resolved: Map, prefix: Str): Str

Base URL (no trailing slash) for a service host prefix such as sqs or bedrock-runtime: resolved.endpoint when set, else https://<prefix>.<region>.amazonaws.com.

Example

::aws::core/service-url({region: "eu-west-1"}, "sqs")  // "https://sqs.eu-west-1.amazonaws.com"
::aws::core/service-url({region: "us-east-1", endpoint: "http://localhost:4566"}, "sqs")  // "http://localhost:4566"

ses-endpoint

fn (region: Str): Str

Get the SES endpoint URL for a given region

Example

::aws::core/ses-endpoint("us-east-1")  // "https://email.us-east-1.amazonaws.com"

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

sign-url

fn (method: Str, url: Str, region: Str, service: Str, credentials: Credentials, expires_in: Int): Str
fn (method: Str, url: Str, region: Str, service: Str, credentials: Credentials, expires_in: Int, amz-date: Str): Str
fn (method: Str, url: Str, region: Str, service: Str, credentials: Credentials): Str

Sign a URL using AWS Signature V4 query string signing.

This is used for presigned URLs where the signature goes in the query string instead of headers. The returned URL can be used by anyone without credentials.

Parameters:

  • method: HTTP method (GET, PUT, etc.)
  • url: Base URL to sign
  • region: AWS region
  • service: AWS service name (s3, etc.)
  • credentials: AWS credentials
  • expires_in: URL expiration time in seconds (default 3600 = 1 hour, max 604800 = 7 days)
  • amz-date: signing time (YYYYMMDD'T'HHMMSS'Z'), default now

An Err when the URL's host or the region isn't plain; see check-signing-target.

Example

creds ::aws::core/get-credentials()

// Anyone holding this URL can download the object for 15 minutes
url ::aws::core/sign-url("GET", "https://my-bucket.s3.us-east-1.amazonaws.com/report.pdf", "us-east-1", "s3", creds, 900)
::hot::http/get(url).status

signature-for

fn (canonical-request: Str, amz-date: Str, region: Str, service: Str, secret-access-key: Str): Str

The hex SigV4 signature of a canonical request at amz-date, in region and service.

Example

canonical ::aws::core/create-canonical-request("GET", "/", "", "host:sqs.us-east-1.amazonaws.com\n", "host", ::hot::hash/sha256(""))
::aws::core/signature-for(canonical, "20261109T120000Z", "us-east-1", "sqs", ::hot::ctx/get("aws.secret-access-key"))

signed-headers

fn (headers: Map): Str

Create signed headers list (semicolon-separated lowercase header names)

Example

::aws::core/signed-headers({Host: "example.com", "X-Amz-Date": "20261109T120000Z"})  // "host;x-amz-date"

sort-query-params

fn (query: Str?): Str

The canonical query string: each name and value URL-encoded, sorted by encoded name, then by encoded value.

Example

::aws::core/sort-query-params("b=2&a=1")  // "a=1&b=2"
::aws::core/sort-query-params(null)  // ""

sqs-endpoint

fn (region: Str): Str

Get the SQS endpoint URL for a given region

Example

::aws::core/sqs-endpoint("us-east-1")  // "https://sqs.us-east-1.amazonaws.com"

uri-encode

fn (s: Str): Str

URI encode a string for an AWS request: every byte except A-Z a-z 0-9 - _ . ~ becomes %XX (uppercase hex, UTF-8), / and % included.

Example

::aws::core/uri-encode("a b/c")  // "a%20b%2Fc"

uri-encode-path

fn (path: Str): Str

URI encode a path or S3 object key for a request URL: uri-encode on each /-separated segment.

Example

::aws::core/uri-encode-path("my folder/a+b.txt")  // "my%20folder/a%2Bb.txt"

url-encode-path

fn (path: Str): Str

URL-encode a URI path once for an AWS request, keeping / and existing %XX escapes. This is the S3 canonical URI; see canonical-uri for other services.

Example

::aws::core/url-encode-path("/a b/c%2Fd")  // "/a%20b/c%2Fd"

url-encode-value

fn (value: Str): Str

URL-encode a value for an AWS query string. The same as uri-encode.

Example

::aws::core/url-encode-value("a=b")  // "a%3Db"

wire-path

fn (path: Str): Str

The path as the HTTP client sends it: spaces, quotes, angle brackets, braces, backticks and non-ASCII characters escaped, everything else (existing %XX included) unchanged.

Example

::aws::core/wire-path("/a b/c:d")  // "/a%20b/c:d"

Types

AwsError

AwsError type {
    status: Int,
    code: Str?,
    message: Str?,
    request_id: Str?,
    body: Any
}

Error response from an AWS service request.

Credentials

Credentials type {
    access_key_id: Str,
    secret_access_key: Str,
    session_token: Str?
}

AWS credentials used for signing requests.

Region

Region type {
    name: Str
}

AWS region identifier.