title: How to write S3 bucket policy to file?
body: <p>I want to pull out the s3 bucket policies from all the s3 buckets I have and store them in their individual .json file. This should be formatted in json. However in my attempted solution it stores the policy in the file with the Response metadata and it not in jSOn format. </p>
  
  <pre><code>"ResponseMetadata": {"HTTPStatusCode": 200, ...... "content-type": "application/json"}}}
  </code></pre>
  
  <p>Can this be done in python/boto3? Here is my code.</p>
  
  <pre><code>try:
      s3client = get_s3Client('us-east-1')
      response = s3client.list_buckets()
      if response and response['Buckets']:
          for bucket in response['Buckets']:
              bucketName = bucket['Name']
              print (bucketName)
              policyname = policy_output + '\\' + bucketName + '.json'
              print (policyname)
  
              response = s3client.get_bucket_policy(
                  Bucket=bucketName
              )
              print (response)
              with open(policyname, 'w') as f:
                  json.dump(response, f)
                  #f.write(response)
  </code></pre>