Skip to content

Commit

Permalink
Renamed aws_copy_snapshot to aws_ebs_snapshot_copy
Browse files Browse the repository at this point in the history
I took another look at the original naming, aws_copy_snapshot, and I've
reasoned that it was not consistent with resources like aws_ami_copy.
Thus, I've modified the resource to be aws_ebs_snapshot_copy to conform
to aws_<resource>_<action> which I thought matched existing resources better.
  • Loading branch information
jwieringa committed Jul 10, 2018
1 parent 0fe1b9c commit 7e7dc07
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 53 deletions.
2 changes: 1 addition & 1 deletion aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ func Provider() terraform.ResourceProvider {
"aws_dynamodb_table_item": resourceAwsDynamoDbTableItem(),
"aws_dynamodb_global_table": resourceAwsDynamoDbGlobalTable(),
"aws_ebs_snapshot": resourceAwsEbsSnapshot(),
"aws_copy_snapshot": resourceAwsCopySnapshot(),
"aws_ebs_snapshot_copy": resourceAwsEbsSnapshotCopy(),
"aws_ebs_volume": resourceAwsEbsVolume(),
"aws_ecr_lifecycle_policy": resourceAwsEcrLifecyclePolicy(),
"aws_ecr_repository": resourceAwsEcrRepository(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
"github.com/hashicorp/terraform/helper/schema"
)

func resourceAwsCopySnapshot() *schema.Resource {
func resourceAwsEbsSnapshotCopy() *schema.Resource {
return &schema.Resource{
Create: resourceAwsCopySnapshotCreate,
Read: resourceAwsCopySnapshotRead,
Delete: resourceAwsCopySnapshotDelete,
Create: resourceAwsEbsSnapshotCopyCreate,
Read: resourceAwsEbsSnapshotCopyRead,
Delete: resourceAwsEbsSnapshotCopyDelete,

Schema: map[string]*schema.Schema{
"volume_id": {
Expand Down Expand Up @@ -73,7 +73,7 @@ func resourceAwsCopySnapshot() *schema.Resource {
}
}

func resourceAwsCopySnapshotCreate(d *schema.ResourceData, meta interface{}) error {
func resourceAwsEbsSnapshotCopyCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).ec2conn

request := &ec2.CopySnapshotInput{
Expand All @@ -97,7 +97,7 @@ func resourceAwsCopySnapshotCreate(d *schema.ResourceData, meta interface{}) err

d.SetId(*res.SnapshotId)

err = resourceAwsCopySnapshotWaitForAvailable(d.Id(), conn)
err = resourceAwsEbsSnapshotCopyWaitForAvailable(d.Id(), conn)
if err != nil {
return err
}
Expand All @@ -106,10 +106,10 @@ func resourceAwsCopySnapshotCreate(d *schema.ResourceData, meta interface{}) err
log.Printf("[WARN] error setting tags: %s", err)
}

return resourceAwsCopySnapshotRead(d, meta)
return resourceAwsEbsSnapshotCopyRead(d, meta)
}

func resourceAwsCopySnapshotRead(d *schema.ResourceData, meta interface{}) error {
func resourceAwsEbsSnapshotCopyRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).ec2conn

req := &ec2.DescribeSnapshotsInput{
Expand Down Expand Up @@ -140,7 +140,7 @@ func resourceAwsCopySnapshotRead(d *schema.ResourceData, meta interface{}) error
return nil
}

func resourceAwsCopySnapshotDelete(d *schema.ResourceData, meta interface{}) error {
func resourceAwsEbsSnapshotCopyDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).ec2conn

return resource.Retry(5*time.Minute, func() *resource.RetryError {
Expand All @@ -165,7 +165,7 @@ func resourceAwsCopySnapshotDelete(d *schema.ResourceData, meta interface{}) err
})
}

func resourceAwsCopySnapshotWaitForAvailable(id string, conn *ec2.EC2) error {
func resourceAwsEbsSnapshotCopyWaitForAvailable(id string, conn *ec2.EC2) error {
log.Printf("Waiting for Snapshot %s to become available...", id)

req := &ec2.DescribeSnapshotsInput{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,41 @@ import (
"github.com/hashicorp/terraform/terraform"
)

func TestAccAWSCopySnapshot_basic(t *testing.T) {
func TestAccAWSEbsSnapshotCopy_basic(t *testing.T) {
var v ec2.Snapshot
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccAwsCopySnapshotConfig,
Config: testAccAwsEbsSnapshotCopyConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckCopySnapshotExists("aws_copy_snapshot.test", &v),
testAccCheckTags(&v.Tags, "Name", "testAccAwsCopySnapshotConfig"),
testAccCheckEbsSnapshotCopyExists("aws_ebs_snapshot_copy.test", &v),
testAccCheckTags(&v.Tags, "Name", "testAccAwsEbsSnapshotCopyConfig"),
),
},
},
})
}

func TestAccAWSCopySnapshot_withDescription(t *testing.T) {
func TestAccAWSEbsSnapshotCopy_withDescription(t *testing.T) {
var v ec2.Snapshot
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccAwsCopySnapshotConfigWithDescription,
Config: testAccAwsEbsSnapshotCopyConfigWithDescription,
Check: resource.ComposeTestCheckFunc(
testAccCheckCopySnapshotExists("aws_copy_snapshot.description_test", &v),
resource.TestCheckResourceAttr("aws_copy_snapshot.description_test", "description", "Copy Snapshot Acceptance Test"),
testAccCheckEbsSnapshotCopyExists("aws_ebs_snapshot_copy.description_test", &v),
resource.TestCheckResourceAttr("aws_ebs_snapshot_copy.description_test", "description", "Copy Snapshot Acceptance Test"),
),
},
},
})
}

