Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add efs_file_system_backup_policy resource #18006

Merged
merged 11 commits into from
Jun 23, 2021
Prev Previous commit
Next Next commit
Rename 'aws_efs_file_system_backup_policy' to 'aws_efs_backup_policy'.
Acceptance test output:

% make testacc TEST=./aws TESTARGS='-run=TestAccAWSEFSBackupPolicy_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSEFSBackupPolicy_ -timeout 180m
=== RUN   TestAccAWSEFSBackupPolicy_basic
=== PAUSE TestAccAWSEFSBackupPolicy_basic
=== RUN   TestAccAWSEFSBackupPolicy_disappears_fs
=== PAUSE TestAccAWSEFSBackupPolicy_disappears_fs
=== RUN   TestAccAWSEFSBackupPolicy_update
=== PAUSE TestAccAWSEFSBackupPolicy_update
=== CONT  TestAccAWSEFSBackupPolicy_basic
=== CONT  TestAccAWSEFSBackupPolicy_update
=== CONT  TestAccAWSEFSBackupPolicy_disappears_fs
--- PASS: TestAccAWSEFSBackupPolicy_disappears_fs (22.38s)
--- PASS: TestAccAWSEFSBackupPolicy_basic (28.27s)
--- PASS: TestAccAWSEFSBackupPolicy_update (50.06s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	53.142s
  • Loading branch information
ewbankkit committed Jun 23, 2021

Verified

This commit was signed with the committer’s verified signature.
ollyw Oliver Wickham
commit ee0ef97ed7f99c1dc0b6022c00e989dc949f7a51
2 changes: 1 addition & 1 deletion aws/provider.go
Original file line number Diff line number Diff line change
@@ -713,8 +713,8 @@ func Provider() *schema.Provider {
"aws_ecs_service": resourceAwsEcsService(),
"aws_ecs_task_definition": resourceAwsEcsTaskDefinition(),
"aws_efs_access_point": resourceAwsEfsAccessPoint(),
"aws_efs_backup_policy": resourceAwsEfsBackupPolicy(),
"aws_efs_file_system": resourceAwsEfsFileSystem(),
"aws_efs_file_system_backup_policy": resourceAwsEfsFileSystemBackupPolicy(),
"aws_efs_file_system_policy": resourceAwsEfsFileSystemPolicy(),
"aws_efs_mount_target": resourceAwsEfsMountTarget(),
"aws_egress_only_internet_gateway": resourceAwsEgressOnlyInternetGateway(),
Original file line number Diff line number Diff line change
@@ -14,12 +14,12 @@ import (
"github.com/terraform-providers/terraform-provider-aws/aws/internal/tfresource"
)

func resourceAwsEfsFileSystemBackupPolicy() *schema.Resource {
func resourceAwsEfsBackupPolicy() *schema.Resource {
return &schema.Resource{
Create: resourceAwsEfsFileSystemBackupPolicyCreate,
Read: resourceAwsEfsFileSystemBackupPolicyRead,
Update: resourceAwsEfsFileSystemBackupPolicyUpdate,
Delete: resourceAwsEfsFileSystemBackupPolicyDelete,
Create: resourceAwsEfsBackupPolicyCreate,
Read: resourceAwsEfsBackupPolicyRead,
Update: resourceAwsEfsBackupPolicyUpdate,
Delete: resourceAwsEfsBackupPolicyDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
@@ -52,7 +52,7 @@ func resourceAwsEfsFileSystemBackupPolicy() *schema.Resource {
}
}

func resourceAwsEfsFileSystemBackupPolicyCreate(d *schema.ResourceData, meta interface{}) error {
func resourceAwsEfsBackupPolicyCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).efsconn

fsID := d.Get("file_system_id").(string)
@@ -63,10 +63,10 @@ func resourceAwsEfsFileSystemBackupPolicyCreate(d *schema.ResourceData, meta int

d.SetId(fsID)

return resourceAwsEfsFileSystemBackupPolicyRead(d, meta)
return resourceAwsEfsBackupPolicyRead(d, meta)
}

func resourceAwsEfsFileSystemBackupPolicyRead(d *schema.ResourceData, meta interface{}) error {
func resourceAwsEfsBackupPolicyRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).efsconn

output, err := finder.BackupPolicyByID(conn, d.Id())
@@ -90,17 +90,17 @@ func resourceAwsEfsFileSystemBackupPolicyRead(d *schema.ResourceData, meta inter
return nil
}

func resourceAwsEfsFileSystemBackupPolicyUpdate(d *schema.ResourceData, meta interface{}) error {
func resourceAwsEfsBackupPolicyUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).efsconn

if err := efsBackupPolicyPut(conn, d.Id(), d.Get("backup_policy").([]interface{})[0].(map[string]interface{})); err != nil {
return err
}

return resourceAwsEfsFileSystemBackupPolicyRead(d, meta)
return resourceAwsEfsBackupPolicyRead(d, meta)
}

func resourceAwsEfsFileSystemBackupPolicyDelete(d *schema.ResourceData, meta interface{}) error {
func resourceAwsEfsBackupPolicyDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).efsconn

err := efsBackupPolicyPut(conn, d.Id(), map[string]interface{}{
Original file line number Diff line number Diff line change
@@ -13,21 +13,21 @@ import (
"github.com/terraform-providers/terraform-provider-aws/aws/internal/tfresource"
)

func TestAccAWSEFSFileSystemBackupPolicy_basic(t *testing.T) {
func TestAccAWSEFSBackupPolicy_basic(t *testing.T) {
var v efs.BackupPolicy
resourceName := "aws_efs_file_system_backup_policy.test"
resourceName := "aws_efs_backup_policy.test"
rName := acctest.RandomWithPrefix("tf-acc-test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ErrorCheck: testAccErrorCheck(t, efs.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckEfsFileSystemBackupPolicyDestroy,
CheckDestroy: testAccCheckEfsBackupPolicyDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSEFSFileSystemBackupPolicyConfig(rName, "ENABLED"),
Config: testAccAWSEFSBackupPolicyConfig(rName, "ENABLED"),
Check: resource.ComposeTestCheckFunc(
testAccCheckEFSFileSystemBackupPolicyExists(resourceName, &v),
testAccCheckEFSBackupPolicyExists(resourceName, &v),
resource.TestCheckResourceAttr(resourceName, "backup_policy.#", "1"),
resource.TestCheckResourceAttr(resourceName, "backup_policy.0.status", "ENABLED"),
),
@@ -41,22 +41,22 @@ func TestAccAWSEFSFileSystemBackupPolicy_basic(t *testing.T) {
})
}

func TestAccAWSEFSFileSystemBackupPolicy_disappears_fs(t *testing.T) {
func TestAccAWSEFSBackupPolicy_disappears_fs(t *testing.T) {
var v efs.BackupPolicy
resourceName := "aws_efs_file_system_backup_policy.test"
resourceName := "aws_efs_backup_policy.test"
fsResourceName := "aws_efs_file_system.test"
rName := acctest.RandomWithPrefix("tf-acc-test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ErrorCheck: testAccErrorCheck(t, efs.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckEfsFileSystemBackupPolicyDestroy,
CheckDestroy: testAccCheckEfsBackupPolicyDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSEFSFileSystemBackupPolicyConfig(rName, "ENABLED"),
Config: testAccAWSEFSBackupPolicyConfig(rName, "ENABLED"),
Check: resource.ComposeTestCheckFunc(
testAccCheckEFSFileSystemBackupPolicyExists(resourceName, &v),
testAccCheckEFSBackupPolicyExists(resourceName, &v),
testAccCheckResourceDisappears(testAccProvider, resourceAwsEfsFileSystem(), fsResourceName),
),
ExpectNonEmptyPlan: true,
@@ -65,21 +65,21 @@ func TestAccAWSEFSFileSystemBackupPolicy_disappears_fs(t *testing.T) {
})
}

func TestAccAWSEFSFileSystemBackupPolicy_update(t *testing.T) {
func TestAccAWSEFSBackupPolicy_update(t *testing.T) {
var v efs.BackupPolicy
resourceName := "aws_efs_file_system_backup_policy.test"
resourceName := "aws_efs_backup_policy.test"
rName := acctest.RandomWithPrefix("tf-acc-test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ErrorCheck: testAccErrorCheck(t, efs.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckEfsFileSystemBackupPolicyDestroy,
CheckDestroy: testAccCheckEfsBackupPolicyDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSEFSFileSystemBackupPolicyConfig(rName, "DISABLED"),
Config: testAccAWSEFSBackupPolicyConfig(rName, "DISABLED"),
Check: resource.ComposeTestCheckFunc(
testAccCheckEFSFileSystemBackupPolicyExists(resourceName, &v),
testAccCheckEFSBackupPolicyExists(resourceName, &v),
resource.TestCheckResourceAttr(resourceName, "backup_policy.#", "1"),
resource.TestCheckResourceAttr(resourceName, "backup_policy.0.status", "DISABLED"),
),
@@ -90,17 +90,17 @@ func TestAccAWSEFSFileSystemBackupPolicy_update(t *testing.T) {
ImportStateVerify: true,
},
{
Config: testAccAWSEFSFileSystemBackupPolicyConfig(rName, "ENABLED"),
Config: testAccAWSEFSBackupPolicyConfig(rName, "ENABLED"),
Check: resource.ComposeTestCheckFunc(
testAccCheckEFSFileSystemBackupPolicyExists(resourceName, &v),
testAccCheckEFSBackupPolicyExists(resourceName, &v),
resource.TestCheckResourceAttr(resourceName, "backup_policy.#", "1"),
resource.TestCheckResourceAttr(resourceName, "backup_policy.0.status", "ENABLED"),
),
},
{
Config: testAccAWSEFSFileSystemBackupPolicyConfig(rName, "DISABLED"),
Config: testAccAWSEFSBackupPolicyConfig(rName, "DISABLED"),
Check: resource.ComposeTestCheckFunc(
testAccCheckEFSFileSystemBackupPolicyExists(resourceName, &v),
testAccCheckEFSBackupPolicyExists(resourceName, &v),
resource.TestCheckResourceAttr(resourceName, "backup_policy.#", "1"),
resource.TestCheckResourceAttr(resourceName, "backup_policy.0.status", "DISABLED"),
),
@@ -109,7 +109,7 @@ func TestAccAWSEFSFileSystemBackupPolicy_update(t *testing.T) {
})
}

func testAccCheckEFSFileSystemBackupPolicyExists(name string, v *efs.BackupPolicy) resource.TestCheckFunc {
func testAccCheckEFSBackupPolicyExists(name string, v *efs.BackupPolicy) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[name]
if !ok {
@@ -134,11 +134,11 @@ func testAccCheckEFSFileSystemBackupPolicyExists(name string, v *efs.BackupPolic
}
}

func testAccCheckEfsFileSystemBackupPolicyDestroy(s *terraform.State) error {
func testAccCheckEfsBackupPolicyDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).efsconn

for _, rs := range s.RootModule().Resources {
if rs.Type != "aws_efs_file_system_backup_policy" {
if rs.Type != "aws_efs_backup_policy" {
continue
}

@@ -162,13 +162,13 @@ func testAccCheckEfsFileSystemBackupPolicyDestroy(s *terraform.State) error {
return nil
}

func testAccAWSEFSFileSystemBackupPolicyConfig(rName, status string) string {
func testAccAWSEFSBackupPolicyConfig(rName, status string) string {
return fmt.Sprintf(`
resource "aws_efs_file_system" "test" {
creation_token = %[1]q
}

resource "aws_efs_file_system_backup_policy" "test" {
resource "aws_efs_backup_policy" "test" {
file_system_id = aws_efs_file_system.test.id

backup_policy {
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
subcategory: "EFS"
layout: "aws"
page_title: "AWS: aws_efs_file_system_backup_policy"
page_title: "AWS: aws_efs_backup_policy"
description: |-
Provides an Elastic File System (EFS) File System Backup Policy resource.
Provides an Elastic File System (EFS) Backup Policy resource.
---

# Resource: aws_efs_file_system_backup_policy

Provides an Elastic File System (EFS) File System Backup Policy resource.
Provides an Elastic File System (EFS) Backup Policy resource.
Backup policies turn automatic backups on or off for an existing file system.

## Example Usage

@@ -17,7 +18,7 @@ resource "aws_efs_file_system" "fs" {
creation_token = "my-product"
}

resource "aws_efs_file_system_backup_policy" "policy" {
resource "aws_efs_backup_policy" "policy" {
file_system_id = aws_efs_file_system.fs.id

backup_policy {
@@ -31,7 +32,7 @@ resource "aws_efs_file_system_backup_policy" "policy" {
The following arguments are supported:

* `file_system_id` - (Required) The ID of the EFS file system.
* `backup_policy` - (Required) A file system backup_policy object (documented below).
* `backup_policy` - (Required) A backup_policy object (documented below).

### Backup Policy Arguments
For **backup_policy** the following attributes are supported:
@@ -46,7 +47,7 @@ In addition to all arguments above, the following attributes are exported:

## Import

The EFS file system backup policies can be imported using the `id`, e.g.
The EFS backup policies can be imported using the `id`, e.g.

```
$ terraform import aws_efs_file_system_backup_policy.example fs-6fa144c6