Skip to content

Commit

Permalink
Merge pull request #3085 from jwieringa/fix-ebs-snapshot
Browse files Browse the repository at this point in the history
Fixed name on resource_aws_ebs_snapshot kms_key_id
  • Loading branch information
bflad authored Jan 23, 2018
2 parents 6b1ce77 + 350c7f9 commit fa3a4fc
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aws/resource_aws_ebs_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func resourceAwsEbsSnapshotRead(d *schema.ResourceData, meta interface{}) error
d.Set("owner_alias", snapshot.OwnerAlias)
d.Set("volume_id", snapshot.VolumeId)
d.Set("data_encryption_key_id", snapshot.DataEncryptionKeyId)
d.Set("kms_keey_id", snapshot.KmsKeyId)
d.Set("kms_key_id", snapshot.KmsKeyId)
d.Set("volume_size", snapshot.VolumeSize)

if err := d.Set("tags", tagsToMap(snapshot.Tags)); err != nil {
Expand Down
48 changes: 48 additions & 0 deletions aws/resource_aws_ebs_snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package aws

import (
"fmt"
"regexp"
"testing"

"github.com/aws/aws-sdk-go/aws"
Expand Down Expand Up @@ -44,6 +45,24 @@ func TestAccAWSEBSSnapshot_withDescription(t *testing.T) {
})
}

func TestAccAWSEBSSnapshot_withKms(t *testing.T) {
var v ec2.Snapshot
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccAwsEbsSnapshotConfigWithKms,
Check: resource.ComposeTestCheckFunc(
testAccCheckSnapshotExists("aws_ebs_snapshot.test", &v),
resource.TestMatchResourceAttr("aws_ebs_snapshot.test", "kms_key_id",
regexp.MustCompile("^arn:aws:kms:[a-z]{2}-[a-z]+-\\d{1}:[0-9]{12}:key/[a-z0-9-]{36}$")),
),
},
},
})
}

func testAccCheckSnapshotExists(n string, v *ec2.Snapshot) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
Expand Down Expand Up @@ -98,3 +117,32 @@ resource "aws_ebs_snapshot" "test" {
description = "EBS Snapshot Acceptance Test"
}
`

const testAccAwsEbsSnapshotConfigWithKms = `
resource "aws_kms_key" "test" {
deletion_window_in_days = 7
tags {
Name = "testAccAwsEbsSnapshotConfigWithKms"
}
}
resource "aws_ebs_volume" "test" {
availability_zone = "us-west-2a"
size = 1
encrypted = true
kms_key_id = "${aws_kms_key.test.arn}"
tags {
Name = "testAccAwsEbsSnapshotConfigWithKms"
}
}
resource "aws_ebs_snapshot" "test" {
volume_id = "${aws_ebs_volume.test.id}"
tags {
Name = "testAccAwsEbsSnapshotConfigWithKms"
}
}
`

0 comments on commit fa3a4fc

Please sign in to comment.