From 5aaf9c36414b7c14d158d4fa41e633c1634ca11a Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Fri, 14 Aug 2020 22:56:09 +0300 Subject: [PATCH] use v2 api --- ...resource_aws_backup_vault_notifications.go | 35 ++++++------------- ...rce_aws_backup_vault_notifications_test.go | 8 ++--- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/aws/resource_aws_backup_vault_notifications.go b/aws/resource_aws_backup_vault_notifications.go index 2ab012184ba..38a7fc79736 100644 --- a/aws/resource_aws_backup_vault_notifications.go +++ b/aws/resource_aws_backup_vault_notifications.go @@ -7,8 +7,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/backup" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) func resourceAwsBackupVaultNotifications() *schema.Resource { @@ -22,10 +22,13 @@ func resourceAwsBackupVaultNotifications() *schema.Resource { Schema: map[string]*schema.Schema{ "backup_vault_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9\-\_\.]{1,50}$`), "must consist of lowercase letters, numbers, and hyphens."), + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.All( + validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9\-\_\.]$`), "must consist of lowercase letters, numbers, and hyphens."), + validation.StringLenBetween(1, 50), + ), }, "sns_topic_arn": { Type: schema.TypeString, @@ -38,24 +41,8 @@ func resourceAwsBackupVaultNotifications() *schema.Resource { Required: true, ForceNew: true, Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validation.StringInSlice([]string{ - backup.VaultEventBackupJobStarted, - backup.VaultEventBackupJobCompleted, - backup.VaultEventBackupJobSuccessful, - backup.VaultEventBackupJobFailed, - backup.VaultEventBackupJobExpired, - backup.VaultEventRestoreJobStarted, - backup.VaultEventRestoreJobSuccessful, - backup.VaultEventRestoreJobCompleted, - backup.VaultEventRestoreJobFailed, - backup.VaultEventCopyJobFailed, - backup.VaultEventCopyJobStarted, - backup.VaultEventCopyJobSuccessful, - backup.VaultEventRecoveryPointModified, - backup.VaultEventBackupPlanCreated, - backup.VaultEventBackupPlanModified, - }, false), + Type: schema.TypeString, + ValidateFunc: validation.StringInSlice(backup.VaultEvent_Values(), false), }, }, "backup_vault_arn": { diff --git a/aws/resource_aws_backup_vault_notifications_test.go b/aws/resource_aws_backup_vault_notifications_test.go index 8f86131428c..0f74ae226e3 100644 --- a/aws/resource_aws_backup_vault_notifications_test.go +++ b/aws/resource_aws_backup_vault_notifications_test.go @@ -2,15 +2,15 @@ package aws import ( "fmt" - "github.com/hashicorp/go-multierror" "log" "testing" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/backup" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/go-multierror" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) func init() {