Access denied to the bucket ****** - amazon-web-services

I am new to AWS and i am trying to export VM images from AWS EC2 to S3 bucket that I had already imported using VMImport/Export service . I tried to export using AWS CLI and SDK (python) as well , but both returns the same error :
An error occurred (InvalidParameter) when calling the ExportImage operation: Access denied to the bucket ******23
Entered parameters are correct and i have given all public access to the S3 bucket used in Export action. Still the error continues to appear.
Any help would be greatly appreciated
Thanks in advance

I was facing the same issue , make sure the open the bucket and again give permission write read in S3 bucket as attached in image
Step 1Open your bucket s3 in console
step 2Go to permission tab
Step 3Make it public and ACL
Step 4Give the read write permissions
But best practice make IAM and add that account to permissions

Related

Amazon S3 Access Denied when calling aws lambda publish-layer-version CLI

I tried to run aws lambda publish-layer-version command line in my local console using my personal aws credentials, but I've got an Amazon S3 Access Denied error for the bucket in which the zip layer is stored.
aws lambda publish-layer-version --layer-name layer_name --content S3Bucket=bucket_name,S3Key=layers/libs.zip
An error occurred (AccessDeniedException) when calling the PublishLayerVersion operation: Your access has been denied by S3, please make sure your request credentials have permission to GetObject for {URI of layer in my S3 bucket}. S3 Error Code: AccessDenied. S3 Error Message: Access Denied
When I'm running the aws cp command in the same bucket, it all works perfectly fine
aws s3 cp s3://bucket_name/layers/libs.zip libs.zip
So I assume that the aws lambda command line is using an other role than the one used when I'm running the aws cp command line ? Or maybe it uses another mecanism that I just don't know. But I couldn't find any thing about it in the AWS documentation.
I've just read that AWS can return a 403 it couldn't find the file. So maybe it could be an issue with the command syntax ?
Thank you for your help.
For your call to publish-layer-version you may need to specify the --content parameter with 3 parts:
S3Bucket=string,S3Key=string,S3ObjectVersion=string
It looks like you are missing S3ObjectVersion. I don't know what the AWS behavior is for evaluating and applying the parts of that parameter, but it could be attempting to do something more since the version is not specified and hence giving you that error. Or it could be returning an error code that is not quite right and is misleading. Try adding S3ObjectVersion and let me know what you get.
Otherwise, AWS permission evaluation can be complex. I like this AWS diagram below, so it is a good one to follow to track down permissions issues, but I suspect that AccessDenied is a bit of a red herring in this case:
Your Lambda does not have privileges (S3:GetObject).
Try running aws sts get-caller-identity. This will give you the IAM role your command line is using.
Go to IAM dashboard, check this role associated with your Lambda execution. If you use AWS wizard, it automatically creates a role called oneClick_lambda_s3_exec_role. Click on Show Policy. It will look something like attached image.Make sure S3:GetObject is listed.
Also, AWS returns 403 (access denied) when the file does not exist. Be sure the target file is in the S3 bucket.

Unable to access S3 bucket content: Access denied

I am using script to create an S3 bucket and uploading cloudformation templates to that bucket with same user credentials.
But when trying to access the templates of that bucket using cloudformation, am getting access denied. I even tried adding the bucket policy and giving explicit access to that user but getting same "Access denied" error. Please suggest if am missing anything. Thank you.
As you are trying to access the s3 bucket using cloud formation, you need to ensure that cloud formation should have proper permission to access S3 because this time you are not calling the S3 API but cloud formation.
If you are using AWS CloudFormation via the management console, then CloudFormation will use your own credentials to retrieve the template from Amazon S3.
Therefore, the user that is using CloudFormation will require access to the object in Amazon S3.
If you believe that this has been correctly configured, please edit your Question to provide more details (eg the permissions granted to the user who is using CloudFormation).

S3 Bucket without ACL - No permission

I found an issue with a S3 bucket.
The bucket don't have any ACL associated, and the user that create the bucket was deleted.
How it's possible add some ACL in the bucket to get the control back?
For any command using AWS CLI, the result are the same always: An error occurred (AccessDenied) when calling the operation: Access Denied
Also in AWS console the access is denied.
First things first , AccessDenied error in AWS indicates that your AWS user does not have access to S3 service , Get S3 permission to your IAM user account , if in case you had access to AWS S3 service.
The thing is since you are using cli make sure AWS client KEY and secret are still correctly in local.
Now the interesting use case :
You have access to S3 service but cannot access the bucket since the bucket had some policies set
In this case if user who set the policies left and no user was able to access this bucket, the best way is to ask AWS root account holder to change the bucket permissions
An IAM user with the managed policy named AdministratorAccess should be able to access all S3 buckets within the same AWS account. Unless you have applied some unusual S3 bucket policy or ACL, in which case you might need to log in as the account's root user and modify that bucket policy or ACL.
See Why am I getting an "Access Denied" error from the S3 when I try to modify a bucket policy?
I just posted this on a related thread...
https://stackoverflow.com/a/73977525/999943
https://aws.amazon.com/premiumsupport/knowledge-center/s3-bucket-owner-full-control-acl/
Basically when putting objects from the non-bucket owner, you need to set the acl at the same time.
--acl bucket-owner-full-control

using Boto 3 to get s3 bucket access control information with real only permission on aws account, but unable to get

I am using Boto 3 to get s3 bucket access control information with real only permission on aws account, but unable to get it and getting an error
response2 = client.get_public_access_block(Bucket='BUCKETNAME')
print(response2['PublicAccessBlockConfiguration']['BlockPublicAcls'])
botocore.exceptions.ClientError: An error occurred (NoSuchPublicAccessBlockConfiguration) when calling the GetPublicAccessBlock operation: The public access block configuration was not found
Please suggest what all permissions as AWS Account user I need to get access information of s3 buckets
I had a same problem with boto3. But i resolved the problem, changing region.
so the region us-east-1 doesn't work for it.
Thanks

Delete S3 bucket in a strange state

I have a problem with removing S3 bucket with the following ERROR state (check this image).
I tried to remove it via aws cli but the result is of course:
aws s3 rb s3://hierarchy --force
fatal error: An error occurred (AccessDenied) when calling the ListObjects operation: Access Denied
I can't change anything (bucket policy, etc.) on this bucket.
I have to mention that I'm administrator and have all privileges on the AWS account.
Google does not help me. I would like to know if is it possible to remove bucket like this.
It is possible that there is a Bucket Policy containing a Deny statement that is preventing your access.
Find somebody who has access to the Root credentials, which should be able to delete it.
If that fails, contact AWS Support.