{- S3 remotes
-
- - Copyright 2011-2022 Joey Hess <id@joeyh.name>
+ - Copyright 2011-2023 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
(FieldDesc "S3 server hostname (default is Amazon S3)")
, optionalStringParser datacenterField
(FieldDesc "S3 datacenter to use (US, EU, us-west-1, ..)")
+ , optionalStringParser regionField
+ (FieldDesc "S3 region to use")
, optionalStringParser partsizeField
(FieldDesc "part size for multipart upload (eg 1GiB)")
, optionalStringParser storageclassField
datacenterField :: RemoteConfigField
datacenterField = Accepted "datacenter"
+regionField :: RemoteConfigField
+regionField = Accepted "region"
+
partsizeField :: RemoteConfigField
partsizeField = Accepted "partsize"
}
where
h = fromJust $ getRemoteConfigValue hostField c
+ r = encodeBS <$> getRemoteConfigValue regionField c
datacenter = fromJust $ getRemoteConfigValue datacenterField c
-- When the default S3 host is configured, connect directly to
-- the S3 endpoint for the configured datacenter.
| otherwise -> AWS.HTTP
cfg = case getRemoteConfigValue signatureField c of
Just (SignatureVersion 4) ->
- S3.s3v4 proto endpoint False S3.SignWithEffort
- _ -> S3.s3 proto endpoint False
+ (S3.s3v4 proto endpoint False S3.SignWithEffort)
+#if MIN_VERSION_aws(0,24,0)
+ { S3.s3Region = r }
+#endif
+ _ -> (S3.s3 proto endpoint False)
+#if MIN_VERSION_aws(0,24,0)
+ { S3.s3Region = r }
+#endif
data S3Info = S3Info
{ bucket :: S3.Bucket
, public :: Bool
, publicurl :: Maybe URLString
, host :: Maybe String
+ , region :: Maybe String
}
extractS3Info :: ParsedRemoteConfig -> Annex S3Info
getRemoteConfigValue publicField c
, publicurl = getRemoteConfigValue publicurlField c
, host = getRemoteConfigValue hostField c
+ , region = getRemoteConfigValue regionField c
}
putObject :: S3Info -> T.Text -> RequestBody -> S3.PutObject
s3Info :: ParsedRemoteConfig -> S3Info -> [(String, String)]
s3Info c info = catMaybes
[ Just ("bucket", fromMaybe "unknown" (getBucketName c))
- , Just ("endpoint", w82s (BS.unpack (S3.s3Endpoint s3c)))
+ , Just ("endpoint", decodeBS (S3.s3Endpoint s3c))
+#if MIN_VERSION_aws(0,24,0)
+ , case S3.s3Region s3c of
+ Nothing -> Nothing
+ Just r -> Just ("region", decodeBS r)
+#endif
, Just ("port", show (S3.s3Port s3c))
, Just ("protocol", map toLower (show (S3.s3Protocol s3c)))
, Just ("storage class", showstorageclass (getStorageClass c))
Think carefully about who can access your repository before using
embedcreds without gpg encryption.
-* `datacenter` - Defaults to "US". Other values include "EU" (which is EU/Ireland),
- "us-west-1", "us-west-2", "ap-southeast-1", "ap-southeast-2", and
- "sa-east-1".
+* `datacenter` - Specifies which Amazon datacenter
+ to use for the bucket. Defaults to "US". Other values include "EU"
+ (which is EU/Ireland), "us-west-1", "us-west-2", "ap-southeast-1",
+ "ap-southeast-2", and "sa-east-1". See Amazon's documentation for a
+ complete list. Configuring this is equivilant to configuring both
+ `host` and `region`.
* `storageclass` - Default is "STANDARD".
Consult S3 provider documentation for pricing details and available
* `host` - Specify in order to use a different, S3 compatable
service.
+* `region` - Specify the region to use. Only makes sense to use when
+ you also set `host`.
+ (Requires a git-annex built with aws-0.24.)
+
* `protocol` - Either "http" (the default) or "https". Setting
protocol=https implies port=443.