0

I am using Babun terminal to run python commands for AWS but hitting with some error->

cors_configuration={
... 'CORSRules':[{'AllowedHeaders':['Authorization'],'AllowedMethods':['GET','PUT'],'AllowedOrigins':['*'],'ExposeHeaders':['GET','PUT'],'MaxAgeSeconds':3000}]}
s3.put_bucket_cors(Bucket='mynamebuckets',CORSConfiguration=cors_configuration)
/usr/lib/python2.7/site-packages/urllib3/util/ssl_.py:387: SNIMissingWarning: An HTTPS request has been made, but the SNI (Server Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  SNIMissingWarning,
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/botocore/client.py", line 316, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/lib/python2.7/site-packages/botocore/client.py", line 635, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the PutBucketCors operation: Access Denied

Please let me know the solution to resolve this.

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
  • Have you specified credentials for the s3 client? And do those credentials have permission to access this s3 bucket for the put bucket cors method? – Chris Williams Jun 27 '20 at 19:02
  • I haven't specified any credentials for the s3 client. – Rashmi Pandey Jun 27 '20 at 19:11
  • I have used >>> http = urllib3.PoolManager(num_pools=50) >>> urllib3.disable_warnings() and now the error is :raceback (most recent call last): File "", line 1, in File "/usr/lib/python2.7/site-packages/botocore/client.py", line 316, in _api_call return self._make_api_call(operation_name, kwargs) File "/usr/lib/python2.7/site-packages/botocore/client.py", line 635, in _make_api_call raise error_class(parsed_response, operation_name) botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the PutBucketCors operation: Access Denied – Rashmi Pandey Jun 27 '20 at 19:13
  • Without credentials running this will not be possible. S3 requires IAM credentials either as an IAM role attached to the instance or IAM user. – Chris Williams Jun 27 '20 at 19:13

1 Answers1

0

No credentials have been provided, the following actions can be taken to allow this script to run.

  • If this script is running on an EC2 you can make use of attaching a IAM role to your instance
  • Alternatively if you are not in AWS create an IAM user with the permissions then do one of the following
Chris Williams
  • 32,215
  • 4
  • 30
  • 68