func TestAccAWSCopySnapshot_withRegions(t *testing.T) {
func TestAccAWSEbsSnapshotCopy_withRegions(t *testing.T) {
var v ec2.Snapshot

// record the initialized providers so that we can use them to
Expand All @@ -65,40 +65,40 @@ func TestAccAWSCopySnapshot_withRegions(t *testing.T) {
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: testAccAwsCopySnapshotConfigWithRegions,
Config: testAccAwsEbsSnapshotCopyConfigWithRegions,
Check: resource.ComposeTestCheckFunc(
testAccCheckCopySnapshotExistsWithProviders("aws_copy_snapshot.region_test", &v, &providers),
testAccCheckEbsSnapshotCopyExistsWithProviders("aws_ebs_snapshot_copy.region_test", &v, &providers),
),
},
},
})

}

func TestAccAWSCopySnapshot_withKms(t *testing.T) {
func TestAccAWSEbsSnapshotCopy_withKms(t *testing.T) {
var v ec2.Snapshot
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccAwsCopySnapshotConfigWithKms,
Config: testAccAwsEbsSnapshotCopyConfigWithKms,
Check: resource.ComposeTestCheckFunc(
testAccCheckCopySnapshotExists("aws_copy_snapshot.kms_test", &v),
resource.TestMatchResourceAttr("aws_copy_snapshot.kms_test", "kms_key_id",
testAccCheckEbsSnapshotCopyExists("aws_ebs_snapshot_copy.kms_test", &v),
resource.TestMatchResourceAttr("aws_ebs_snapshot_copy.kms_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 testAccCheckCopySnapshotExists(n string, v *ec2.Snapshot) resource.TestCheckFunc {
func testAccCheckEbsSnapshotCopyExists(n string, v *ec2.Snapshot) resource.TestCheckFunc {
providers := []*schema.Provider{testAccProvider}
return testAccCheckCopySnapshotExistsWithProviders(n, v, &providers)
return testAccCheckEbsSnapshotCopyExistsWithProviders(n, v, &providers)
}

func testAccCheckCopySnapshotExistsWithProviders(n string, v *ec2.Snapshot, providers *[]*schema.Provider) resource.TestCheckFunc {
func testAccCheckEbsSnapshotCopyExistsWithProviders(n string, v *ec2.Snapshot, providers *[]*schema.Provider) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
Expand Down Expand Up @@ -133,7 +133,7 @@ func testAccCheckCopySnapshotExistsWithProviders(n string, v *ec2.Snapshot, prov
}
}

const testAccAwsCopySnapshotConfig = `
const testAccAwsEbsSnapshotCopyConfig = `
resource "aws_ebs_volume" "test" {
availability_zone = "us-west-2a"
size = 1
Expand All @@ -143,27 +143,27 @@ resource "aws_ebs_snapshot" "test" {
volume_id = "${aws_ebs_volume.test.id}"
tags {
Name = "testAccAwsEbsSnapshotConfig"
Name = "testAccAwsEbsSnapshotCopyConfig"
}
}
resource "aws_copy_snapshot" "test" {
resource "aws_ebs_snapshot_copy" "test" {
source_snapshot_id = "${aws_ebs_snapshot.test.id}"
source_region = "us-west-2"
tags {
Name = "testAccAwsCopySnapshotConfig"
Name = "testAccAwsEbsSnapshotCopyConfig"
}
}
`

const testAccAwsCopySnapshotConfigWithDescription = `
const testAccAwsEbsSnapshotCopyConfigWithDescription = `
resource "aws_ebs_volume" "description_test" {
availability_zone = "us-west-2a"
size = 1
tags {
Name = "testAccAwsCopySnapshotConfigWithDescription"
Name = "testAccAwsEbsSnapshotCopyConfigWithDescription"
}
}
Expand All @@ -172,22 +172,22 @@ resource "aws_ebs_snapshot" "description_test" {
description = "EBS Snapshot Acceptance Test"
tags {
Name = "testAccAwsCopySnapshotConfigWithDescription"
Name = "testAccAwsEbsSnapshotCopyConfigWithDescription"
}
}
resource "aws_copy_snapshot" "description_test" {
resource "aws_ebs_snapshot_copy" "description_test" {
description = "Copy Snapshot Acceptance Test"
source_snapshot_id = "${aws_ebs_snapshot.description_test.id}"
source_region = "us-west-2"
tags {
Name = "testAccAwsCopySnapshotConfigWithDescription"
Name = "testAccAwsEbsSnapshotCopyConfigWithDescription"
}
}
`

const testAccAwsCopySnapshotConfigWithRegions = `
const testAccAwsEbsSnapshotCopyConfigWithRegions = `
provider "aws" {
region = "us-west-2"
alias = "uswest2"
Expand All @@ -204,7 +204,7 @@ resource "aws_ebs_volume" "region_test" {
size = 1
tags {
Name = "testAccAwsCopySnapshotConfigWithRegions"
Name = "testAccAwsEbsSnapshotCopyConfigWithRegions"
}
}
Expand All @@ -213,28 +213,28 @@ resource "aws_ebs_snapshot" "region_test" {
volume_id = "${aws_ebs_volume.region_test.id}"
tags {
Name = "testAccAwsCopySnapshotConfigWithRegions"
Name = "testAccAwsEbsSnapshotCopyConfigWithRegions"
}
}
resource "aws_copy_snapshot" "region_test" {
resource "aws_ebs_snapshot_copy" "region_test" {
provider = "aws.useast1"
source_snapshot_id = "${aws_ebs_snapshot.region_test.id}"
source_region = "us-west-2"
tags {
Name = "testAccAwsCopySnapshotConfigWithRegions"
Name = "testAccAwsEbsSnapshotCopyConfigWithRegions"
}
}
`

const testAccAwsCopySnapshotConfigWithKms = `
const testAccAwsEbsSnapshotCopyConfigWithKms = `
provider "aws" {
region = "us-west-2"
}
resource "aws_kms_key" "kms_test" {
description = "testAccAwsCopySnapshotConfigWithKms"
description = "testAccAwsEbsSnapshotCopyConfigWithKms"
deletion_window_in_days = 7
}
Expand All @@ -243,26 +243,26 @@ resource "aws_ebs_volume" "kms_test" {
size = 1
tags {
Name = "testAccAwsCopySnapshotConfigWithKms"
Name = "testAccAwsEbsSnapshotCopyConfigWithKms"
}
}
resource "aws_ebs_snapshot" "kms_test" {
volume_id = "${aws_ebs_volume.kms_test.id}"
tags {
Name = "testAccAwsCopySnapshotConfigWithKms"
Name = "testAccAwsEbsSnapshotCopyConfigWithKms"
}
}
resource "aws_copy_snapshot" "kms_test" {
resource "aws_ebs_snapshot_copy" "kms_test" {
source_snapshot_id = "${aws_ebs_snapshot.kms_test.id}"
source_region = "us-west-2"
encrypted = true
kms_key_id = "${aws_kms_key.kms_test.arn}"
tags {
Name = "testAccAwsCopySnapshotConfigWithKms"
Name = "testAccAwsEbsSnapshotCopyConfigWithKms"
}
}
`
8 changes: 4 additions & 4 deletions website/docs/r/copy_snapshot.html.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
layout: "aws"
page_title: "AWS: aws_copy_snapshot"
sidebar_current: "docs-aws-resource-copy-snapshot"
page_title: "AWS: aws_ebs_snapshot_copy"
sidebar_current: "docs-aws-resource-ebs-snapshot-copy"
description: |-
Duplicates an existing Amazon snapshot
---

# aws_copy_snapshot
# aws_ebs_snapshot_copy

Creates a Snapshot of a snapshot.

Expand All @@ -29,7 +29,7 @@ resource "aws_ebs_snapshot" "example_snapshot" {
}
}
resource "aws_copy_snapshot" "example_copy" {
resource "aws_ebs_snapshot_copy" "example_copy" {
source_snapshot_id = "${aws_ebs_snapshot.example_snapshot.id}"
source_region = "us-west-2"
Expand Down

0 comments on commit 7e7dc07

Please sign in to comment.