From 0714f93ec3e78ec1535b7aa44119ef67daedba5f Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Sun, 13 Aug 2023 23:53:40 +0200 Subject: [PATCH 01/10] feat: added connection_mode attribute + tests --- .../opensearch/inbound_connection_accepter.go | 6 +- .../service/opensearch/outbound_connection.go | 95 ++++++++++- .../opensearch/outbound_connection_test.go | 160 ++++++++++++++++++ 3 files changed, 253 insertions(+), 8 deletions(-) diff --git a/internal/service/opensearch/inbound_connection_accepter.go b/internal/service/opensearch/inbound_connection_accepter.go index ccb578d682a..9396b07446d 100644 --- a/internal/service/opensearch/inbound_connection_accepter.go +++ b/internal/service/opensearch/inbound_connection_accepter.go @@ -33,8 +33,8 @@ func ResourceInboundConnectionAccepter() *schema.Resource { }, Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(1 * time.Minute), - Delete: schema.DefaultTimeout(1 * time.Minute), + Create: schema.DefaultTimeout(5 * time.Minute), + Delete: schema.DefaultTimeout(5 * time.Minute), }, Schema: map[string]*schema.Schema{ @@ -113,7 +113,7 @@ func resourceInboundConnectionDelete(ctx context.Context, d *schema.ResourceData } if err := waitForInboundConnectionDeletion(ctx, conn, d.Id(), d.Timeout(schema.TimeoutDelete)); err != nil { - return diag.Errorf("waiting for VPC Peering Connection (%s) to be deleted: %s", d.Id(), err) + return diag.Errorf("waiting for Inbound Connection (%s) to be deleted: %s", d.Id(), err) } return nil diff --git a/internal/service/opensearch/outbound_connection.go b/internal/service/opensearch/outbound_connection.go index 471044ba02b..90d940f5104 100644 --- a/internal/service/opensearch/outbound_connection.go +++ b/internal/service/opensearch/outbound_connection.go @@ -16,7 +16,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" + "github.com/hashicorp/terraform-provider-aws/internal/verify" ) // @SDKResource("aws_opensearch_outbound_connection") @@ -30,8 +32,8 @@ func ResourceOutboundConnection() *schema.Resource { }, Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(1 * time.Minute), - Delete: schema.DefaultTimeout(1 * time.Minute), + Create: schema.DefaultTimeout(5 * time.Minute), + Delete: schema.DefaultTimeout(5 * time.Minute), }, Schema: map[string]*schema.Schema{ @@ -40,6 +42,42 @@ func ResourceOutboundConnection() *schema.Resource { Required: true, ForceNew: true, }, + "connection_mode": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(opensearchservice.ConnectionMode_Values(), false), + }, + "connection_properties": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cross_cluster_search": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "skip_unavailable": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + }, + }, + }, + "endpoint": { + Type: schema.TypeString, + Computed: true, + DiffSuppressFunc: verify.SuppressMissingOptionalConfigurationBlock, + }, + }, + }, + }, "local_domain_info": outboundConnectionDomainInfoSchema(), "remote_domain_info": outboundConnectionDomainInfoSchema(), "connection_status": { @@ -55,9 +93,11 @@ func resourceOutboundConnectionCreate(ctx context.Context, d *schema.ResourceDat // Create the Outbound Connection createOpts := &opensearchservice.CreateOutboundConnectionInput{ - ConnectionAlias: aws.String(d.Get("connection_alias").(string)), - LocalDomainInfo: expandOutboundConnectionDomainInfo(d.Get("local_domain_info").([]interface{})), - RemoteDomainInfo: expandOutboundConnectionDomainInfo(d.Get("remote_domain_info").([]interface{})), + ConnectionAlias: aws.String(d.Get("connection_alias").(string)), + ConnectionMode: aws.String(d.Get("connection_mode").(string)), + ConnectionProperties: expandOutboundConnectionConnectionProperties(d.Get("connection_properties").([]interface{})), + LocalDomainInfo: expandOutboundConnectionDomainInfo(d.Get("local_domain_info").([]interface{})), + RemoteDomainInfo: expandOutboundConnectionDomainInfo(d.Get("remote_domain_info").([]interface{})), } log.Printf("[DEBUG] Outbound Connection Create options: %#v", createOpts) @@ -98,6 +138,8 @@ func resourceOutboundConnectionRead(ctx context.Context, d *schema.ResourceData, } d.Set("connection_alias", ccsc.ConnectionAlias) + d.Set("connection_mode", ccsc.ConnectionMode) + d.Set("connection_properties", flattenOutboundConnectionConnectionProperties(ccsc.ConnectionProperties)) d.Set("remote_domain_info", flattenOutboundConnectionDomainInfo(ccsc.RemoteDomainInfo)) d.Set("local_domain_info", flattenOutboundConnectionDomainInfo(ccsc.LocalDomainInfo)) d.Set("connection_status", statusCode) @@ -264,3 +306,46 @@ func flattenOutboundConnectionDomainInfo(domainInfo *opensearchservice.DomainInf "region": aws.StringValue(domainInfo.AWSDomainInformation.Region), }} } + +func expandOutboundConnectionConnectionProperties(cProperties []interface{}) *opensearchservice.ConnectionProperties { + if len(cProperties) == 0 || cProperties[0] == nil { + return nil + } + + mOptions := cProperties[0].(map[string]interface{}) + + return &opensearchservice.ConnectionProperties{ + CrossClusterSearch: expandOutboundConnectionCrossClusterSearchConnectionProperties(mOptions["cross_cluster_search"].([]interface{})), + } +} + +func flattenOutboundConnectionConnectionProperties(cProperties *opensearchservice.ConnectionProperties) []interface{} { + if cProperties == nil { + return nil + } + return []interface{}{map[string]interface{}{ + "cross_cluster_search": flattenOutboundConnectionCrossClusterSearchConnectionProperties(cProperties.CrossClusterSearch), + "endpoint": aws.StringValue(cProperties.Endpoint), + }} +} + +func expandOutboundConnectionCrossClusterSearchConnectionProperties(cProperties []interface{}) *opensearchservice.CrossClusterSearchConnectionProperties { + if len(cProperties) == 0 || cProperties[0] == nil { + return nil + } + + mOptions := cProperties[0].(map[string]interface{}) + + return &opensearchservice.CrossClusterSearchConnectionProperties{ + SkipUnavailable: aws.String(mOptions["skip_unavailable"].(string)), + } +} + +func flattenOutboundConnectionCrossClusterSearchConnectionProperties(cProperties *opensearchservice.CrossClusterSearchConnectionProperties) []interface{} { + if cProperties == nil { + return nil + } + return []interface{}{map[string]interface{}{ + "skip_unavailable": aws.StringValue(cProperties.SkipUnavailable), + }} +} diff --git a/internal/service/opensearch/outbound_connection_test.go b/internal/service/opensearch/outbound_connection_test.go index 01c9f0f5b97..04adcf9bb77 100644 --- a/internal/service/opensearch/outbound_connection_test.go +++ b/internal/service/opensearch/outbound_connection_test.go @@ -32,6 +32,7 @@ func TestAccOpenSearchOutboundConnection_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckDomainExists(ctx, "aws_opensearch_domain.domain_1", &domain), testAccCheckDomainExists(ctx, "aws_opensearch_domain.domain_2", &domain), + resource.TestCheckResourceAttr(resourceName, "connection_properties.#", "2"), resource.TestCheckResourceAttr(resourceName, "connection_status", "PENDING_ACCEPTANCE"), ), }, @@ -44,6 +45,36 @@ func TestAccOpenSearchOutboundConnection_basic(t *testing.T) { }) } +func TestAccOpenSearchOutboundConnection_vpc(t *testing.T) { + ctx := acctest.Context(t) + var domain opensearchservice.DomainStatus + ri := sdkacctest.RandString(10) + name := fmt.Sprintf("tf-test-%s", ri) + resourceName := "aws_opensearch_outbound_connection.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(ctx, t) }, + ErrorCheck: acctest.ErrorCheck(t, opensearchservice.EndpointsID), + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, + CheckDestroy: testAccCheckDomainDestroy(ctx), + Steps: []resource.TestStep{ + { + Config: testAccOutboundConnectionConfig_vpc(name), + Check: resource.ComposeTestCheckFunc( + testAccCheckDomainExists(ctx, "aws_opensearch_domain.domain_1", &domain), + testAccCheckDomainExists(ctx, "aws_opensearch_domain.domain_2", &domain), + resource.TestCheckResourceAttr(resourceName, "connection_properties.#", "1"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func TestAccOpenSearchOutboundConnection_disappears(t *testing.T) { ctx := acctest.Context(t) var domain opensearchservice.DomainStatus @@ -151,6 +182,13 @@ data "aws_region" "current" {} resource "aws_opensearch_outbound_connection" "test" { connection_alias = "%s" + + connection_properties { + cross_cluster_search { + skip_unavailable = "ENABLED" + } + } + local_domain_info { owner_id = data.aws_caller_identity.current.account_id region = data.aws_region.current.name @@ -165,3 +203,125 @@ resource "aws_opensearch_outbound_connection" "test" { } `, name, pw, name, pw, name) } + +func testAccOutboundConnectionConfig_vpc(name string) string { + // Satisfy the pw requirements + pw := fmt.Sprintf("Aa1-%s", sdkacctest.RandString(10)) + + return acctest.ConfigCompose( + acctest.ConfigAvailableAZsNoOptIn(), + fmt.Sprintf(` +resource "aws_vpc" "test" { + cidr_block = "192.168.0.0/22" + + tags = { + Name = %[1]q + } +} + +resource "aws_subnet" "test" { + vpc_id = aws_vpc.test.id + availability_zone = data.aws_availability_zones.available.names[0] + cidr_block = "192.168.0.0/24" + + tags = { + Name = %[1]q + } +} + +resource "aws_subnet" "test2" { + vpc_id = aws_vpc.test.id + availability_zone = data.aws_availability_zones.available.names[1] + cidr_block = "192.168.1.0/24" + + tags = { + Name = %[1]q + } +} + +resource "aws_security_group" "test" { + vpc_id = aws_vpc.test.id +} + +resource "aws_security_group" "test2" { + vpc_id = aws_vpc.test.id +} + +resource "aws_opensearch_domain" "domain_1" { + domain_name = "%[1]s-1" + + cluster_config { + instance_type = "t3.small.search" # supported in both aws and aws-us-gov + } + + ebs_options { + ebs_enabled = true + volume_size = 10 + } + + node_to_node_encryption { + enabled = true + } + + advanced_security_options { + enabled = true + internal_user_database_enabled = true + + master_user_options { + master_user_name = "test" + master_user_password = %[2]q + } + } + + encrypt_at_rest { + enabled = true + } + + domain_endpoint_options { + enforce_https = true + tls_security_policy = "Policy-Min-TLS-1-2-2019-07" + } +} + +resource "aws_opensearch_domain" "domain_2" { + domain_name = "%[1]s-2" + + ebs_options { + ebs_enabled = true + volume_size = 10 + } + + cluster_config { + instance_count = 2 + zone_awareness_enabled = true + instance_type = "t3.small.search" + } + + vpc_options { + security_group_ids = [aws_security_group.test.id, aws_security_group.test2.id] + subnet_ids = [aws_subnet.test.id, aws_subnet.test2.id] + } +} + +data "aws_caller_identity" "current" {} +data "aws_region" "current" {} + +resource "aws_opensearch_outbound_connection" "test" { + connection_alias = %[1]q + connection_mode = "VPC_ENDPOINT" + + local_domain_info { + owner_id = data.aws_caller_identity.current.account_id + region = data.aws_region.current.name + domain_name = aws_opensearch_domain.domain_1.domain_name + } + + remote_domain_info { + owner_id = data.aws_caller_identity.current.account_id + region = data.aws_region.current.name + domain_name = aws_opensearch_domain.domain_2.domain_name + } +} + +`, name, pw)) +} From 82c1de484f234210846a8552fce485a24d73f225 Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Mon, 14 Aug 2023 00:23:04 +0200 Subject: [PATCH 02/10] feat: changed type --- internal/service/opensearch/outbound_connection.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/internal/service/opensearch/outbound_connection.go b/internal/service/opensearch/outbound_connection.go index 90d940f5104..691187bab3f 100644 --- a/internal/service/opensearch/outbound_connection.go +++ b/internal/service/opensearch/outbound_connection.go @@ -18,7 +18,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" - "github.com/hashicorp/terraform-provider-aws/internal/verify" ) // @SDKResource("aws_opensearch_outbound_connection") @@ -51,7 +50,7 @@ func ResourceOutboundConnection() *schema.Resource { "connection_properties": { Type: schema.TypeList, Optional: true, - ForceNew: true, + Computed: true, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -71,9 +70,8 @@ func ResourceOutboundConnection() *schema.Resource { }, }, "endpoint": { - Type: schema.TypeString, - Computed: true, - DiffSuppressFunc: verify.SuppressMissingOptionalConfigurationBlock, + Type: schema.TypeString, + Computed: true, }, }, }, From 491e69a17ea45f950d9d91e82a8b4e9af1da0a6d Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Mon, 14 Aug 2023 01:47:17 +0200 Subject: [PATCH 03/10] feat: added accept_connection feature --- .../opensearch/inbound_connection_accepter.go | 37 ------------------- .../service/opensearch/outbound_connection.go | 33 +++++++++++++++++ .../opensearch/outbound_connection_test.go | 13 ++++--- internal/service/opensearch/wait.go | 37 +++++++++++++++++++ 4 files changed, 77 insertions(+), 43 deletions(-) diff --git a/internal/service/opensearch/inbound_connection_accepter.go b/internal/service/opensearch/inbound_connection_accepter.go index 9396b07446d..66ba65059d9 100644 --- a/internal/service/opensearch/inbound_connection_accepter.go +++ b/internal/service/opensearch/inbound_connection_accepter.go @@ -5,7 +5,6 @@ package opensearch import ( "context" - "fmt" "log" "time" @@ -150,39 +149,3 @@ func inboundConnectionRefreshState(ctx context.Context, conn *opensearchservice. return ccsc, statusCode, nil } } - -func inboundConnectionWaitUntilActive(ctx context.Context, conn *opensearchservice.OpenSearchService, id string, timeout time.Duration) error { - log.Printf("[DEBUG] Waiting for Inbound Connection (%s) to become available.", id) - stateConf := &retry.StateChangeConf{ - Pending: []string{ - opensearchservice.InboundConnectionStatusCodeProvisioning, - opensearchservice.InboundConnectionStatusCodeApproved, - }, - Target: []string{ - opensearchservice.InboundConnectionStatusCodeActive, - }, - Refresh: inboundConnectionRefreshState(ctx, conn, id), - Timeout: timeout, - } - if _, err := stateConf.WaitForStateContext(ctx); err != nil { - return fmt.Errorf("waiting for Inbound Connection (%s) to become available: %s", id, err) - } - return nil -} - -func waitForInboundConnectionDeletion(ctx context.Context, conn *opensearchservice.OpenSearchService, id string, timeout time.Duration) error { - stateConf := &retry.StateChangeConf{ - Pending: []string{ - opensearchservice.InboundConnectionStatusCodeDeleting, - }, - Target: []string{ - opensearchservice.InboundConnectionStatusCodeDeleted, - }, - Refresh: inboundConnectionRefreshState(ctx, conn, id), - Timeout: timeout, - } - - _, err := stateConf.WaitForStateContext(ctx) - - return err -} diff --git a/internal/service/opensearch/outbound_connection.go b/internal/service/opensearch/outbound_connection.go index 691187bab3f..c6f52808e04 100644 --- a/internal/service/opensearch/outbound_connection.go +++ b/internal/service/opensearch/outbound_connection.go @@ -82,6 +82,12 @@ func ResourceOutboundConnection() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "accept_connection": { + Type: schema.TypeBool, + Optional: true, + Default: false, + ForceNew: true, + }, }, } } @@ -114,6 +120,12 @@ func resourceOutboundConnectionCreate(ctx context.Context, d *schema.ResourceDat return diag.Errorf("waiting for Outbound Connection to become available: %s", err) } + if d.Get("accept_connection").(bool) { + if err := inboundConnectionAccept(ctx, d, conn); err != nil { + return diag.Errorf("unable to accept Connection: %s", err) + } + } + return resourceOutboundConnectionRead(ctx, d, meta) } @@ -278,6 +290,27 @@ func outboundConnectionDomainInfoSchema() *schema.Schema { } } +func inboundConnectionAccept(ctx context.Context, d *schema.ResourceData, conn *opensearchservice.OpenSearchService) error { + // Create the Inbound Connection + acceptOpts := &opensearchservice.AcceptInboundConnectionInput{ + ConnectionId: aws.String(d.Id()), + } + + log.Printf("[DEBUG] Inbound Connection Accept options: %#v", acceptOpts) + + _, err := conn.AcceptInboundConnectionWithContext(ctx, acceptOpts) + if err != nil { + return err + } + + err = inboundConnectionWaitUntilActive(ctx, conn, d.Id(), d.Timeout(schema.TimeoutCreate)) + if err != nil { + return err + } + + return nil +} + func expandOutboundConnectionDomainInfo(vOptions []interface{}) *opensearchservice.DomainInformationContainer { if len(vOptions) == 0 || vOptions[0] == nil { return nil diff --git a/internal/service/opensearch/outbound_connection_test.go b/internal/service/opensearch/outbound_connection_test.go index 04adcf9bb77..dc444ff814e 100644 --- a/internal/service/opensearch/outbound_connection_test.go +++ b/internal/service/opensearch/outbound_connection_test.go @@ -32,7 +32,6 @@ func TestAccOpenSearchOutboundConnection_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckDomainExists(ctx, "aws_opensearch_domain.domain_1", &domain), testAccCheckDomainExists(ctx, "aws_opensearch_domain.domain_2", &domain), - resource.TestCheckResourceAttr(resourceName, "connection_properties.#", "2"), resource.TestCheckResourceAttr(resourceName, "connection_status", "PENDING_ACCEPTANCE"), ), }, @@ -59,11 +58,11 @@ func TestAccOpenSearchOutboundConnection_vpc(t *testing.T) { CheckDestroy: testAccCheckDomainDestroy(ctx), Steps: []resource.TestStep{ { - Config: testAccOutboundConnectionConfig_vpc(name), + Config: testAccOutboundConnectionConfig_vpcEndpoint(name), Check: resource.ComposeTestCheckFunc( testAccCheckDomainExists(ctx, "aws_opensearch_domain.domain_1", &domain), testAccCheckDomainExists(ctx, "aws_opensearch_domain.domain_2", &domain), - resource.TestCheckResourceAttr(resourceName, "connection_properties.#", "1"), + resource.TestCheckResourceAttrSet(resourceName, "connection_properties.0.endpoint"), ), }, { @@ -182,6 +181,7 @@ data "aws_region" "current" {} resource "aws_opensearch_outbound_connection" "test" { connection_alias = "%s" + connection_mode = "DIRECT" connection_properties { cross_cluster_search { @@ -204,7 +204,7 @@ resource "aws_opensearch_outbound_connection" "test" { `, name, pw, name, pw, name) } -func testAccOutboundConnectionConfig_vpc(name string) string { +func testAccOutboundConnectionConfig_vpcEndpoint(name string) string { // Satisfy the pw requirements pw := fmt.Sprintf("Aa1-%s", sdkacctest.RandString(10)) @@ -307,8 +307,9 @@ data "aws_caller_identity" "current" {} data "aws_region" "current" {} resource "aws_opensearch_outbound_connection" "test" { - connection_alias = %[1]q - connection_mode = "VPC_ENDPOINT" + connection_alias = %[1]q + connection_mode = "VPC_ENDPOINT" + accept_connection = true local_domain_info { owner_id = data.aws_caller_identity.current.account_id diff --git a/internal/service/opensearch/wait.go b/internal/service/opensearch/wait.go index 22ed54fe460..23fff802e76 100644 --- a/internal/service/opensearch/wait.go +++ b/internal/service/opensearch/wait.go @@ -6,6 +6,7 @@ package opensearch import ( "context" "fmt" + "log" "time" "github.com/aws/aws-sdk-go/aws" @@ -156,3 +157,39 @@ func waitForDomainDelete(ctx context.Context, conn *opensearchservice.OpenSearch return err } + +func inboundConnectionWaitUntilActive(ctx context.Context, conn *opensearchservice.OpenSearchService, id string, timeout time.Duration) error { + log.Printf("[DEBUG] Waiting for Inbound Connection (%s) to become available.", id) + stateConf := &retry.StateChangeConf{ + Pending: []string{ + opensearchservice.InboundConnectionStatusCodeProvisioning, + opensearchservice.InboundConnectionStatusCodeApproved, + }, + Target: []string{ + opensearchservice.InboundConnectionStatusCodeActive, + }, + Refresh: inboundConnectionRefreshState(ctx, conn, id), + Timeout: timeout, + } + if _, err := stateConf.WaitForStateContext(ctx); err != nil { + return fmt.Errorf("waiting for Inbound Connection (%s) to become available: %s", id, err) + } + return nil +} + +func waitForInboundConnectionDeletion(ctx context.Context, conn *opensearchservice.OpenSearchService, id string, timeout time.Duration) error { + stateConf := &retry.StateChangeConf{ + Pending: []string{ + opensearchservice.InboundConnectionStatusCodeDeleting, + }, + Target: []string{ + opensearchservice.InboundConnectionStatusCodeDeleted, + }, + Refresh: inboundConnectionRefreshState(ctx, conn, id), + Timeout: timeout, + } + + _, err := stateConf.WaitForStateContext(ctx) + + return err +} From 7e4cb343b1d177598c56c73c8cb21f63449c2a12 Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Mon, 14 Aug 2023 02:47:32 +0200 Subject: [PATCH 04/10] feat: added documentation --- .../opensearch/outbound_connection_test.go | 15 +++++++++------ .../opensearch_outbound_connection.html.markdown | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/internal/service/opensearch/outbound_connection_test.go b/internal/service/opensearch/outbound_connection_test.go index dc444ff814e..7b67571a3ad 100644 --- a/internal/service/opensearch/outbound_connection_test.go +++ b/internal/service/opensearch/outbound_connection_test.go @@ -36,9 +36,10 @@ func TestAccOpenSearchOutboundConnection_basic(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"accept_connection"}, }, }, }) @@ -66,9 +67,10 @@ func TestAccOpenSearchOutboundConnection_vpc(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"accept_connection"}, }, }, }) @@ -182,6 +184,7 @@ data "aws_region" "current" {} resource "aws_opensearch_outbound_connection" "test" { connection_alias = "%s" connection_mode = "DIRECT" + accept_connection = true connection_properties { cross_cluster_search { diff --git a/website/docs/r/opensearch_outbound_connection.html.markdown b/website/docs/r/opensearch_outbound_connection.html.markdown index 528cc3f8240..972274d61d6 100644 --- a/website/docs/r/opensearch_outbound_connection.html.markdown +++ b/website/docs/r/opensearch_outbound_connection.html.markdown @@ -20,6 +20,7 @@ data "aws_region" "current" {} resource "aws_opensearch_outbound_connection" "foo" { connection_alias = "outbound_connection" + connection_mode = "DIRECT" local_domain_info { owner_id = data.aws_caller_identity.current.account_id region = data.aws_region.current.name @@ -39,9 +40,20 @@ resource "aws_opensearch_outbound_connection" "foo" { This resource supports the following arguments: * `connection_alias` - (Required, Forces new resource) Specifies the connection alias that will be used by the customer for this connection. +* `connection_mode` - (Required, Forces new resource) Specifies the connection mode. Accepted values are `DIRECT` or `VPC_ENDPOINT`. +* `accept_connection` - (Optional, Forces new resource) Accepts the connection. +* `connection_properties` - (Optional, Forces new resource) Configuration block for the outbound connection.. * `local_domain_info` - (Required, Forces new resource) Configuration block for the local Opensearch domain. * `remote_domain_info` - (Required, Forces new resource) Configuration block for the remote Opensearch domain. +### connection_properties + +* `cross_cluster_search` - (Optional, Forces new resource) Configuration block for cross cluster search. + +### cross_cluster_search + +* `skip_unavailable` - (Optional, Forces new resource) Skips unavailable clusters and can only be used for cross-cluster searches. Accepted values are `ENABLED` or `DISABLED`. + ### local_domain_info * `owner_id` - (Required, Forces new resource) The Account ID of the owner of the local domain. @@ -61,6 +73,10 @@ This resource exports the following attributes in addition to the arguments abov * `id` - The Id of the connection. * `connection_status` - Status of the connection request. +`connection_properties` block exports the following: + +* `endpoint` - The endpoint of the remote domain, is only set when `connection_mode` is `VPC_ENDPOINT` and `accept_connection` is `TRUE`. + ## Import In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import AWS Opensearch Outbound Connections using the Outbound Connection ID. For example: From a2c97ce64ca826e7db293cec7aec75991dda81ac Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Mon, 14 Aug 2023 03:10:47 +0200 Subject: [PATCH 05/10] feat: changed expected connection_status in tests --- internal/service/opensearch/outbound_connection_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/service/opensearch/outbound_connection_test.go b/internal/service/opensearch/outbound_connection_test.go index 7b67571a3ad..6c8cb740fc5 100644 --- a/internal/service/opensearch/outbound_connection_test.go +++ b/internal/service/opensearch/outbound_connection_test.go @@ -32,7 +32,7 @@ func TestAccOpenSearchOutboundConnection_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckDomainExists(ctx, "aws_opensearch_domain.domain_1", &domain), testAccCheckDomainExists(ctx, "aws_opensearch_domain.domain_2", &domain), - resource.TestCheckResourceAttr(resourceName, "connection_status", "PENDING_ACCEPTANCE"), + resource.TestCheckResourceAttr(resourceName, "connection_status", "ACTIVE"), ), }, { @@ -64,6 +64,7 @@ func TestAccOpenSearchOutboundConnection_vpc(t *testing.T) { testAccCheckDomainExists(ctx, "aws_opensearch_domain.domain_1", &domain), testAccCheckDomainExists(ctx, "aws_opensearch_domain.domain_2", &domain), resource.TestCheckResourceAttrSet(resourceName, "connection_properties.0.endpoint"), + resource.TestCheckResourceAttr(resourceName, "connection_status", "ACTIVE"), ), }, { From 2b84f514cab90d25f438f9c0765a32d2488911ba Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Mon, 14 Aug 2023 03:57:34 +0200 Subject: [PATCH 06/10] chore: added changelog --- .changelog/32990.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/32990.txt diff --git a/.changelog/32990.txt b/.changelog/32990.txt new file mode 100644 index 00000000000..2292aff4c49 --- /dev/null +++ b/.changelog/32990.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_opensearch_outbound_connection: Add `connection_properties`, `connection_mode` and `accept_connection` arguments to support specifying connection mode. +``` From 4beb5c45f2c37840d0902e786ea29d0496d5582d Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Mon, 14 Aug 2023 04:08:15 +0200 Subject: [PATCH 07/10] chore: removed whitespaces --- internal/service/opensearch/outbound_connection.go | 5 +---- internal/service/opensearch/outbound_connection_test.go | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/internal/service/opensearch/outbound_connection.go b/internal/service/opensearch/outbound_connection.go index c6f52808e04..06789758da3 100644 --- a/internal/service/opensearch/outbound_connection.go +++ b/internal/service/opensearch/outbound_connection.go @@ -304,11 +304,8 @@ func inboundConnectionAccept(ctx context.Context, d *schema.ResourceData, conn * } err = inboundConnectionWaitUntilActive(ctx, conn, d.Id(), d.Timeout(schema.TimeoutCreate)) - if err != nil { - return err - } - return nil + return err } func expandOutboundConnectionDomainInfo(vOptions []interface{}) *opensearchservice.DomainInformationContainer { diff --git a/internal/service/opensearch/outbound_connection_test.go b/internal/service/opensearch/outbound_connection_test.go index 6c8cb740fc5..b01d46d8e74 100644 --- a/internal/service/opensearch/outbound_connection_test.go +++ b/internal/service/opensearch/outbound_connection_test.go @@ -183,8 +183,8 @@ data "aws_caller_identity" "current" {} data "aws_region" "current" {} resource "aws_opensearch_outbound_connection" "test" { - connection_alias = "%s" - connection_mode = "DIRECT" + connection_alias = "%s" + connection_mode = "DIRECT" accept_connection = true connection_properties { @@ -314,7 +314,7 @@ resource "aws_opensearch_outbound_connection" "test" { connection_alias = %[1]q connection_mode = "VPC_ENDPOINT" accept_connection = true - + local_domain_info { owner_id = data.aws_caller_identity.current.account_id region = data.aws_region.current.name From 372c29b6911a1aeb319edf04c79a2c6f22b17a3a Mon Sep 17 00:00:00 2001 From: Daniel Rieske Date: Mon, 14 Aug 2023 04:11:46 +0200 Subject: [PATCH 08/10] chore: removed whitespace --- internal/service/opensearch/outbound_connection_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/opensearch/outbound_connection_test.go b/internal/service/opensearch/outbound_connection_test.go index b01d46d8e74..9b779e781b8 100644 --- a/internal/service/opensearch/outbound_connection_test.go +++ b/internal/service/opensearch/outbound_connection_test.go @@ -186,7 +186,7 @@ resource "aws_opensearch_outbound_connection" "test" { connection_alias = "%s" connection_mode = "DIRECT" accept_connection = true - + connection_properties { cross_cluster_search { skip_unavailable = "ENABLED" From a0693f0afe43d040b8f4256f9718b183f22180e9 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 25 Sep 2023 16:51:06 -0400 Subject: [PATCH 09/10] r/aws_opensearch_outbound_connection: Cosmetics. --- .changelog/32990.txt | 2 +- .../service/opensearch/outbound_connection.go | 260 ++++++++++-------- ...ensearch_outbound_connection.html.markdown | 2 +- 3 files changed, 153 insertions(+), 111 deletions(-) diff --git a/.changelog/32990.txt b/.changelog/32990.txt index 2292aff4c49..221d331f512 100644 --- a/.changelog/32990.txt +++ b/.changelog/32990.txt @@ -1,3 +1,3 @@ ```release-note:enhancement -resource/aws_opensearch_outbound_connection: Add `connection_properties`, `connection_mode` and `accept_connection` arguments to support specifying connection mode. +resource/aws_opensearch_outbound_connection: Add `connection_properties`, `connection_mode` and `accept_connection` arguments ``` diff --git a/internal/service/opensearch/outbound_connection.go b/internal/service/opensearch/outbound_connection.go index 7a4dc9065dc..5e0c4fe64ab 100644 --- a/internal/service/opensearch/outbound_connection.go +++ b/internal/service/opensearch/outbound_connection.go @@ -6,7 +6,6 @@ package opensearch import ( "context" "errors" - "fmt" "log" "time" @@ -18,14 +17,44 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" + "github.com/hashicorp/terraform-provider-aws/internal/tfresource" ) // @SDKResource("aws_opensearch_outbound_connection") func ResourceOutboundConnection() *schema.Resource { + outboundConnectionDomainInfoSchema := func() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Required: true, + ForceNew: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "domain_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "owner_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "region": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + }, + }, + } + } + return &schema.Resource{ CreateWithoutTimeout: resourceOutboundConnectionCreate, ReadWithoutTimeout: resourceOutboundConnectionRead, DeleteWithoutTimeout: resourceOutboundConnectionDelete, + Importer: &schema.ResourceImporter{ StateContext: schema.ImportStatePassthroughContext, }, @@ -36,6 +65,12 @@ func ResourceOutboundConnection() *schema.Resource { }, Schema: map[string]*schema.Schema{ + "accept_connection": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Default: false, + }, "connection_alias": { Type: schema.TypeString, Required: true, @@ -76,18 +111,12 @@ func ResourceOutboundConnection() *schema.Resource { }, }, }, - "local_domain_info": outboundConnectionDomainInfoSchema(), - "remote_domain_info": outboundConnectionDomainInfoSchema(), "connection_status": { Type: schema.TypeString, Computed: true, }, - "accept_connection": { - Type: schema.TypeBool, - Optional: true, - Default: false, - ForceNew: true, - }, + "local_domain_info": outboundConnectionDomainInfoSchema(), + "remote_domain_info": outboundConnectionDomainInfoSchema(), }, } } @@ -95,29 +124,25 @@ func ResourceOutboundConnection() *schema.Resource { func resourceOutboundConnectionCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.AWSClient).OpenSearchConn(ctx) - // Create the Outbound Connection - createOpts := &opensearchservice.CreateOutboundConnectionInput{ - ConnectionAlias: aws.String(d.Get("connection_alias").(string)), + connectionAlias := d.Get("connection_alias").(string) + input := &opensearchservice.CreateOutboundConnectionInput{ + ConnectionAlias: aws.String(connectionAlias), ConnectionMode: aws.String(d.Get("connection_mode").(string)), ConnectionProperties: expandOutboundConnectionConnectionProperties(d.Get("connection_properties").([]interface{})), LocalDomainInfo: expandOutboundConnectionDomainInfo(d.Get("local_domain_info").([]interface{})), RemoteDomainInfo: expandOutboundConnectionDomainInfo(d.Get("remote_domain_info").([]interface{})), } - log.Printf("[DEBUG] Outbound Connection Create options: %#v", createOpts) + output, err := conn.CreateOutboundConnectionWithContext(ctx, input) - resp, err := conn.CreateOutboundConnectionWithContext(ctx, createOpts) if err != nil { - return diag.Errorf("creating Outbound Connection: %s", err) + return diag.Errorf("creating OpenSearch Outbound Connection (%s): %s", connectionAlias, err) } - // Get the ID and store it - d.SetId(aws.StringValue(resp.ConnectionId)) - log.Printf("[INFO] Outbound Connection ID: %s", d.Id()) + d.SetId(aws.StringValue(output.ConnectionId)) - err = outboundConnectionWaitUntilAvailable(ctx, conn, d.Id(), d.Timeout(schema.TimeoutCreate)) - if err != nil { - return diag.Errorf("waiting for Outbound Connection to become available: %s", err) + if _, err := waitOutboundConnectionCreated(ctx, conn, d.Id(), d.Timeout(schema.TimeoutCreate)); err != nil { + return diag.Errorf("waiting for OpenSearch Outbound Connection (%s) create: %s", d.Id(), err) } if d.Get("accept_connection").(bool) { @@ -142,27 +167,24 @@ func resourceOutboundConnectionCreate(ctx context.Context, d *schema.ResourceDat func resourceOutboundConnectionRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.AWSClient).OpenSearchConn(ctx) - ccscRaw, statusCode, err := outboundConnectionRefreshState(ctx, conn, d.Id())() + connection, err := FindOutboundConnectionByID(ctx, conn, d.Id()) - if err != nil { - return diag.Errorf("reading Outbound Connection: %s", err) - } - - ccsc := ccscRaw.(*opensearchservice.OutboundConnection) - log.Printf("[DEBUG] Outbound Connection response: %#v", ccsc) - - if !d.IsNewResource() && statusCode == opensearchservice.OutboundConnectionStatusCodeDeleted { - log.Printf("[INFO] Outbound Connection (%s) deleted, removing from state", d.Id()) + if !d.IsNewResource() && tfresource.NotFound(err) { + log.Printf("[WARN] OpenSearch Outbound Connection (%s) not found, removing from state", d.Id()) d.SetId("") return nil } - d.Set("connection_alias", ccsc.ConnectionAlias) - d.Set("connection_mode", ccsc.ConnectionMode) - d.Set("connection_properties", flattenOutboundConnectionConnectionProperties(ccsc.ConnectionProperties)) - d.Set("remote_domain_info", flattenOutboundConnectionDomainInfo(ccsc.RemoteDomainInfo)) - d.Set("local_domain_info", flattenOutboundConnectionDomainInfo(ccsc.LocalDomainInfo)) - d.Set("connection_status", statusCode) + if err != nil { + return diag.Errorf("reading OpenSearch Outbound Connection (%s): %s", d.Id(), err) + } + + d.Set("connection_alias", connection.ConnectionAlias) + d.Set("connection_mode", connection.ConnectionMode) + d.Set("connection_properties", flattenOutboundConnectionConnectionProperties(connection.ConnectionProperties)) + d.Set("connection_status", connection.ConnectionStatus.StatusCode) + d.Set("remote_domain_info", flattenOutboundConnectionDomainInfo(connection.RemoteDomainInfo)) + d.Set("local_domain_info", flattenOutboundConnectionDomainInfo(connection.LocalDomainInfo)) return nil } @@ -180,61 +202,99 @@ func resourceOutboundConnectionDelete(ctx context.Context, d *schema.ResourceDat } if err != nil { - return diag.Errorf("deleting Outbound Connection (%s): %s", d.Id(), err) + return diag.Errorf("deleting OpenSearch Outbound Connection (%s): %s", d.Id(), err) } - if err := waitForOutboundConnectionDeletion(ctx, conn, d.Id(), d.Timeout(schema.TimeoutDelete)); err != nil { - return diag.Errorf("waiting for VPC Peering Connection (%s) to be deleted: %s", d.Id(), err) + if _, err := waitOutboundConnectionDeleted(ctx, conn, d.Id(), d.Timeout(schema.TimeoutCreate)); err != nil { + return diag.Errorf("waiting for OpenSearch Outbound Connection (%s) delete: %s", d.Id(), err) } return nil } -func outboundConnectionRefreshState(ctx context.Context, conn *opensearchservice.OpenSearchService, id string) retry.StateRefreshFunc { - return func() (interface{}, string, error) { - resp, err := conn.DescribeOutboundConnectionsWithContext(ctx, &opensearchservice.DescribeOutboundConnectionsInput{ - Filters: []*opensearchservice.Filter{ - { - Name: aws.String("connection-id"), - Values: []*string{aws.String(id)}, - }, +func FindOutboundConnectionByID(ctx context.Context, conn *opensearchservice.OpenSearchService, id string) (*opensearchservice.OutboundConnection, error) { + input := &opensearchservice.DescribeOutboundConnectionsInput{ + Filters: []*opensearchservice.Filter{ + { + Name: aws.String("connection-id"), + Values: aws.StringSlice([]string{id}), }, - }) - if err != nil { - return nil, "", err + }, + } + + output, err := findOutboundConnection(ctx, conn, input) + + if err != nil { + return nil, err + } + + if output.ConnectionStatus == nil { + return nil, tfresource.NewEmptyResultError(input) + } + + if status := aws.StringValue(output.ConnectionStatus.StatusCode); status == opensearchservice.OutboundConnectionStatusCodeDeleted { + return nil, &retry.NotFoundError{ + Message: status, + LastRequest: input, } + } - if resp == nil || resp.Connections == nil || - len(resp.Connections) == 0 || resp.Connections[0] == nil { - // Sometimes AWS just has consistency issues and doesn't see - // our connection yet. Return an empty state. - return nil, "", nil + return output, err +} + +func findOutboundConnection(ctx context.Context, conn *opensearchservice.OpenSearchService, input *opensearchservice.DescribeOutboundConnectionsInput) (*opensearchservice.OutboundConnection, error) { + output, err := findOutboundConnections(ctx, conn, input) + + if err != nil { + return nil, err + } + + return tfresource.AssertSinglePtrResult(output) +} + +func findOutboundConnections(ctx context.Context, conn *opensearchservice.OpenSearchService, input *opensearchservice.DescribeOutboundConnectionsInput) ([]*opensearchservice.OutboundConnection, error) { + var output []*opensearchservice.OutboundConnection + + err := conn.DescribeOutboundConnectionsPagesWithContext(ctx, input, func(page *opensearchservice.DescribeOutboundConnectionsOutput, lastPage bool) bool { + if page == nil { + return !lastPage + } + + for _, v := range page.Connections { + if v != nil { + output = append(output, v) + } } - ccsc := resp.Connections[0] - if ccsc.ConnectionStatus == nil { - // Sometimes AWS just has consistency issues and doesn't see - // our connection yet. Return an empty state. + + return !lastPage + }) + + if err != nil { + return nil, err + } + + return output, nil +} + +func statusOutboundConnection(ctx context.Context, conn *opensearchservice.OpenSearchService, id string) retry.StateRefreshFunc { + return func() (interface{}, string, error) { + output, err := FindOutboundConnectionByID(ctx, conn, id) + + if tfresource.NotFound(err) { return nil, "", nil } - statusCode := aws.StringValue(ccsc.ConnectionStatus.StatusCode) - // A Outbound Connection can exist in a failed state, - // thus we short circuit before the time out would occur. - if statusCode == opensearchservice.OutboundConnectionStatusCodeValidationFailed { - return nil, statusCode, errors.New(aws.StringValue(ccsc.ConnectionStatus.Message)) + if err != nil { + return nil, "", err } - return ccsc, statusCode, nil + return output, aws.StringValue(output.ConnectionStatus.StatusCode), nil } } -func outboundConnectionWaitUntilAvailable(ctx context.Context, conn *opensearchservice.OpenSearchService, id string, timeout time.Duration) error { - log.Printf("[DEBUG] Waiting for Outbound Connection (%s) to become available.", id) +func waitOutboundConnectionCreated(ctx context.Context, conn *opensearchservice.OpenSearchService, id string, timeout time.Duration) (*opensearchservice.OutboundConnection, error) { stateConf := &retry.StateChangeConf{ - Pending: []string{ - opensearchservice.OutboundConnectionStatusCodeValidating, - opensearchservice.OutboundConnectionStatusCodeProvisioning, - }, + Pending: []string{opensearchservice.OutboundConnectionStatusCodeValidating, opensearchservice.OutboundConnectionStatusCodeProvisioning}, Target: []string{ opensearchservice.OutboundConnectionStatusCodePendingAcceptance, opensearchservice.OutboundConnectionStatusCodeActive, @@ -242,16 +302,22 @@ func outboundConnectionWaitUntilAvailable(ctx context.Context, conn *opensearchs opensearchservice.OutboundConnectionStatusCodeRejected, opensearchservice.OutboundConnectionStatusCodeValidationFailed, }, - Refresh: outboundConnectionRefreshState(ctx, conn, id), + Refresh: statusOutboundConnection(ctx, conn, id), Timeout: timeout, } - if _, err := stateConf.WaitForStateContext(ctx); err != nil { - return fmt.Errorf("waiting for Outbound Connection (%s) to become available: %s", id, err) + + outputRaw, err := stateConf.WaitForStateContext(ctx) + + if output, ok := outputRaw.(*opensearchservice.OutboundConnection); ok { + tfresource.SetLastError(err, errors.New(aws.StringValue(output.ConnectionStatus.Message))) + + return output, err } - return nil + + return nil, err } -func waitForOutboundConnectionDeletion(ctx context.Context, conn *opensearchservice.OpenSearchService, id string, timeout time.Duration) error { +func waitOutboundConnectionDeleted(ctx context.Context, conn *opensearchservice.OpenSearchService, id string, timeout time.Duration) (*opensearchservice.OutboundConnection, error) { stateConf := &retry.StateChangeConf{ Pending: []string{ opensearchservice.OutboundConnectionStatusCodeActive, @@ -259,44 +325,20 @@ func waitForOutboundConnectionDeletion(ctx context.Context, conn *opensearchserv opensearchservice.OutboundConnectionStatusCodeDeleting, opensearchservice.OutboundConnectionStatusCodeRejecting, }, - Target: []string{ - opensearchservice.OutboundConnectionStatusCodeDeleted, - }, - Refresh: outboundConnectionRefreshState(ctx, conn, id), + Target: []string{}, + Refresh: statusOutboundConnection(ctx, conn, id), Timeout: timeout, } - _, err := stateConf.WaitForStateContext(ctx) + outputRaw, err := stateConf.WaitForStateContext(ctx) - return err -} + if output, ok := outputRaw.(*opensearchservice.OutboundConnection); ok { + tfresource.SetLastError(err, errors.New(aws.StringValue(output.ConnectionStatus.Message))) -func outboundConnectionDomainInfoSchema() *schema.Schema { - return &schema.Schema{ - Type: schema.TypeList, - Required: true, - ForceNew: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "owner_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "domain_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "region": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - }, - }, + return output, err } + + return nil, err } func expandOutboundConnectionDomainInfo(vOptions []interface{}) *opensearchservice.DomainInformationContainer { diff --git a/website/docs/r/opensearch_outbound_connection.html.markdown b/website/docs/r/opensearch_outbound_connection.html.markdown index febe429ac8e..ded5205d4d4 100644 --- a/website/docs/r/opensearch_outbound_connection.html.markdown +++ b/website/docs/r/opensearch_outbound_connection.html.markdown @@ -42,7 +42,7 @@ This resource supports the following arguments: * `connection_alias` - (Required, Forces new resource) Specifies the connection alias that will be used by the customer for this connection. * `connection_mode` - (Required, Forces new resource) Specifies the connection mode. Accepted values are `DIRECT` or `VPC_ENDPOINT`. * `accept_connection` - (Optional, Forces new resource) Accepts the connection. -* `connection_properties` - (Optional, Forces new resource) Configuration block for the outbound connection.. +* `connection_properties` - (Optional, Forces new resource) Configuration block for the outbound connection. * `local_domain_info` - (Required, Forces new resource) Configuration block for the local Opensearch domain. * `remote_domain_info` - (Required, Forces new resource) Configuration block for the remote Opensearch domain. From 8361bb1065e76fe5bddfa64e8864ec5c27801394 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 25 Sep 2023 18:28:41 -0400 Subject: [PATCH 10/10] Fix golangci-lint 'unparam'. --- internal/service/opensearch/inbound_connection_accepter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/opensearch/inbound_connection_accepter.go b/internal/service/opensearch/inbound_connection_accepter.go index adddae7063d..8eb6a21dc58 100644 --- a/internal/service/opensearch/inbound_connection_accepter.go +++ b/internal/service/opensearch/inbound_connection_accepter.go @@ -216,7 +216,7 @@ func statusInboundConnection(ctx context.Context, conn *opensearchservice.OpenSe } } -func waitInboundConnectionAccepted(ctx context.Context, conn *opensearchservice.OpenSearchService, id string, timeout time.Duration) (*opensearchservice.InboundConnection, error) { +func waitInboundConnectionAccepted(ctx context.Context, conn *opensearchservice.OpenSearchService, id string, timeout time.Duration) (*opensearchservice.InboundConnection, error) { //nolint:unparam stateConf := &retry.StateChangeConf{ Pending: []string{opensearchservice.InboundConnectionStatusCodeProvisioning, opensearchservice.InboundConnectionStatusCodeApproved}, Target: []string{opensearchservice.InboundConnectionStatusCodeActive},