I can successfully upload the file from AWS console (UI) to the S3 bucket, but when I try to upload the file from my CLI using command:
aws s3 sync d1/ s3://<s3-bucket>/test-directory
I am getting this error:
An error occurred (AccessDenied) when calling the ListObjectsV2 operation: Access Denied
aws iam get-usercommand (with no additional parameters). This will show you which IAM entity is being used by the AWS CLI to make API calls to AWS. Based on the behaviour you describe, it is likely that this will be a different user that the one you use to login to the AWS management console.