Comments (6)
Hm, actually I'm not sure if S3 needs to be regional or if it needs to learn to associate a bucket with a region by following the redirects that are returned when the wrong (or no) region is sent. Individual buckets are regioned, but the top-level service itself is not.
from amazonka.
Thanks @rjmac.
Since I chose (or was forced to by the models, due to generality) to use the region specific endpoints instead of virtual host style buckets, region/endpoint logic needs to be specialised for S3. This is because it uses a different endpoint structure based on the region you're communicating with.
The API reference outlines this in detail, and the service models contain the invariants which I will parse/use to ensure the correct endpoint is chosen depending on the region.
from amazonka.
I'm going to merge the two PR's addressing this to develop
, but leaving the issue open. If you could rerun your code and let me know if your problems have been solved, or add any additional info.
Alternatively if you could supply me with a small example I could use to quickly recreate any issues, it would be greatly appreciated!
from amazonka.
Doesn't quite; it looks like the line Endpoint host' scope = endpoint s r
in V4.hs should be Endpoint scope host' = ...
After changing that, there are a couple of incorrect timestamp formats (RFC822s that should be ISO8601s in the definitions of Bucket
and Object
in S3.Types).
Anyway, here's the program I've been using to experiment:
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Network.AWS (Credentials(..), Region(..), getEnv, envLogger, Logger(Debug))
import Control.Monad.Trans.AWS (runAWST, send, paginate)
import Network.AWS.S3
import Network.AWS.Prelude
import Control.Lens
import qualified Data.Text.IO as Text
import qualified Data.Text as Text
import Control.Monad.IO.Class (liftIO)
import Data.Conduit
import System.Environment (lookupEnv)
main :: IO ()
main = do
env <- getEnv Oregon Discover <&> envLogger .~ Debug Text.putStrLn
-- Work with the bucket named in S3_BUCKET or whichever comes back first
defaultBucket <- (fmap.fmap) Text.pack $ lookupEnv "S3_BUCKET"
let bucketSelector = maybe head const defaultBucket
-- The name of an object to retrieve
objectToRetrieve <- (fmap.fmap) Text.pack $ lookupEnv "S3_OBJECT"
er <- runAWST env $ do
buckets <- send listBuckets <&> (^.lbrBuckets) <&> map (^.bName) <&> catMaybes
liftIO $ print buckets
let bucketToList = bucketSelector buckets
paginate (listObjects bucketToList) $$ awaitForever (liftIO . print)
case objectToRetrieve of
Just name -> do
obj <- send $ getObject bucketToList name
liftIO $ print obj
(obj^.gorBody) `connectBody` awaitForever (liftIO . print)
Nothing ->
return ()
case er of
Left err -> print err
Right _ -> return ()
from amazonka.
Thanks! You beat me before I could push the fix for Endpoint
to develop.
I'll check it out.
from amazonka.
I've successfully verified that c2f3c40 in combination with previous round of fixes results in things working as expected. The S3 example mostly demonstrates this, but avoids actually printing/downloading the objects since who knows what people keep in their buckets.
from amazonka.
Related Issues (20)
- S3.SelectObjectContent throws `SignatureDoesNotMatch` exception HOT 6
- crypton-0.34 could be accepted with revision HOT 1
- S3 Addressing Style: Should `S3AddressingStyleAuto` only rewrite *.amazonaws.com DNS names? HOT 3
- Compilation failures with GHC 9.8 HOT 5
- Strange behavior in Haddocks for amazonka HOT 2
- Consider `stamina` as an alternative to `retry`
- R2 Incompatibility HOT 4
- S3 - Get pre-signed put object URL? HOT 3
- amazonka-secretsmanager is not registered in stackage HOT 4
- Setting S3 endpoint creates invalid host in HTTP request HOT 6
- Support setting service endpoints via config/environment variable
- Throws CredentialChainExhausted unless `~/.aws/credentials` exists HOT 8
- ToJSON on output types, FromJSON on input types (where possible)
- Share AttributeValue type between amazonka-dynamodb and amazonka-dynamodb-streams
- amazonka timestream query prefix results in 404
- [amazonka-sso] Duplicate record field ‘accountId’ in export list HOT 2
- amazonka base revisions prevent building in Stackage Nightly! HOT 4
- Error handling in periodic credential update
- regenerate sesv2 HOT 1
- Hook system improvements HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amazonka.