title: AWS - S3 - GetBucketPolicy
body: <p>Having trouble understanding just why my get_bucket_policy function is not working. i have double checked for typos and I have a policy and I get this error:</p>
  
  <pre><code>An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist
  </code></pre>
  
  <p>from this script:</p>
  
  <pre><code>import boto3
  import json
  
  BUCKET_NAME ='patrick-s3-2018-bucket'
  
  def s3_client():
      s3 = boto3.client('s3')
      """:type : pyboto3.s3"""
      return s3
  
  def create_bucket(bucket_name):
      return s3_client().create_bucket(
          Bucket=bucket_name,
          CreateBucketConfiguration={
              'LocationConstraint': 'us-east-2'
              }
          )
  
  def create_bucket_policy():
      bucket_policy = {
          "Version": "2012-10-17",
          "Statement":[
              {
              "Sid": "AddPerm",
              "Effect": "Allow",
              "Principal": "*",
              "Action":["s3:*"],
              "Resource":["arn:aws:s3:::patricksbucket/*"]
              }
          ]
      }
      policy_string = json.dumps(bucket_policy)
  
      return s3_client().put_bucket_policy(
          Bucket=BUCKET_NAME,
          Policy=policy_string
      )
  def list_buckets():
      return s3_client().list_buckets()
  
  def get_bucket_policy():
      return s3_client().get_bucket_policy(Bucket=BUCKET_NAME)
  
  
  if __name__ == '__main__':
      print(get_bucket_policy())
  </code></pre>
  
  <p>I have also tried to use the full actual bucket name , not just the variable but this has not solved the issue. </p>
  
  <p>This issue does not appear to be well documented online, when using AWS resources it is hard for me to compare their examples to the UDEMY class example I am using as I am still learning </p>