On this page:
1.1 Configuration
sqs-api-version
sqs-host
sqs-auth-version
signature-method
sqs-ns
1.2 AWS Authentication
1.2.1 AWS Credentials
current-aws-credential
default-cred-path
Base  Credential
Session  Credential
Aws  Credential
load-credential
set-aws-credential!
1.3 STS
get-session-token
1.4 S3 API
1.5 S3 URI
s3-uri-path->prefix
1.6 S3 Bucket Types
Buckets
Owner
Bucket
S3Response
1.6.1 S3 Bucket API
list-buckets
create-bucket
delete-bucket
1.6.2 S3 Object Types
Object
Objects
1.6.3 S3 Object API
list-bucket-objects
put-object
put-file-object
delete-object
1.7 SQS
list-queues
send-message
Attribute  Name
receive-message
1.8 Dynamo  DB
1.8.1 Table Types
Create  Table  Resp
Throughput
Table  Status
List  Tables  Resp
1.8.2 Table API
create-table
delete-table
describe-table
list-tables

1 SQS - Simple Queue Service

1.1 Configuration

 (require "../aws/sqs/config.rkt") package: wrap
Currently SQS configuration is hardcoded in a "config.rkt" file and reviewed and modified to suit.

value

sqs-api-version : String

The version of the SQS API to use. This should be changed as Amazon releases new versions of the SQS API.

value

sqs-host : String

The SQS host to which all SQS commands are sent. This should be changed to match your desired AWS facility. Ideally this should be say a parameterizable configuration, but for now is a hard code.

value

sqs-auth-version : String

The version of authentication that SQS is using. For current SQS api, "2011-10-01" version "2" authentication is used. This value is sent as part of the request and should in general not be changed.

value

signature-method : String

The signing method used to create the authentication header. This value is also sent as part of the request. For the current SQS api, "2011-10-01" HMAC-SHA256 is used and should in general not be changed.

value

sqs-ns : String

The namespace used in the XML contained in payload of an SQS HTTP response.

1.2 AWS Authentication

AWS uses a set of credentials which include a private key or a private session key to perform an signature of the request and then sending the signature as part of the request.

Currently this library expects and requires that a valid set of credentials is loadable from "~/.awscreds.sexp".

1.2.1 AWS Credentials

 (require aws/credential)

procedure

(current-aws-credential)  (Parameterof AwsCredential)

A parameterization containing the credentials used by this library authorizing an AWS call. An initial set of credential information is loaded during module initialization from a given path. Module initialization will fail if the expected credential file is not found.

value

default-cred-path : String

Currently defined to be the path "~/.awscreds.sexp". It is an error if this file does not exist.

At a minimum this file must contain the AWS account access key and secret key in the following sexp alist form.

((access-key . "ACCESSKEY")
 (secret-key . "secretkey"))

struct

