File: deleteBucket.hs

package info (click to toggle)
haskell-hs3 0.5.7-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 184 kB
  • sloc: haskell: 1,219; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 1,042 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/local/bin/runhaskell

-----------------------------------------------------------------------------
-- |
-- Program     :  Delete Bucket
-- Copyright   :  (c) Greg Heartsfield 2007
-- License     :  BSD3
--
-- Delete a bucket with a given name.
-- Usage:
--    deleteBucket.hs bucket-name
--
-- This requires the following environment variables to be set with
-- your Amazon keys:
--   AWS_ACCESS_KEY_ID
--   AWS_ACCESS_KEY_SECRET
-----------------------------------------------------------------------------

import Network.AWS.S3Bucket
import Network.AWS.AWSConnection
import Network.AWS.AWSResult
import System.Environment
import Data.Maybe

main = do argv <- getArgs
          let bucket = head argv
          mConn <- amazonS3ConnectionFromEnv
          let conn = fromJust mConn
          putStrLn ("Deleting bucket with name: " ++ bucket)
          res <- deleteBucket conn bucket
          either (putStrLn . prettyReqError)
                 (const $ putStrLn ("Deletion of " ++ bucket ++ " successful."))
                 res