'Access denied to S3 bucket with s3-bucket-ssl-requests-only bucket policy

I am running an application on AWS EKS cluster and one of the pods has access to my S3 bucket. It works fine until I add a bucket policy.

When I add s3-bucket-ssl-requests-only bucket policy (like this one: https://aws.amazon.com/premiumsupport/knowledge-center/s3-bucket-policy-for-config-rule/), my pod loses accesses to S3 bucket and receives the Access Denied message.

Does anyone have an idea what could be the reason for this and how to allow my pod to access to the bucket with s3-bucket-ssl-requests-only policy?

I am only learning AWS, so please be understanding. I will provide more details if necessary.

EDIT:

The exact policy that I have added:

{
  "Id": "ExamplePolicy",
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowSSLRequestsOnly",
      "Action": "s3:*",
      "Effect": "Deny",
      "Resource": [
        "arn:aws:s3:::my_bucket_name",
        "arn:aws:s3:::my_bucket_name/*"
      ],
      "Condition": {
        "Bool": {
          "aws:SecureTransport": "false"
        }
      },
      "Principal": "*"
    }
  ]
}

where my_bucket_name is the name of my bucket



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source