From 201fac4b0207f4aa58a2ce479dbf8a5ca1958fc2 Mon Sep 17 00:00:00 2001 From: Aleks1001 Date: Tue, 24 Aug 2021 00:19:50 -0400 Subject: [PATCH 01/13] Add new resource aws_chime_voice_connetor_termination --- CHANGELOG.md | 14 ++ aws/provider.go | 1 + ...e_aws_chime_voice_connector_termination.go | 191 ++++++++++++++++++ ..._chime_voice_connector_termination_test.go | 157 ++++++++++++++ ..._voice_connector_termination.html.markdown | 53 +++++ 5 files changed, 416 insertions(+) create mode 100644 aws/resource_aws_chime_voice_connector_termination.go create mode 100644 aws/resource_aws_chime_voice_connector_termination_test.go create mode 100644 website/docs/r/chime_voice_connector_termination.html.markdown diff --git a/CHANGELOG.md b/CHANGELOG.md index 993ae0b7f2a..dd2a45d4b9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,26 @@ FEATURES: * **New Resource:** `aws_dynamodb_tag` ([#13783](https://github.com/hashicorp/terraform-provider-aws/issues/13783)) * **New Resource:** `aws_ecs_tag` ([#13783](https://github.com/hashicorp/terraform-provider-aws/issues/13783)) +* **New Resource:** `aws_route53recoveryreadiness_cell` ([#20526](https://github.com/hashicorp/terraform-provider-aws/issues/20526)) +* **New Resource:** `aws_route53recoveryreadiness_readiness_check` ([#20526](https://github.com/hashicorp/terraform-provider-aws/issues/20526)) +* **New Resource:** `aws_route53recoveryreadiness_recovery_group` ([#20526](https://github.com/hashicorp/terraform-provider-aws/issues/20526)) +* **New Resource:** `aws_route53recoveryreadiness_resource_set` ([#20526](https://github.com/hashicorp/terraform-provider-aws/issues/20526)) ENHANCEMENTS: * data-source/aws_elasticache_user: Mark `passwords` attribute as sensitive. ([#20629](https://github.com/hashicorp/terraform-provider-aws/issues/20629)) +* data-source/aws_route53_zone: Add `arn` attribute ([#20652](https://github.com/hashicorp/terraform-provider-aws/issues/20652)) * resource/aws_elasticache_user: Mark `passwords` argument as sensitive. ([#20629](https://github.com/hashicorp/terraform-provider-aws/issues/20629)) * resource/aws_fsx_lustre_filesystem: Allow creating filesystem from backup using `backup_id`. ([#20614](https://github.com/hashicorp/terraform-provider-aws/issues/20614)) +* resource/aws_fsx_windows_filesystem: Allow creating filesystem from backup using `backup_id`. ([#20643](https://github.com/hashicorp/terraform-provider-aws/issues/20643)) +* resource/aws_route53_health_check: Add `arn` attribute. ([#20653](https://github.com/hashicorp/terraform-provider-aws/issues/20653)) +* resource/aws_route53_health_check: Add plan time validation for `failure_threshold`, `ip_address`, `fqdn`, `port`, `resource_path`, `search_string`, `child_healthchecks`. ([#20653](https://github.com/hashicorp/terraform-provider-aws/issues/20653)) +* resource/aws_route53_zone: Add `arn` attribute ([#20652](https://github.com/hashicorp/terraform-provider-aws/issues/20652)) +* resource/aws_route53_zone: Add plan time validation for `comment` ([#20652](https://github.com/hashicorp/terraform-provider-aws/issues/20652)) + +BUG FIXES: + +* data-source/aws_route53_resolver_rule: Fix lack of pagination when listing rules ([#20642](https://github.com/hashicorp/terraform-provider-aws/issues/20642)) ## 3.55.0 (August 19, 2021) diff --git a/aws/provider.go b/aws/provider.go index f00bdc90afb..c793f2c2492 100644 --- a/aws/provider.go +++ b/aws/provider.go @@ -552,6 +552,7 @@ func Provider() *schema.Provider { "aws_budgets_budget_action": resourceAwsBudgetsBudgetAction(), "aws_chime_voice_connector": resourceAwsChimeVoiceConnector(), "aws_chime_voice_connector_group": resourceAwsChimeVoiceConnectorGroup(), + "aws_chime_voice_connector_termination": resourceAwsChimeVoiceConnectorTermination(), "aws_cloud9_environment_ec2": resourceAwsCloud9EnvironmentEc2(), "aws_cloudformation_stack": resourceAwsCloudFormationStack(), "aws_cloudformation_stack_set": resourceAwsCloudFormationStackSet(), diff --git a/aws/resource_aws_chime_voice_connector_termination.go b/aws/resource_aws_chime_voice_connector_termination.go new file mode 100644 index 00000000000..ff2ce02cb2d --- /dev/null +++ b/aws/resource_aws_chime_voice_connector_termination.go @@ -0,0 +1,191 @@ +package aws + +import ( + "context" + "fmt" + "log" + "regexp" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/service/chime" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) + +func resourceAwsChimeVoiceConnectorTermination() *schema.Resource { + return &schema.Resource{ + CreateContext: resourceAwsChimeVoiceConnectorTerminationPut, + ReadContext: resourceAwsChimeVoiceConnectorTerminationRead, + UpdateContext: resourceAwsChimeVoiceConnectorTerminationUpdate, + DeleteContext: resourceAwsChimeVoiceConnectorTerminationDelete, + + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: map[string]*schema.Schema{ + "calling_regions": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringLenBetween(2, 2), + }, + }, + "cidr_allow_list": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.IsCIDRNetwork(27, 32), + }, + }, + "cps_limit": { + Type: schema.TypeInt, + Optional: true, + Default: 1, + ValidateFunc: validation.IntAtMost(1), + }, + "default_phone_number": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^\+?[1-9]\d{1,14}$`), "must match ^\\+?[1-9]\\d{1,14}$"), + }, + "disabled": { + Type: schema.TypeBool, + Optional: true, + }, + "voice_connector_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + }, + } +} + +func resourceAwsChimeVoiceConnectorTerminationPut(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + conn := meta.(*AWSClient).chimeconn + + vcId := d.Get("voice_connector_id").(string) + + input := &chime.PutVoiceConnectorTerminationInput{ + VoiceConnectorId: aws.String(vcId), + } + + termination := &chime.Termination{ + CidrAllowedList: expandStringList(d.Get("cidr_allow_list").([]interface{})), + CallingRegions: expandStringList(d.Get("calling_regions").([]interface{})), + } + + if v, ok := d.GetOk("disabled"); ok { + termination.Disabled = aws.Bool(v.(bool)) + } + + if v, ok := d.GetOk("cps_limit"); ok { + termination.CpsLimit = aws.Int64(int64(v.(int))) + } + + if v, ok := d.GetOk("default_phone_number"); ok { + termination.DefaultPhoneNumber = aws.String(v.(string)) + } + + input.Termination = termination + + if _, err := conn.PutVoiceConnectorTerminationWithContext(ctx, input); err != nil { + return diag.Errorf("error creating Chime Voice Connector (%s) termination: %s", vcId, err) + } + + d.SetId(fmt.Sprintf("termination-%s", vcId)) + + return resourceAwsChimeVoiceConnectorTerminationRead(ctx, d, meta) +} + +func resourceAwsChimeVoiceConnectorTerminationRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + conn := meta.(*AWSClient).chimeconn + + vcId := d.Get("voice_connector_id").(string) + input := &chime.GetVoiceConnectorTerminationInput{ + VoiceConnectorId: aws.String(vcId), + } + + resp, err := conn.GetVoiceConnectorTerminationWithContext(ctx, input) + if !d.IsNewResource() && isAWSErr(err, chime.ErrCodeNotFoundException, "") { + log.Printf("[WARN] error getting Chime Voice Connector (%s) termination: %s", vcId, err) + d.SetId("") + return nil + } + + if err != nil || resp.Termination == nil { + return diag.Errorf("error getting Chime Voice Connector (%s) termination: %s", vcId, err) + } + + d.Set("cps_limit", resp.Termination.CpsLimit) + d.Set("disabled", resp.Termination.Disabled) + d.Set("default_phone_number", resp.Termination.DefaultPhoneNumber) + + if err := d.Set("calling_regions", flattenStringList(resp.Termination.CallingRegions)); err != nil { + return diag.Errorf("error setting termination calling regions (%s): %s", vcId, err) + } + if err := d.Set("cidr_allow_list", flattenStringList(resp.Termination.CidrAllowedList)); err != nil { + return diag.Errorf("error setting termination cidr allow list (%s): %s", vcId, err) + } + + return nil +} + +func resourceAwsChimeVoiceConnectorTerminationUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + conn := meta.(*AWSClient).chimeconn + + if d.HasChanges("calling_regions", "cidr_allow_list", "disabled", "cps_limit", "default_phone_number") { + vcId := d.Get("voice_connector_id").(string) + termination := &chime.Termination{ + CallingRegions: expandStringList(d.Get("calling_regions").([]interface{})), + CidrAllowedList: expandStringList(d.Get("cidr_allow_list").([]interface{})), + CpsLimit: aws.Int64(int64(d.Get("cps_limit").(int))), + } + + if v, ok := d.GetOk("default_phone_number"); ok { + termination.DefaultPhoneNumber = aws.String(v.(string)) + } + + if v, ok := d.GetOk("disabled"); ok { + termination.Disabled = aws.Bool(v.(bool)) + } + + input := &chime.PutVoiceConnectorTerminationInput{ + VoiceConnectorId: aws.String(vcId), + Termination: termination, + } + + if _, err := conn.PutVoiceConnectorTerminationWithContext(ctx, input); err != nil { + if isAWSErr(err, chime.ErrCodeNotFoundException, "") { + log.Printf("[WARN] error getting Chime Voice Connector (%s) termination: %s", vcId, err) + d.SetId("") + return nil + } + + return diag.Errorf("error updating Chime Voice Connector (%s) termination: %s", vcId, err) + } + } + + return resourceAwsChimeVoiceConnectorTerminationRead(ctx, d, meta) +} + +func resourceAwsChimeVoiceConnectorTerminationDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + conn := meta.(*AWSClient).chimeconn + + vcId := d.Get("voice_connector_id").(string) + input := &chime.DeleteVoiceConnectorTerminationInput{ + VoiceConnectorId: aws.String(vcId), + } + + if _, err := conn.DeleteVoiceConnectorTerminationWithContext(ctx, input); err != nil { + return diag.Errorf("error deleting Chime Voice Connector (%s) termination (%s): %s", vcId, d.Id(), err) + } + + return nil +} diff --git a/aws/resource_aws_chime_voice_connector_termination_test.go b/aws/resource_aws_chime_voice_connector_termination_test.go new file mode 100644 index 00000000000..481f7551f35 --- /dev/null +++ b/aws/resource_aws_chime_voice_connector_termination_test.go @@ -0,0 +1,157 @@ +package aws + +import ( + "fmt" + "testing" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/service/chime" + "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 TestAccAWSChimeVoiceConnectorTermination_basic(t *testing.T) { + var vc *chime.VoiceConnector + name := acctest.RandomWithPrefix("tf-acc-test") + vcResourceName := "aws_chime_voice_connector.chime" + resourceName := "aws_chime_voice_connector_termination.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, chime.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSChimeVoiceConnectorDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSChimeVoiceConnectorTerminationConfig(name), + + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckAWSChimeVoiceConnectorExists(vcResourceName, vc), + resource.TestCheckResourceAttr(resourceName, "cps_limit", "1"), + resource.TestCheckResourceAttr(resourceName, "calling_regions.#", "2"), + resource.TestCheckResourceAttr(resourceName, "cidr_allow_list.#", "1"), + resource.TestCheckResourceAttr(resourceName, "disabled", "false"), + ), + }, + { + ResourceName: vcResourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAWSChimeVoiceConnectorTermination_disappears(t *testing.T) { + name := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_chime_voice_connector_termination.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, chime.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSChimeVoiceConnectorDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSChimeVoiceConnectorTerminationConfig(name), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSChimeVoiceConnectorTerminationExists(resourceName), + testAccCheckResourceDisappears(testAccProvider, resourceAwsChimeVoiceConnectorTermination(), resourceName), + ), + ExpectNonEmptyPlan: true, + }, + }, + }) +} + +func TestAccAWSChimeVoiceConnectorTermination_update(t *testing.T) { + var vc *chime.VoiceConnector + name := acctest.RandomWithPrefix("tf-acc-test") + vcResourceName := "aws_chime_voice_connector.chime" + resourceName := "aws_chime_voice_connector_termination.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, chime.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSChimeVoiceConnectorDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSChimeVoiceConnectorTerminationConfig(name), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckAWSChimeVoiceConnectorExists(vcResourceName, vc), + ), + }, + { + ResourceName: vcResourceName, + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccAWSChimeVoiceConnectorTerminationUpdated(name), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr(resourceName, "cps_limit", "1"), + resource.TestCheckResourceAttr(resourceName, "calling_regions.#", "3"), + ), + }, + }, + }) +} + +func testAccAWSChimeVoiceConnectorTerminationConfig(name string) string { + return fmt.Sprintf(` +resource "aws_chime_voice_connector" "chime" { + name = "vc-%[1]s" + require_encryption = true +} + +resource "aws_chime_voice_connector_termination" "test" { + voice_connector_id = aws_chime_voice_connector.chime.id + + calling_regions = ["US", "RU"] + cidr_allow_list = ["50.35.78.97/32"] +} +`, name) +} + +func testAccAWSChimeVoiceConnectorTerminationUpdated(name string) string { + return fmt.Sprintf(` +resource "aws_chime_voice_connector" "chime" { + name = "vc-%[1]s" + require_encryption = true +} + +resource "aws_chime_voice_connector_termination" "test" { + voice_connector_id = aws_chime_voice_connector.chime.id + disabled = false + calling_regions = ["US", "RU", "CA"] + cidr_allow_list = ["100.35.78.97/32"] +} +`, name) +} + +func testAccCheckAWSChimeVoiceConnectorTerminationExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[name] + if !ok { + return fmt.Errorf("not found: %s", name) + } + + if rs.Primary.ID == "" { + return fmt.Errorf("no Chime voice connector group ID is set") + } + + conn := testAccProvider.Meta().(*AWSClient).chimeconn + input := &chime.GetVoiceConnectorTerminationInput{ + VoiceConnectorId: aws.String(rs.Primary.Attributes["voice_connector_id"]), + } + + resp, err := conn.GetVoiceConnectorTermination(input) + if err != nil || resp.Termination == nil { + return err + } + + return nil + } +} diff --git a/website/docs/r/chime_voice_connector_termination.html.markdown b/website/docs/r/chime_voice_connector_termination.html.markdown new file mode 100644 index 00000000000..6d42b5500e4 --- /dev/null +++ b/website/docs/r/chime_voice_connector_termination.html.markdown @@ -0,0 +1,53 @@ +--- +subcategory: "Chime" +layout: "aws" +page_title: "AWS: aws_chime_voice_connector_termination" +description: |- + Enable Termination settings to control outbound calling from your SIP infrastructure. +--- + +# Resource: aws_chime_voice_connector_termination + +Enable Termination settings to control outbound calling from your SIP infrastructure. + +## Example Usage + +```terraform +resource "aws_chime_voice_connector" "default" { + name = "vc-name-test" + require_encryption = true +} + +resource "aws_chime_voice_connector_termination" "default" { + disabled = false + cps_limit = 1 + cidr_allow_list = ["50.35.78.96/31"] + calling_regions = ["US", "CA"] + voice_connector_id = aws_chime_voice_connector.default.id +} +``` + +## Argument Reference + +The following arguments are supported: + +* `voice_connector_id` - (Required) The Amazon Chime Voice Connector ID. +* `cidr_allow_list` - (Required) The IP addresses allowed to make calls, in CIDR format. +* `calling_regions` - (Required) The countries to which calls are allowed, in ISO 3166-1 alpha-2 format. +* `disabled` - (Optional) When termination settings are disabled, outbound calls can not be made. +* `default_phone_number` - (Optional) The default caller ID phone number. +* `cps_limit` - (Optional) The limit on calls per second. Max value based on account service quota. Default value of `1`. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `id` - The unique termination settings ID. + +## Import + +Configuration Recorder can be imported using the name, e.g. + +``` +$ terraform import aws_chime_voice_connector_termination.default example +``` \ No newline at end of file From 53ff343f5e95465e9a10c63d003c85960f915542 Mon Sep 17 00:00:00 2001 From: Aleks1001 Date: Tue, 24 Aug 2021 11:52:52 -0400 Subject: [PATCH 02/13] Add changelog file --- .changelog/20667.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/20667.txt diff --git a/.changelog/20667.txt b/.changelog/20667.txt new file mode 100644 index 00000000000..b84ccdb1e70 --- /dev/null +++ b/.changelog/20667.txt @@ -0,0 +1,3 @@ +```release-note:new-resource +aws_chime_voice_connector_termination +``` \ No newline at end of file From 2041fc356e0ba388f45c4e572f88459e0ce10cae Mon Sep 17 00:00:00 2001 From: Aleks1001 Date: Thu, 26 Aug 2021 10:58:42 -0400 Subject: [PATCH 03/13] Update assertions in tests --- aws/resource_aws_chime_voice_connector_termination_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aws/resource_aws_chime_voice_connector_termination_test.go b/aws/resource_aws_chime_voice_connector_termination_test.go index 481f7551f35..0b3a4833198 100644 --- a/aws/resource_aws_chime_voice_connector_termination_test.go +++ b/aws/resource_aws_chime_voice_connector_termination_test.go @@ -93,6 +93,9 @@ func TestAccAWSChimeVoiceConnectorTermination_update(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "cps_limit", "1"), resource.TestCheckResourceAttr(resourceName, "calling_regions.#", "3"), + resource.TestCheckResourceAttr(resourceName, "cidr_allow_list.0", "100.35.78.97/32"), + resource.TestCheckResourceAttr(resourceName, "disabled", "false"), + resource.TestCheckResourceAttr(resourceName, "default_phone_number", ""), ), }, }, From 7a26b2136aa3ade614eca5357e5f9f60dc43248e Mon Sep 17 00:00:00 2001 From: Alexey Kozyachiy Date: Fri, 3 Sep 2021 16:49:51 -0400 Subject: [PATCH 04/13] Update website/docs/r/chime_voice_connector_termination.html.markdown Co-authored-by: angie pinilla --- website/docs/r/chime_voice_connector_termination.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/chime_voice_connector_termination.html.markdown b/website/docs/r/chime_voice_connector_termination.html.markdown index 6d42b5500e4..d63d349f1d8 100644 --- a/website/docs/r/chime_voice_connector_termination.html.markdown +++ b/website/docs/r/chime_voice_connector_termination.html.markdown @@ -46,7 +46,7 @@ In addition to all arguments above, the following attributes are exported: ## Import -Configuration Recorder can be imported using the name, e.g. +Chime Voice Connector Termination can be imported using the `voice_connector_id`, e.g. ``` $ terraform import aws_chime_voice_connector_termination.default example From 759d4b4fc668be916bb4f346ba89f6cca2e31acf Mon Sep 17 00:00:00 2001 From: Alexey Kozyachiy Date: Fri, 3 Sep 2021 16:50:05 -0400 Subject: [PATCH 05/13] Update aws/resource_aws_chime_voice_connector_termination.go Co-authored-by: angie pinilla --- aws/resource_aws_chime_voice_connector_termination.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aws/resource_aws_chime_voice_connector_termination.go b/aws/resource_aws_chime_voice_connector_termination.go index ff2ce02cb2d..61c5723c35d 100644 --- a/aws/resource_aws_chime_voice_connector_termination.go +++ b/aws/resource_aws_chime_voice_connector_termination.go @@ -15,10 +15,10 @@ import ( func resourceAwsChimeVoiceConnectorTermination() *schema.Resource { return &schema.Resource{ - CreateContext: resourceAwsChimeVoiceConnectorTerminationPut, - ReadContext: resourceAwsChimeVoiceConnectorTerminationRead, - UpdateContext: resourceAwsChimeVoiceConnectorTerminationUpdate, - DeleteContext: resourceAwsChimeVoiceConnectorTerminationDelete, + CreateWithoutTimeout: resourceAwsChimeVoiceConnectorTerminationPut, + ReadWithoutTimeout resourceAwsChimeVoiceConnectorTerminationRead, + UpdateWithoutTimeout: resourceAwsChimeVoiceConnectorTerminationUpdate, + DeleteWithoutTimeout: resourceAwsChimeVoiceConnectorTerminationDelete, Importer: &schema.ResourceImporter{ StateContext: schema.ImportStatePassthroughContext, From 05f8b848c0285dab58c98f596da0188b10595d14 Mon Sep 17 00:00:00 2001 From: Alexey Kozyachiy Date: Fri, 3 Sep 2021 16:50:17 -0400 Subject: [PATCH 06/13] Update aws/resource_aws_chime_voice_connector_termination.go Co-authored-by: angie pinilla --- aws/resource_aws_chime_voice_connector_termination.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/resource_aws_chime_voice_connector_termination.go b/aws/resource_aws_chime_voice_connector_termination.go index 61c5723c35d..1297befc99d 100644 --- a/aws/resource_aws_chime_voice_connector_termination.go +++ b/aws/resource_aws_chime_voice_connector_termination.go @@ -67,7 +67,7 @@ func resourceAwsChimeVoiceConnectorTermination() *schema.Resource { } } -func resourceAwsChimeVoiceConnectorTerminationPut(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { +func resourceAwsChimeVoiceConnectorTerminationCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*AWSClient).chimeconn vcId := d.Get("voice_connector_id").(string) From da853aabbb8b97ff988d54eaaaada402071eb389 Mon Sep 17 00:00:00 2001 From: Alexey Kozyachiy Date: Fri, 3 Sep 2021 16:58:18 -0400 Subject: [PATCH 07/13] Update website/docs/r/chime_voice_connector_termination.html.markdown Co-authored-by: angie pinilla --- website/docs/r/chime_voice_connector_termination.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/chime_voice_connector_termination.html.markdown b/website/docs/r/chime_voice_connector_termination.html.markdown index d63d349f1d8..44267b6de27 100644 --- a/website/docs/r/chime_voice_connector_termination.html.markdown +++ b/website/docs/r/chime_voice_connector_termination.html.markdown @@ -42,7 +42,7 @@ The following arguments are supported: In addition to all arguments above, the following attributes are exported: -* `id` - The unique termination settings ID. +* `id` - The Amazon Chime Voice Connector ID. ## Import From 1264ed395d2c30df4bce08d1159099796f75021b Mon Sep 17 00:00:00 2001 From: Alexey Kozyachiy Date: Fri, 3 Sep 2021 16:58:32 -0400 Subject: [PATCH 08/13] Update website/docs/r/chime_voice_connector_termination.html.markdown Co-authored-by: angie pinilla --- website/docs/r/chime_voice_connector_termination.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/chime_voice_connector_termination.html.markdown b/website/docs/r/chime_voice_connector_termination.html.markdown index 44267b6de27..cab606cc72a 100644 --- a/website/docs/r/chime_voice_connector_termination.html.markdown +++ b/website/docs/r/chime_voice_connector_termination.html.markdown @@ -49,5 +49,5 @@ In addition to all arguments above, the following attributes are exported: Chime Voice Connector Termination can be imported using the `voice_connector_id`, e.g. ``` -$ terraform import aws_chime_voice_connector_termination.default example +$ terraform import aws_chime_voice_connector_termination.default abcdef1ghij2klmno3pqr4 ``` \ No newline at end of file From 5142b90f0025ebcd08b35088c0d385e5b78131c9 Mon Sep 17 00:00:00 2001 From: Aleks1001 Date: Fri, 3 Sep 2021 17:30:55 -0400 Subject: [PATCH 09/13] Address comments --- ...e_aws_chime_voice_connector_termination.go | 18 ++++++------ ..._chime_voice_connector_termination_test.go | 29 ++++++++++++++++++- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/aws/resource_aws_chime_voice_connector_termination.go b/aws/resource_aws_chime_voice_connector_termination.go index 1297befc99d..1e7e820e757 100644 --- a/aws/resource_aws_chime_voice_connector_termination.go +++ b/aws/resource_aws_chime_voice_connector_termination.go @@ -15,8 +15,8 @@ import ( func resourceAwsChimeVoiceConnectorTermination() *schema.Resource { return &schema.Resource{ - CreateWithoutTimeout: resourceAwsChimeVoiceConnectorTerminationPut, - ReadWithoutTimeout resourceAwsChimeVoiceConnectorTerminationRead, + CreateWithoutTimeout: resourceAwsChimeVoiceConnectorTerminationCreate, + ReadWithoutTimeout: resourceAwsChimeVoiceConnectorTerminationRead, UpdateWithoutTimeout: resourceAwsChimeVoiceConnectorTerminationUpdate, DeleteWithoutTimeout: resourceAwsChimeVoiceConnectorTerminationDelete, @@ -26,7 +26,7 @@ func resourceAwsChimeVoiceConnectorTermination() *schema.Resource { Schema: map[string]*schema.Schema{ "calling_regions": { - Type: schema.TypeList, + Type: schema.TypeSet, Required: true, MinItems: 1, Elem: &schema.Schema{ @@ -35,7 +35,7 @@ func resourceAwsChimeVoiceConnectorTermination() *schema.Resource { }, }, "cidr_allow_list": { - Type: schema.TypeList, + Type: schema.TypeSet, Required: true, MinItems: 1, Elem: &schema.Schema{ @@ -47,7 +47,7 @@ func resourceAwsChimeVoiceConnectorTermination() *schema.Resource { Type: schema.TypeInt, Optional: true, Default: 1, - ValidateFunc: validation.IntAtMost(1), + ValidateFunc: validation.IntAtLeast(1), }, "default_phone_number": { Type: schema.TypeString, @@ -77,8 +77,8 @@ func resourceAwsChimeVoiceConnectorTerminationCreate(ctx context.Context, d *sch } termination := &chime.Termination{ - CidrAllowedList: expandStringList(d.Get("cidr_allow_list").([]interface{})), - CallingRegions: expandStringList(d.Get("calling_regions").([]interface{})), + CidrAllowedList: expandStringSet(d.Get("cidr_allow_list").(*schema.Set)), + CallingRegions: expandStringSet(d.Get("calling_regions").(*schema.Set)), } if v, ok := d.GetOk("disabled"); ok { @@ -143,8 +143,8 @@ func resourceAwsChimeVoiceConnectorTerminationUpdate(ctx context.Context, d *sch if d.HasChanges("calling_regions", "cidr_allow_list", "disabled", "cps_limit", "default_phone_number") { vcId := d.Get("voice_connector_id").(string) termination := &chime.Termination{ - CallingRegions: expandStringList(d.Get("calling_regions").([]interface{})), - CidrAllowedList: expandStringList(d.Get("cidr_allow_list").([]interface{})), + CallingRegions: expandStringSet(d.Get("calling_regions").(*schema.Set)), + CidrAllowedList: expandStringSet(d.Get("cidr_allow_list").(*schema.Set)), CpsLimit: aws.Int64(int64(d.Get("cps_limit").(int))), } diff --git a/aws/resource_aws_chime_voice_connector_termination_test.go b/aws/resource_aws_chime_voice_connector_termination_test.go index 0b3a4833198..d0279942560 100644 --- a/aws/resource_aws_chime_voice_connector_termination_test.go +++ b/aws/resource_aws_chime_voice_connector_termination_test.go @@ -51,7 +51,7 @@ func TestAccAWSChimeVoiceConnectorTermination_disappears(t *testing.T) { PreCheck: func() { testAccPreCheck(t) }, ErrorCheck: testAccErrorCheck(t, chime.EndpointsID), Providers: testAccProviders, - CheckDestroy: testAccCheckAWSChimeVoiceConnectorDestroy, + CheckDestroy: testAccCheckAWSChimeVoiceConnectorTerminationDestroy, Steps: []resource.TestStep{ { Config: testAccAWSChimeVoiceConnectorTerminationConfig(name), @@ -158,3 +158,30 @@ func testAccCheckAWSChimeVoiceConnectorTerminationExists(name string) resource.T return nil } } + +func testAccCheckAWSChimeVoiceConnectorTerminationDestroy(s *terraform.State) error { + for _, rs := range s.RootModule().Resources { + if rs.Type != "aws_chime_voice_connector_termination" { + continue + } + conn := testAccProvider.Meta().(*AWSClient).chimeconn + input := &chime.GetVoiceConnectorTerminationInput{ + VoiceConnectorId: aws.String(rs.Primary.Attributes["voice_connector_id"]), + } + resp, err := conn.GetVoiceConnectorTermination(input) + + if isAWSErr(err, chime.ErrCodeNotFoundException, "") { + continue + } + + if err != nil { + return err + } + + if resp != nil && resp.Termination != nil { + return fmt.Errorf("error Chime Voice Connector Termination still exists") + } + } + + return nil +} From dec424cb21d7a7fb28b92f8d01e39617e8b2dbfe Mon Sep 17 00:00:00 2001 From: Alexey Kozyachiy Date: Tue, 7 Sep 2021 15:54:36 -0400 Subject: [PATCH 10/13] Update aws/resource_aws_chime_voice_connector_termination_test.go Co-authored-by: angie pinilla --- aws/resource_aws_chime_voice_connector_termination_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_chime_voice_connector_termination_test.go b/aws/resource_aws_chime_voice_connector_termination_test.go index d0279942560..01eaf0cd4eb 100644 --- a/aws/resource_aws_chime_voice_connector_termination_test.go +++ b/aws/resource_aws_chime_voice_connector_termination_test.go @@ -151,9 +151,13 @@ func testAccCheckAWSChimeVoiceConnectorTerminationExists(name string) resource.T } resp, err := conn.GetVoiceConnectorTermination(input) - if err != nil || resp.Termination == nil { + if err != nil { return err } + + if resp == nil || resp.Termination == nil { + return fmt.Errorf("Chime Voice Connector Termintation (%s) not found", rs.Primary.ID) + } return nil } From 6e05373d1674e8f40e8a2841533bb06a94166040 Mon Sep 17 00:00:00 2001 From: Aleks1001 Date: Tue, 7 Sep 2021 16:03:27 -0400 Subject: [PATCH 11/13] Update termination set ID --- aws/resource_aws_chime_voice_connector_termination.go | 8 +++----- ...resource_aws_chime_voice_connector_termination_test.go | 8 ++++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/aws/resource_aws_chime_voice_connector_termination.go b/aws/resource_aws_chime_voice_connector_termination.go index 1e7e820e757..1bbd644463c 100644 --- a/aws/resource_aws_chime_voice_connector_termination.go +++ b/aws/resource_aws_chime_voice_connector_termination.go @@ -2,7 +2,6 @@ package aws import ( "context" - "fmt" "log" "regexp" @@ -99,7 +98,7 @@ func resourceAwsChimeVoiceConnectorTerminationCreate(ctx context.Context, d *sch return diag.Errorf("error creating Chime Voice Connector (%s) termination: %s", vcId, err) } - d.SetId(fmt.Sprintf("termination-%s", vcId)) + d.SetId(vcId) return resourceAwsChimeVoiceConnectorTerminationRead(ctx, d, meta) } @@ -178,13 +177,12 @@ func resourceAwsChimeVoiceConnectorTerminationUpdate(ctx context.Context, d *sch func resourceAwsChimeVoiceConnectorTerminationDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*AWSClient).chimeconn - vcId := d.Get("voice_connector_id").(string) input := &chime.DeleteVoiceConnectorTerminationInput{ - VoiceConnectorId: aws.String(vcId), + VoiceConnectorId: aws.String(d.Id()), } if _, err := conn.DeleteVoiceConnectorTerminationWithContext(ctx, input); err != nil { - return diag.Errorf("error deleting Chime Voice Connector (%s) termination (%s): %s", vcId, d.Id(), err) + return diag.Errorf("error deleting Chime Voice Connector termination (%s): %s", d.Id(), err) } return nil diff --git a/aws/resource_aws_chime_voice_connector_termination_test.go b/aws/resource_aws_chime_voice_connector_termination_test.go index 01eaf0cd4eb..6c2483f59e9 100644 --- a/aws/resource_aws_chime_voice_connector_termination_test.go +++ b/aws/resource_aws_chime_voice_connector_termination_test.go @@ -154,10 +154,10 @@ func testAccCheckAWSChimeVoiceConnectorTerminationExists(name string) resource.T if err != nil { return err } - + if resp == nil || resp.Termination == nil { - return fmt.Errorf("Chime Voice Connector Termintation (%s) not found", rs.Primary.ID) - } + return fmt.Errorf("Chime Voice Connector Termintation (%s) not found", rs.Primary.ID) + } return nil } @@ -170,7 +170,7 @@ func testAccCheckAWSChimeVoiceConnectorTerminationDestroy(s *terraform.State) er } conn := testAccProvider.Meta().(*AWSClient).chimeconn input := &chime.GetVoiceConnectorTerminationInput{ - VoiceConnectorId: aws.String(rs.Primary.Attributes["voice_connector_id"]), + VoiceConnectorId: aws.String(rs.Primary.ID), } resp, err := conn.GetVoiceConnectorTermination(input) From 8bf9ded9448398f34a33823d2ba377e9ebbaf9f6 Mon Sep 17 00:00:00 2001 From: Aleks1001 Date: Tue, 7 Sep 2021 16:17:27 -0400 Subject: [PATCH 12/13] Update termination set ID --- ...ce_aws_chime_voice_connector_termination.go | 18 ++++++++---------- ...s_chime_voice_connector_termination_test.go | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/aws/resource_aws_chime_voice_connector_termination.go b/aws/resource_aws_chime_voice_connector_termination.go index 1bbd644463c..26e6e74e6fa 100644 --- a/aws/resource_aws_chime_voice_connector_termination.go +++ b/aws/resource_aws_chime_voice_connector_termination.go @@ -106,20 +106,19 @@ func resourceAwsChimeVoiceConnectorTerminationCreate(ctx context.Context, d *sch func resourceAwsChimeVoiceConnectorTerminationRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*AWSClient).chimeconn - vcId := d.Get("voice_connector_id").(string) input := &chime.GetVoiceConnectorTerminationInput{ - VoiceConnectorId: aws.String(vcId), + VoiceConnectorId: aws.String(d.Id()), } resp, err := conn.GetVoiceConnectorTerminationWithContext(ctx, input) if !d.IsNewResource() && isAWSErr(err, chime.ErrCodeNotFoundException, "") { - log.Printf("[WARN] error getting Chime Voice Connector (%s) termination: %s", vcId, err) + log.Printf("[WARN] error getting Chime Voice Connector (%s) termination: %s", d.Id(), err) d.SetId("") return nil } if err != nil || resp.Termination == nil { - return diag.Errorf("error getting Chime Voice Connector (%s) termination: %s", vcId, err) + return diag.Errorf("error getting Chime Voice Connector (%s) termination: %s", d.Id(), err) } d.Set("cps_limit", resp.Termination.CpsLimit) @@ -127,10 +126,10 @@ func resourceAwsChimeVoiceConnectorTerminationRead(ctx context.Context, d *schem d.Set("default_phone_number", resp.Termination.DefaultPhoneNumber) if err := d.Set("calling_regions", flattenStringList(resp.Termination.CallingRegions)); err != nil { - return diag.Errorf("error setting termination calling regions (%s): %s", vcId, err) + return diag.Errorf("error setting termination calling regions (%s): %s", d.Id(), err) } if err := d.Set("cidr_allow_list", flattenStringList(resp.Termination.CidrAllowedList)); err != nil { - return diag.Errorf("error setting termination cidr allow list (%s): %s", vcId, err) + return diag.Errorf("error setting termination cidr allow list (%s): %s", d.Id(), err) } return nil @@ -140,7 +139,6 @@ func resourceAwsChimeVoiceConnectorTerminationUpdate(ctx context.Context, d *sch conn := meta.(*AWSClient).chimeconn if d.HasChanges("calling_regions", "cidr_allow_list", "disabled", "cps_limit", "default_phone_number") { - vcId := d.Get("voice_connector_id").(string) termination := &chime.Termination{ CallingRegions: expandStringSet(d.Get("calling_regions").(*schema.Set)), CidrAllowedList: expandStringSet(d.Get("cidr_allow_list").(*schema.Set)), @@ -156,18 +154,18 @@ func resourceAwsChimeVoiceConnectorTerminationUpdate(ctx context.Context, d *sch } input := &chime.PutVoiceConnectorTerminationInput{ - VoiceConnectorId: aws.String(vcId), + VoiceConnectorId: aws.String(d.Id()), Termination: termination, } if _, err := conn.PutVoiceConnectorTerminationWithContext(ctx, input); err != nil { if isAWSErr(err, chime.ErrCodeNotFoundException, "") { - log.Printf("[WARN] error getting Chime Voice Connector (%s) termination: %s", vcId, err) + log.Printf("[WARN] error getting Chime Voice Connector (%s) termination: %s", d.Id(), err) d.SetId("") return nil } - return diag.Errorf("error updating Chime Voice Connector (%s) termination: %s", vcId, err) + return diag.Errorf("error updating Chime Voice Connector (%s) termination: %s", d.Id(), err) } } diff --git a/aws/resource_aws_chime_voice_connector_termination_test.go b/aws/resource_aws_chime_voice_connector_termination_test.go index 6c2483f59e9..9278829ad2b 100644 --- a/aws/resource_aws_chime_voice_connector_termination_test.go +++ b/aws/resource_aws_chime_voice_connector_termination_test.go @@ -147,7 +147,7 @@ func testAccCheckAWSChimeVoiceConnectorTerminationExists(name string) resource.T conn := testAccProvider.Meta().(*AWSClient).chimeconn input := &chime.GetVoiceConnectorTerminationInput{ - VoiceConnectorId: aws.String(rs.Primary.Attributes["voice_connector_id"]), + VoiceConnectorId: aws.String(rs.Primary.ID), } resp, err := conn.GetVoiceConnectorTermination(input) From 2b19a57f4ff4bbf7dac7981c7298140d49742de4 Mon Sep 17 00:00:00 2001 From: Angie Pinilla Date: Wed, 8 Sep 2021 00:39:10 -0400 Subject: [PATCH 13/13] additional CR changes --- aws/config.go | 10 +++++++ ...e_aws_chime_voice_connector_termination.go | 27 ++++++++++++------ ..._chime_voice_connector_termination_test.go | 28 ++++++++----------- 3 files changed, 40 insertions(+), 25 deletions(-) diff --git a/aws/config.go b/aws/config.go index ff09b292064..9fe0fe6e3e3 100644 --- a/aws/config.go +++ b/aws/config.go @@ -733,6 +733,16 @@ func (c *Config) Client() (interface{}, error) { } }) + client.chimeconn.Handlers.Retry.PushBack(func(r *request.Request) { + // When calling CreateVoiceConnector across multiple resources, + // the API can randomly return a BadRequestException without explanation + if r.Operation.Name == "CreateVoiceConnector" { + if tfawserr.ErrMessageContains(r.Error, chime.ErrCodeBadRequestException, "Service received a bad request") { + r.Retryable = aws.Bool(true) + } + } + }) + client.cloudhsmv2conn.Handlers.Retry.PushBack(func(r *request.Request) { if tfawserr.ErrMessageContains(r.Error, cloudhsmv2.ErrCodeCloudHsmInternalFailureException, "request was rejected because of an AWS CloudHSM internal failure") { r.Retryable = aws.Bool(true) diff --git a/aws/resource_aws_chime_voice_connector_termination.go b/aws/resource_aws_chime_voice_connector_termination.go index 26e6e74e6fa..9ae2aff05e1 100644 --- a/aws/resource_aws_chime_voice_connector_termination.go +++ b/aws/resource_aws_chime_voice_connector_termination.go @@ -111,16 +111,21 @@ func resourceAwsChimeVoiceConnectorTerminationRead(ctx context.Context, d *schem } resp, err := conn.GetVoiceConnectorTerminationWithContext(ctx, input) + if !d.IsNewResource() && isAWSErr(err, chime.ErrCodeNotFoundException, "") { - log.Printf("[WARN] error getting Chime Voice Connector (%s) termination: %s", d.Id(), err) + log.Printf("[WARN] Chime Voice Connector (%s) termination not found, removing from state", d.Id()) d.SetId("") return nil } - if err != nil || resp.Termination == nil { + if err != nil { return diag.Errorf("error getting Chime Voice Connector (%s) termination: %s", d.Id(), err) } + if resp == nil || resp.Termination == nil { + return diag.Errorf("error getting Chime Voice Connector (%s) termination: empty response", d.Id()) + } + d.Set("cps_limit", resp.Termination.CpsLimit) d.Set("disabled", resp.Termination.Disabled) d.Set("default_phone_number", resp.Termination.DefaultPhoneNumber) @@ -132,6 +137,8 @@ func resourceAwsChimeVoiceConnectorTerminationRead(ctx context.Context, d *schem return diag.Errorf("error setting termination cidr allow list (%s): %s", d.Id(), err) } + d.Set("voice_connector_id", d.Id()) + return nil } @@ -158,13 +165,9 @@ func resourceAwsChimeVoiceConnectorTerminationUpdate(ctx context.Context, d *sch Termination: termination, } - if _, err := conn.PutVoiceConnectorTerminationWithContext(ctx, input); err != nil { - if isAWSErr(err, chime.ErrCodeNotFoundException, "") { - log.Printf("[WARN] error getting Chime Voice Connector (%s) termination: %s", d.Id(), err) - d.SetId("") - return nil - } + _, err := conn.PutVoiceConnectorTerminationWithContext(ctx, input) + if err != nil { return diag.Errorf("error updating Chime Voice Connector (%s) termination: %s", d.Id(), err) } } @@ -179,7 +182,13 @@ func resourceAwsChimeVoiceConnectorTerminationDelete(ctx context.Context, d *sch VoiceConnectorId: aws.String(d.Id()), } - if _, err := conn.DeleteVoiceConnectorTerminationWithContext(ctx, input); err != nil { + _, err := conn.DeleteVoiceConnectorTerminationWithContext(ctx, input) + + if isAWSErr(err, chime.ErrCodeNotFoundException, "") { + return nil + } + + if err != nil { return diag.Errorf("error deleting Chime Voice Connector termination (%s): %s", d.Id(), err) } diff --git a/aws/resource_aws_chime_voice_connector_termination_test.go b/aws/resource_aws_chime_voice_connector_termination_test.go index 9278829ad2b..0d650ff0d91 100644 --- a/aws/resource_aws_chime_voice_connector_termination_test.go +++ b/aws/resource_aws_chime_voice_connector_termination_test.go @@ -12,22 +12,19 @@ import ( ) func TestAccAWSChimeVoiceConnectorTermination_basic(t *testing.T) { - var vc *chime.VoiceConnector name := acctest.RandomWithPrefix("tf-acc-test") - vcResourceName := "aws_chime_voice_connector.chime" resourceName := "aws_chime_voice_connector_termination.test" resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, ErrorCheck: testAccErrorCheck(t, chime.EndpointsID), Providers: testAccProviders, - CheckDestroy: testAccCheckAWSChimeVoiceConnectorDestroy, + CheckDestroy: testAccCheckAWSChimeVoiceConnectorTerminationDestroy, Steps: []resource.TestStep{ { Config: testAccAWSChimeVoiceConnectorTerminationConfig(name), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckAWSChimeVoiceConnectorExists(vcResourceName, vc), + testAccCheckAWSChimeVoiceConnectorTerminationExists(resourceName), resource.TestCheckResourceAttr(resourceName, "cps_limit", "1"), resource.TestCheckResourceAttr(resourceName, "calling_regions.#", "2"), resource.TestCheckResourceAttr(resourceName, "cidr_allow_list.#", "1"), @@ -35,7 +32,7 @@ func TestAccAWSChimeVoiceConnectorTermination_basic(t *testing.T) { ), }, { - ResourceName: vcResourceName, + ResourceName: resourceName, ImportState: true, ImportStateVerify: true, }, @@ -66,38 +63,37 @@ func TestAccAWSChimeVoiceConnectorTermination_disappears(t *testing.T) { } func TestAccAWSChimeVoiceConnectorTermination_update(t *testing.T) { - var vc *chime.VoiceConnector name := acctest.RandomWithPrefix("tf-acc-test") - vcResourceName := "aws_chime_voice_connector.chime" resourceName := "aws_chime_voice_connector_termination.test" resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, ErrorCheck: testAccErrorCheck(t, chime.EndpointsID), Providers: testAccProviders, - CheckDestroy: testAccCheckAWSChimeVoiceConnectorDestroy, + CheckDestroy: testAccCheckAWSChimeVoiceConnectorTerminationDestroy, Steps: []resource.TestStep{ { Config: testAccAWSChimeVoiceConnectorTerminationConfig(name), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckAWSChimeVoiceConnectorExists(vcResourceName, vc), + testAccCheckAWSChimeVoiceConnectorTerminationExists(resourceName), ), }, - { - ResourceName: vcResourceName, - ImportState: true, - ImportStateVerify: true, - }, { Config: testAccAWSChimeVoiceConnectorTerminationUpdated(name), Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckAWSChimeVoiceConnectorTerminationExists(resourceName), resource.TestCheckResourceAttr(resourceName, "cps_limit", "1"), resource.TestCheckResourceAttr(resourceName, "calling_regions.#", "3"), - resource.TestCheckResourceAttr(resourceName, "cidr_allow_list.0", "100.35.78.97/32"), + resource.TestCheckTypeSetElemAttr(resourceName, "cidr_allow_list.*", "100.35.78.97/32"), resource.TestCheckResourceAttr(resourceName, "disabled", "false"), resource.TestCheckResourceAttr(resourceName, "default_phone_number", ""), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, }, }) }