Below is my yml file to create S3 bucket. For security purpose i have not pasted here actual aws_access_key and aws_secret_key just showing them as ***** in the snippet below. I have installed boto3, boto,AWS CLI on the Ec2 instance which is having Ansible installed on it.
--- - hosts: localhost tasks: - name: Create an S3 bucket become: true aws_s3: aws_access_key=****** aws_secret_key=**** bucket=testbuck mode=create permission=public-read region=us-east-1
when i execute above yml file using ansible-playbook command then it gives exception as shown below. Please help me to fix this issue so that a S3 bucket with name "testbuck" gets created.
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: botocore.exceptions.ClientError: An error occurred (403) when calling the HeadBucket operation: Forbidden fatal: [localhost]: FAILED! => {"boto3_version": "1.10.44", "botocore_version": "1.13.44", "changed": false, "error": {"code": "403", "message": "Forbidden"}, "msg": "Failed while looking up bucket (during bucket_check) testbuck.: An error occurred (403) when calling the HeadBucket operation: Forbidden", "response_metadata": {"host_id": "OmIY2bLkh4T4JwxD/UJsM47n7oUUS6ttEL9ZMl+vv66bVsLcwQuP2pzAGr05m1LdtznYudrrapk=", "http_headers": {"content-type": "application/xml", "date": "Fri, 17 Jan 2020 16:54:49 GMT", "server": "AmazonS3", "transfer-encoding": "chunked", "x-amz-bucket-region": "us-east-1", "x-amz-id-2": "OmIY2bLkh4T4JwxD/UJsM47n7oUUS6ttEL9ZMl+vv66bVsLcwQuP2pzAGr05m1LdtznYudrrapk=", "x-amz-request-id": "51740FB276A10A18"}, "http_status_code": 403, "request_id": "51740FB276A10A18", "retry_attempts": 0}}