• Stars
    star
    238
  • Rank 169,306 (Top 4 %)
  • Language
    Haskell
  • License
    BSD 3-Clause "New...
  • Created about 14 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Amazon Web Services for Haskell

Introduction

The aws package attempts to provide support for using Amazon Web Services like S3 (storage), SQS (queuing) and others to Haskell programmers. The ultimate goal is to support all Amazon Web Services.

Installation

Make sure you have a recent GHC installed, as well as cabal-install, and installation should be as easy as:

$ cabal install aws

If you prefer to install from source yourself, you should first get a clone of the aws repository, and install it from inside the source directory:

$ git clone https://github.com/aristidb/aws.git
$ cd aws
$ cabal install

Using aws

Concepts and organisation

The aws package is organised into the general Aws module namespace, and subnamespaces like Aws.S3 for each Amazon Web Service. Under each service namespace in turn, there are general support modules and and Aws.<Service>.Commands.<Command> module for each command. For easier usage, there are the "bundling" modules Aws (general support), and Aws.<Service>.

The primary concept in aws is the Transaction, which corresponds to a single HTTP request to the Amazon Web Services. A transaction consists of a request and a response, which are associated together via the Transaction typeclass. Requests and responses are simple Haskell records, but for some requests there are convenience functions to fill in default values for many parameters.

Example usage

To be able to access AWS resources, you should put your into a configuration file. (You don't have to store it in a file, but that's how we do it in this example.) Save the following in $HOME/.aws-keys.

default AccessKeyID SecretKey

You do have to replace AccessKeyID and SecretKey with the Access Key ID and the Secret Key respectively, of course.

Then, copy this example into a Haskell file, and run it with runghc (after installing aws):

{-# LANGUAGE OverloadedStrings #-}

import qualified Aws
import qualified Aws.S3 as S3
import           Control.Monad.Trans.Resource
import           Data.Conduit ((.|), runConduit)
import           Data.Conduit.Binary (sinkFile)
import           Network.HTTP.Conduit (newManager, tlsManagerSettings, responseBody)

main :: IO ()
main = do
  {- Set up AWS credentials and the default configuration. -}
  cfg <- Aws.baseConfiguration
  let s3cfg = Aws.defServiceConfig :: S3.S3Configuration Aws.NormalQuery

  {- Set up a ResourceT region with an available HTTP manager. -}
  mgr <- newManager tlsManagerSettings
  runResourceT $ do
    {- Create a request object with S3.getObject and run the request with pureAws. -}
    S3.GetObjectResponse { S3.gorResponse = rsp } <-
      Aws.pureAws cfg s3cfg mgr $
        S3.getObject "haskell-aws" "cloud-remote.pdf"

    {- Save the response to a file. -}
    runConduit $ responseBody rsp .| sinkFile "cloud-remote.pdf"

You can also find this example in the source distribution in the Examples/ folder.

Frequently Asked Questions

S3 questions

  • I get an error when I try to access my bucket with upper-case characters / a very long name.

    Those names are not compliant with DNS. You need to use path-style requests, by setting s3RequestStyle in the configuration to PathStyle. Note that such bucket names are only allowed in the US standard region, so your endpoint needs to be US standard.

Release Notes

See CHANGELOG

Resources

Contributors

Name Github E-Mail Company Components
Abhinav Gupta abhinav [email protected] - IAM, SES
Aristid Breitkreuz aristidb [email protected] - Co-Maintainer
Bas van Dijk basvandijk [email protected] Erudify AG S3
David Vollbracht qxjit
Felipe Lessa meteficha [email protected] currently secret Core, S3, SES
Nathan Howell NathanHowell [email protected] Alpha Heavy Industries S3
Ozgun Ataman ozataman [email protected] Soostone Inc Core, S3, DynamoDb
Steve Severance sseveran [email protected] Alpha Heavy Industries S3, SQS
John Wiegley jwiegley [email protected] FP Complete S3
Chris Dornan cdornan [email protected] Iris Connect Core
John Lenz wuzzeb DynamoDB, Core
Joey Hess joeyh [email protected] - Co-Maintainer, S3

More Repositories

1

http-types

Generic HTTP types for Haskell (for both client and server code)
Haskell
54
star
2

random-extras

Additional functions for random values.
Haskell
7
star
3

lens-agda

Understanding lenses with the help of Agda
6
star
4

cppbash

C++ Bash - Quotes from the C++ world
Python
5
star
5

GOTT

The infamous "GOTT project" ("GUI on Transparent Technology"; now dead, of historical interest only)
Python
4
star
6

fragments

C++
4
star
7

shortcircuit

Classes and functions for short-circuit values and expressions.
Haskell
4
star
8

fmtxx

Formatting for C++, inspired by PEP 3101 (the "Python 3.0 Formatting")
C++
3
star
9

rest

C++ Web Server
C++
3
star
10

functors

(.:) and friends
Haskell
3
star
11

agda

Me attempting to learn Agda
Haskell
2
star
12

xml-enumerator-combinators

Parser combinators for xml-enumerator and compatible XML parsers.
Haskell
2
star
13

GameOfLife

Haskell
2
star
14

playground

Just a playground
Haskell
2
star
15

dotemacs

.emacs files of various users (DEPRECATED, i have an .emacs.d repository now)
Emacs Lisp
2
star
16

fluvial

Better C++ Streams
2
star
17

monadLib-compose

Arrow-like monad composition for monadLib.
Haskell
2
star
18

zimmerbingo

My first Yesod project: A "room number bingo" creator
Haskell
2
star
19

dcpu16-hs

Haskell
2
star
20

xml-monad

Monadic extensions to the xml package.
Haskell
2
star
21

mueval-irc

mueval with some patches to make it more suitable for an IRC bot.
Haskell
2
star
22

haskell-containers

For learning and playing with Haskell
Haskell
2
star
23

transformers-compose

Arrow-like / category-like composition for transformers.
Haskell
2
star
24

sequential-index

[Haskell] Sequential index numbers between 0.0 and 1.0 that allow arbitrarily inserting new numbers in between (for special containers).
Haskell
2
star
25

filefind

Syntax idea for finding files in directories
Haskell
2
star
26

kv-agda

Experiments with sorted associative data structures in Agda
1
star
27

git-tools

Tools for GIT
Shell
1
star
28

.emacs.d

My new .emacs.d
Emacs Lisp
1
star
29

elisp-utils

Some utility functions for elisp
Emacs Lisp
1
star
30

flusspferd-json-utils

Command line utilities for JSON on the Flusspferd platform
1
star
31

arith-coding

Experiment with arithmetic coding in Haskell
Haskell
1
star