canceraiddev / elm-aws-core / AWS.Config

A configuration for a service can be built directly, or by using the helper functions for convenience.

To build an AWS service configuration directly:

{ endpointPrefix = "lambda"
, apiVersion = "2015-03-31"
, protocol = AWS.Config.REST_JSON
, signer = AWS.Config.SignV4
, endpoint = RegionalEndpoint "us-east-1"
, jsonVersion = Nothing
, signingName = Nothing
, xmlNamespace = Nothing
, timestampFormat = Nothing
, targetPrefix = Nothing
}

The same thing with the convenience functions would look like:

AWS.Service.defineRegional
    "lambda"
    "2015-03-31"
    AWS.Config.REST_JSON
    AWS.Config.SignV4
    "us-east-1"

In some of the comments below you will see 'API metadata' mentioned. AWS publishes a set of JSON files containing metadata describing each of its services, and this is what is being referred to. You can find this metadata here:

https://github.com/aws/aws-sdk-js/tree/master/apis

Service configuration.


type alias ServiceConfig =
{ endpointPrefix : String
, apiVersion : ApiVersion
, protocol : Protocol
, signer : Signer
, endpoint : Endpoint
, jsonVersion : Maybe String
, signingName : Maybe String
, xmlNamespace : Maybe String
, timestampFormat : Maybe TimestampFormat
, targetPrefix : Maybe String 
}

Configures an AWS service.

Note that timestampFormat defaults to UnixTimestamp for JSON and REST_JSON based services and ISO8601 for other services. Specifying Nothing will use the correct default, unless it is set to something different in the API metadata.

Also note that targetPrefix will default to AWS ++ prefix ++ (apiVersion with the '-' characters removed). This only needs to be set to a different value if it differs in the API metadata.


type alias ApiVersion =
String

Version of a service.


type Protocol
    = EC2
    | JSON
    | QUERY
    | REST_JSON
    | REST_XML

Defines the different protocols that AWS services can use.


type Signer
    = SignV4
    | SignS3

Defines the different signing schemes that AWS services can use.


type TimestampFormat
    = ISO8601
    | RFC822
    | UnixTimestamp

Defines the different timestamp formats that AWS services can use.


type alias Region =
String

An AWS region string.

For example "us-east-1".


type Endpoint
    = GlobalEndpoint
    | RegionalEndpoint Region

Defines an AWS service endpoint.

Convenience functions to help with service configuration.

defineGlobal : String -> ApiVersion -> Protocol -> Signer -> ServiceConfig

Creates a global service definition.

defineRegional : String -> ApiVersion -> Protocol -> Signer -> Region -> ServiceConfig

Creates a regional service definition.

withJsonVersion : String -> ServiceConfig -> ServiceConfig

Set the JSON apiVersion.

Use this if jsonVersion is provided in the API metadata.

withSigningName : String -> ServiceConfig -> ServiceConfig

Set the signing name for the service.

Use this if signingName is provided in the API metadata.

withTargetPrefix : String -> ServiceConfig -> ServiceConfig

Set the target prefix for the service.

Use this if targetPrefix is provided in the API metadata.

Note that targetPrefix will default to AWS ++ prefix ++ (apiVersion with the '-' characters removed). This only needs to be set to a different value if it differs in the API metadata.

withTimestampFormat : TimestampFormat -> ServiceConfig -> ServiceConfig

Set the timestamp format for the service.

Use this if timestampFormat is provided in the API metadata.

Note that timestampFormat defaults to UnixTimestamp for JSON and REST_JSON based services and ISO8601 for other services. Specifying Nothing will use the correct default, unless it is set to something different in the API metadata.

withXmlNamespace : String -> ServiceConfig -> ServiceConfig

Set the XML namespace for the service.

Use this if xmlNamespace is provided in the API metadata.