Context Vars

Optional
  • aws.access-key-id
  • aws.secret-access-key
  • aws.session-token
  • aws.region
  • aws.endpoint

Values

DEFAULT_REGION

DEFAULT_REGION: Str "us-east-1"

Functions

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

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

resolve alias 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 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

sign-request alias 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 alias 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 alias of ::aws::core/Credentials

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

AWS credentials used for signing requests.

Region alias of ::aws::core/Region

Region type {
    name: Str
}

AWS region identifier.