choonkeat / elm-aws

Home Page:https://package.elm-lang.org/packages/choonkeat/elm-aws/latest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

elm-aws

Helper functions to create signed http requests to AWS, e.g. DynamoDB or IAM

This package does not export any Task function, removing the ability to inject backdoors. It can only sign UnsignedRequest and return the necessary argument for Http.task.

So, at most, you'd need only to verify the host of url in the returned SignedRequest record

-- Setup the request


stringBody =
    Json.Encode.object
        [ ( "TableName", Json.Encode.string "Example" )
        , ( "Key"
          , Json.Encode.object
                [ ( "primaryKey", AWS.DynamoDB.encodeS "uniqueValue" )
                ]
          )
        ]
        |> Json.Encode.encode 0

rawRequest =
    { method = "POST"
    , headers =
        [ AWS.awsTargetHeader AWS.DynamoDB_GetItem
        ]
    , query = []
    , stringBody = stringBody
    , resolver = httpResolver
    , service = AWS.ServiceDynamoDB
    }


-- If AWS.signRequest is successful, give it to Http.task


httpTask =
    case AWS.signRequest config now rawRequest of
        Err err ->
            -- unable to create request

        Ok signedRequest ->
            Http.task signedRequest

About

https://package.elm-lang.org/packages/choonkeat/elm-aws/latest

License:MIT License


Languages

Language:Elm 99.8%Language:Makefile 0.2%