Skip to content

Commit

Permalink
Merge pull request #2903 from kjmkznr/remote-s3-sse-kms
Browse files Browse the repository at this point in the history
state/remote/s3: Allows KMS Key Encryption setting when using S3 backend with encrypt
  • Loading branch information
phinze committed Jan 20, 2016
2 parents 9020960 + 9186c29 commit ba21769
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion state/remote/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func s3Factory(conf map[string]string) (Client, error) {
if raw, ok := conf["acl"]; ok {
acl = raw
}
kmsKeyID := conf["kms_key_id"]

accessKeyId := conf["access_key"]
secretAccessKey := conf["secret_key"]
Expand Down Expand Up @@ -95,6 +96,7 @@ func s3Factory(conf map[string]string) (Client, error) {
keyName: keyName,
serverSideEncryption: serverSideEncryption,
acl: acl,
kmsKeyID: kmsKeyID,
}, nil
}

Expand All @@ -104,6 +106,7 @@ type S3Client struct {
keyName string
serverSideEncryption bool
acl string
kmsKeyID string
}

func (c *S3Client) Get() (*Payload, error) {
Expand Down Expand Up @@ -156,7 +159,12 @@ func (c *S3Client) Put(data []byte) error {
}

if c.serverSideEncryption {
i.ServerSideEncryption = aws.String("AES256")
if c.kmsKeyID != "" {
i.SSEKMSKeyId = &c.kmsKeyID
i.ServerSideEncryption = aws.String("aws:kms")
} else {
i.ServerSideEncryption = aws.String("AES256")
}
}

if c.acl != "" {
Expand Down

0 comments on commit ba21769

Please sign in to comment.