Comments (5)
@tianx2 it looks like you probably need to pass the region name when creating your client or resource:
>>> import boto3
>>> s3 = boto3.resource('s3', region_name='us-west-2')
>>> bucket = s3.create_bucket(Bucket='boto3.region',
CreateBucketConfiguration={'LocationConstraint': 'us-west-2'})
>>> bucket.Object('hello.txt').put(Body='hello')
...
>>> bucket.Object('hello.txt').last_modified
datetime.datetime(2015, 4, 2, 20, 55, 17, tzinfo=tzutc())
You can also determine the bucket location programmatically:
>>> s3.meta.client.get_bucket_location(Bucket='boto3.region')
{'LocationConstraint': 'us-west-2',
'ResponseMetadata': {'RequestId': 'abc123',
'HostId': '12345',
'HTTPStatusCode': 200}}
This is a limitation of the way that S3 works, but with the above code you can work around it to support any bucket in any region.
Please let me know if you have any other questions.
from boto3.
So my use case was that i was trying to grab the tags for the bucket. Here is some sample code:
import boto3
try:
s3 = boto3.resource("s3", region_name="us-east-1")
name = "my.bucket.random"
dotted_bucket = s3.Bucket(name)
print dotted_bucket.Tagging().tag_set
except Exception as e:
print e.message
Event with your suggestion, I still get the error.
Steps:
- Create a bucket with dots (".") in the name.
- Replace
name = "my.bucket.random"
in sample code with the created bucket name - Run sample code.
Result:
An error occurred (PermanentRedirect) when calling the GetBucketTagging operation: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
I did a test on Python 2.7.8 as well. I get the error there too, so I don't think it's related to the SSL issue.
from boto3.
@tianx2 I'd double check that the bucket actually is in us-east-1. I'm not seeing that issue when I try your sample code. For example, I created a bucket with dots in us-west-2. Running your sample code works for me:
>>> import boto3
>>> s3 = boto3.resource('s3', region_name='us-west-2')
>>> bucket = s3.Bucket('jamesls.bucket.with.dots')
>>> bucket.Tagging().tag_set
[{u'Value': 'TestValue', u'Key': 'TestTag'}]
However if I use the wrong region (say us-east-1 in this example), then I get your error:
>>> s3 = boto3.resource('s3', region_name='us-east-1')
>>> bucket = s3.Bucket('jamesls.bucket.with.dots')
>>> bucket.Tagging().tag_set
Traceback (most recent call last):
...
raise ClientError(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (PermanentRedirect) when calling the GetBucketTagging operation: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
You can confirm where your bucket is located via:
>>> boto3.client('s3').get_bucket_location(Bucket='jamesls.bucket.with.dots')['LocationConstraint']
'us-west-2'
from boto3.
i tag the s3 bucket now i want to write a a program using boto3 to fetch the details of the tagging bucket can anyone help me in dat
from boto3.
getting error An error occurred (AuthorizationHeaderMalformed) when calling the GetBucketTagging operation: The authorization header is malformed; a non-empty Access Key (AKID) must be provided in the credential.
Any suggestions ?
from boto3.
Related Issues (20)
- [Feature Request] Query Bedrock model maxTokens limit HOT 2
- Unable to call RevokeSecurityGroupIngress (incorrect parameters being passed) HOT 3
- Invalid endpoint when initializing boto3.client inside Docker HOT 2
- Neptune Client Returns All DB Clusters (Not Just Neptune) HOT 2
- InvalidParameterException when starting a Textract async job for Document Analysis HOT 3
- validate_e911_address returns invalid country code HOT 2
- Validation Exception: Invalid API version when calling InvokeModel [bedrock-runtime] HOT 2
- Collaborate with AWS SDK Code Examples team
- ECS ListContainerInstances (1.34.150) - incorrect 'MaxItems' details HOT 2
- AWS Lambda - "list_coverage" filter on `lambdaFunctionRuntime` not working HOT 8
- list_protections doc does not state an optional field. HOT 3
- Converse API skips 'required' tool spec parameters HOT 2
- Dangling Parameter - should be removed from SNS Docs HOT 1
- Image corruption when uploading to S3 using Boto3 in Lambda HOT 2
- Use IAM ID instead of username HOT 1
- Example for MultipartUpload HOT 5
- Error writing records to Timestream HOT 2
- Bedrock - Add way to identify which models an account currently has access to HOT 3
- Inconsistent description of `type` response for `describe_directories` HOT 2
- Bedrock invoke_agent boto3 does not have knowledgeBaseConfigurations HOT 6
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 boto3.