assay.aws.sigv4
AWS Signature V4 request signing. Generates Authorization headers for authenticated AWS API calls.
Parameterized for any AWS service (ecr, ec2, sts, iam, etc.).
Signing
-
sigv4.sign(opts)→ headers — Sign an AWS API request. Returns a headers table includingauthorization,x-amz-date,x-amz-content-sha256, and any custom headers passed in. Theoptstable:Key Type Required Description access_keystring Yes AWS access key ID secret_keystring Yes AWS secret access key session_tokenstring No AWS session token (for STS credentials) servicestring Yes AWS service name (e.g. "ecr")regionstring Yes AWS region (e.g. "us-east-1")methodstring No HTTP method (default "GET")hoststring Yes API hostname pathstring No Request path (default "/")querystring No Query string payloadstring No Request body (default "")headerstable No Additional headers to include and sign
Example:
local sigv4 = require("assay.aws.sigv4")
local headers = sigv4.sign({
access_key = "AKIA...",
secret_key = "wJalr...",
service = "ecr",
region = "us-east-1",
method = "POST",
host = "api.ecr.us-east-1.amazonaws.com",
payload = "{}",
headers = {
["content-type"] = "application/x-amz-json-1.1",
["x-amz-target"] = "AmazonEC2ContainerRegistry_V20150921.GetAuthorizationToken",
},
})
-- Use headers with http.post/get