From d0b1cad73581fb30c43e1080b6d2abbfd8f36ea2 Mon Sep 17 00:00:00 2001 From: nitro Date: Mon, 18 May 2020 09:39:00 -0400 Subject: [PATCH] Put secret using text/plain content type This allows secrets to be retrievable using the terraform data source [`s3_bucket_object`](https://www.terraform.io/docs/providers/aws/d/s3_bucket_object.html) --- s3keyring/s3.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/s3keyring/s3.py b/s3keyring/s3.py index 3ac1572..4ab371d 100644 --- a/s3keyring/s3.py +++ b/s3keyring/s3.py @@ -150,9 +150,13 @@ def set_password(self, service, username, password): # Save in S3 using both server and client side encryption keyname = self._get_s3_key(service, username) try: - self.bucket.Object(keyname).put(ACL='private', Body=pwd_base64, - ServerSideEncryption='aws:kms', - SSEKMSKeyId=self.kms_key_id) + self.bucket.Object(keyname).put( + ACL='private', + Body=pwd_base64, + ContentType='text/plain', + ServerSideEncryption='aws:kms', + SSEKMSKeyId=self.kms_key_id + ) except EndpointConnectionError: if self.use_local_keyring: # Can't connect to S3: fallback to OS keyring