(struct BaseCredential (access-key secret-key)
    #:transparent)
  access-key : String
  secret-key : String
An abstract base structure which contains the minimal set of credential information an AWS account access and secret key.

struct

(struct SessionCredential BaseCredential (token expiration)
    #:transparent)
  token : String
  expiration : Time
Contains an AWS STS (Security Token Service) issued token and its associated expiration time stamp. Some AWS services such as DynamoDB require session authorization. A valid session is token is implicitly maintained by this AWS library.

struct

(struct AwsCredential BaseCredential (account-id
    associatate-tag
    session)
    #:mutable
    #:transparent)
  account-id : String
  associatate-tag : String
  session : (Option SessionCredential)
Extends "BaseCredential" and contains the full set of AWS credentialing information. The "account-id" and "associate-tag" are used for AWS affiliate program API which are not contained in this planet library. If these values are not found in the home directory ".awscreds.sexp" file their values are an empty string.

The session credential field holds the current (if any) ephemeral session credentials from AWS STS security token service.

The library will automatically maintain a valid session credential from STS by implicitly obtaining one if it is required or obtaining a fresh token if the current token has expired.

procedure

(load-credential path)  AwsCredential

  path : Path
Explicitly read in an sexp alist property file containing AWS credential information. The library implicitly loads "~/.awscreds.sexp" in module initialization, therefore use of this procedure is unnecessary for normal usage.

procedure

(set-aws-credential! credential)  Void

  credential : AwsCredential
Utility procedure to set the "current-aws-credential" parameter. Not required for normal use as the library loads and initializes the "current-aws-credential" parameter implicitly from "~/.awscreds.sexp" on initialization.

1.3 STS

 (require "../aws/sts/stc.rkt") package: wrap

procedure

(get-session-token duration-secs)  SessionCredential

  duration-secs : Exact-Nonnegative-Integer
Obtains a session token valid for the given duration in seconds from the AWS STS service.

1.4 S3 API

1.5 S3 URI

procedure

(s3-uri-path->prefix path)  String

  path : String
S3 API prefixes are relative path strings to the bucket. A URI path is absolute. Convert a S3 Uri, s3://mybucket/a/b/c, path, "/a/b/c" to a S3 prefix "a/b/c".

1.6 S3 Bucket Types

struct

(struct Buckets (owner buckets)
    #:transparent)
  owner : Owner
  buckets : (Listof Bucket)
Structure return by the "list-buckets" call to S3.

struct

(struct Owner (id creation-date)
    #:transparent)
  id : String
  creation-date : String
Ownership information associated with an S3 bucket.

struct

(struct Bucket (name creation-date)
    #:transparent)
  name : String
  creation-date : String
Bucket meta information returned by S3 in a "list-buckets" call.

struct

(struct S3Response (http sxml)
    #:transparent)
  http : Result
  sxml : Sxml
Contains the low level HTTP response header, e.g. the HTTP code and message, and the S3 XML response parsed into sxml. Eventually all S3 API calls will be fully parsed into appropriate response structures.

1.6.1 S3 Bucket API

See AWS S3 documentation for detailed information on the various parameters.

procedure

(list-buckets)  Buckets

Obtains a list of owned S3 buckets.

procedure

(create-bucket bucket-name)  S3Response

  bucket-name : String
Create a bucket on S3 with the given name.

procedure

(delete-bucket bucket-name)  S3Response

  bucket-name : String
Deletes the given S3 bucket

1.6.2 S3 Object Types

struct

(struct Object (key last-modified etag size owner)
    #:transparent)
  key : String
  last-modified : String
  etag : String
  size : Integer
  owner : Owner
The meta information associated with an S3 object.

struct

(struct Objects (name prefix marker max-keys is-truncated objects)
    #:transparent)
  name : String
  prefix : String
  marker : String
  max-keys : Integer
  is-truncated : Boolean
  objects : (Listof Object)
Result information returned from a call to "list-bucket-objects".

1.6.3 S3 Object API

See AWS S3 documentation for detailed information on the various parameters.

procedure

(list-bucket-objects bucket    
  prefix    
  delimiter    
  marker    
  max)  Objects
  bucket : String
  prefix : String
  delimiter : String
  marker : String
  max : Integer
Lists the objects contained in the given bucket.

procedure

(put-object bytes bucket path)  S3Response

  bytes : Bytes
  bucket : String
  path : String
Stores a blob of bytes into a bucket under a path name.

procedure

(put-file-object path-to-file bucket path)  S3Response

  path-to-file : String
  bucket : String
  path : String
Stores a local on disk file up on S3 in a provided path.

procedure

(delete-object bucket path)  S3Response

  bucket : String
  path : String
Deletes an S3 stored object.

1.7 SQS

 (require aws/sqs/sqs)

procedure

(list-queues prefix)  (U SQSError SQSListQueuesResp)

  prefix : (Option String)
List all SQS queues. If the optional prefix is provided only those queues starting with the prefix are listed. e.g. "/txs" would include "/txs/q1" and not "/orders/qs".

(: send-message (String String -> (U SQSError Void)))
(define (send-message queue-path msg)
  (sqs-invoke queue-path 'SendMessage (send-message-request msg)))

procedure

(send-message queue-path msg)  (U SQSError SQSSendResp)

  queue-path : String
  msg : String
Sends a message to the given gueue. The queue-path should be absolute, e.g. "/myqueue".

value

AttributeName : 
(U 'All 'SenderId 'SentTimestamp
   'ApproximateReceiveCount
        'ApproximateFirstReceiveTimestamp)
A define-type of an enumeration of allowable code values which specify the attribute values to be returned by SQS when receiving a message.

procedure

(receive-message queue-path 
  attributes 
  visibility-timeout 
  max-msgs) 
  (U SQSError SQSReceiveResp)
  queue-path : String
  attributes : (Listof AttributeName)
  visibility-timeout : Exact-Nonnegative-Integer
  max-msgs : Exact-Nonnegative-Integer
Receives a message from the given queue. See SQS doc recieve API doc for parameter semantics.

1.8 DynamoDB

1.8.1 Table Types

struct

(struct CreateTableResp (name status create capacity schema)
    #:transparent)
  name : String
  status : TableStatus
  create : Float
  capacity : Throughput
  schema : KeySchema
Response information from a "create-table" call.

struct

(struct Throughput (read write)
    #:transparent)
  read : Natural
  write : Natural
The read and write throughput of a table.

value

TableStatus : (U 'Active 'Deleting 'Creating)

The status of a table.

struct

(struct ListTablesResp (names last)
    #:transparent)
  names : (Listof String)
  last : STring
Information returned from a "list-tables" call. The "last" value can be used to initiate a second "list-tables" call to start listing from there.

1.8.2 Table API

procedure

(create-table name    
  hash-key    
  range-key    
  throughput)  (U DDBFailure CreateTableResp)
  name : String
  hash-key : Key
  range-key : (Option Key)
  throughput : Throughput
Creates a DynamboDB table.

procedure

(delete-table name)  (U DDBFailure DeleteTableRep)

  name : String
Deletes the table.

procedure

(describe-table name    
  schema    
  size    
  creation    
  status    
  capacity)  (U DDBFailure DescribeTableResp)
  name : String
  schema : (Option KeySchema)
  size : Integer
  creation : Float
  status : TableStatus
  capacity : Throughput
Meta data information for a table.

procedure

(list-tables start-from count)  ListTablesResp

  start-from : (Option String)
  count : Natural
List tables. If "start-from" is given the listing starts lexically after the string. Count is maximum number of tables to return in the response.