Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

F create aws open search vpc endpoint #32435

Merged
merged 51 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
48337fa
implemented new resource aws opensearch vpc endpoint connection
Jul 10, 2023
5314a3b
Merge branch 'hashicorp:main' into f-opensearch-vpc-endpoint
lafod Jul 10, 2023
2db394c
added documentation
Jul 10, 2023
89d8356
Merge branch 'f-opensearch-vpc-endpoint' of https://github.com/lafod/…
Jul 10, 2023
bffccae
fix format in test file
Jul 10, 2023
d13f878
fix format in test file
Jul 10, 2023
14f59a9
fix website format
Jul 11, 2023
473c248
fix website format
Jul 11, 2023
02a3aff
fix website format
Jul 11, 2023
1cd95fb
fix website format
Jul 11, 2023
573bfd7
fix website format
Jul 11, 2023
843b36b
fix website format
Jul 11, 2023
ff4cfd5
fix website format
Jul 11, 2023
2e44250
fix website format
Jul 11, 2023
748609a
website format
Jul 11, 2023
301d732
website format
Jul 11, 2023
978d1e6
website format
Jul 11, 2023
74cf843
website format
Jul 11, 2023
d1243c3
refactor: updated test.go
debojitmegaco Jul 11, 2023
00a8376
fix indentation
debojitmegaco Jul 11, 2023
6ee6301
lint fix
debojitmegaco Jul 11, 2023
6882a5b
remove whitespace
Jul 12, 2023
0dc7b66
remove unnecessary trailing newline
Aug 15, 2023
5787fce
updated documentation
Aug 15, 2023
29ca27a
updated documentation
Aug 15, 2023
df4db09
updated documentation
Aug 15, 2023
0deb277
updated documentation
Aug 15, 2023
c5a2b02
updated documentation
Aug 15, 2023
68ca2aa
updated documentation
Aug 15, 2023
d47cb9c
Merge branch 'main' into HEAD
ewbankkit Aug 15, 2023
1051089
updated documentation
Aug 15, 2023
134cab4
Fix tfproviderdocs 'the first import section code block should have a…
ewbankkit Aug 15, 2023
9cd61e9
Merge commit '134cab4477abd455489b0fb975171bc9660e3a61' into HEAD
ewbankkit Aug 15, 2023
6330fd8
Correct CHANGELOG entry.
ewbankkit Aug 15, 2023
31e3c9c
r/aws_opensearch_vpc_endpoint_connection: Document 'timeouts'.
ewbankkit Aug 15, 2023
4ec51b5
r/aws_opensearch_vpc_endpoint_connection: Alphabetize attribute.
ewbankkit Aug 15, 2023
852c0d0
updated resource name to vpc endpoint
Aug 15, 2023
05f07d6
merge head
Aug 15, 2023
8b8bd42
updated test case
Aug 15, 2023
12309e0
updated documentation name
Aug 15, 2023
815b34e
Correct CHANGELOG entry.
ewbankkit Aug 15, 2023
70bbb06
r/aws_opensearch_vpc_endpoint: 'vpc_options' is Required.
ewbankkit Aug 15, 2023
7032caf
opensearch: Add 'vpcEndpointError' etc.
ewbankkit Aug 15, 2023
f12aa3c
r/aws_opensearch_vpc_endpoint: Tidy up resource Delete.
ewbankkit Aug 15, 2023
86929f3
r/aws_opensearch_vpc_endpoint: Tidy up resource Read.
ewbankkit Aug 15, 2023
634f268
r/aws_opensearch_vpc_endpoint: Tidy up resource Update.
ewbankkit Aug 15, 2023
a05d4bf
r/aws_opensearch_vpc_endpoint: Add 'endpoint' attribute.
ewbankkit Aug 15, 2023
fe52f6b
r/aws_opensearch_vpc_endpoint: Tidy up waiters.
ewbankkit Aug 15, 2023
be9de72
r/aws_opensearch_vpc_endpoint: Tidy up acceptance tests.
ewbankkit Aug 15, 2023
c8b1698
Fix callers of 'flattenVPCDerivedInfo'.
ewbankkit Aug 15, 2023
1bed608
Add 'TestAccOpenSearchVPCEndpoint_update'.
ewbankkit Aug 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/32435.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
aws_opensearch_vpc_endpoint
```
2 changes: 1 addition & 1 deletion internal/service/opensearch/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ func resourceDomainRead(ctx context.Context, d *schema.ResourceData, meta interf
}

if ds.VPCOptions != nil {
if err := d.Set("vpc_options", flattenVPCDerivedInfo(ds.VPCOptions)); err != nil {
if err := d.Set("vpc_options", []interface{}{flattenVPCDerivedInfo(ds.VPCOptions)}); err != nil {
return sdkdiag.AppendErrorf(diags, "setting vpc_options: %s", err)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/service/opensearch/domain_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ func dataSourceDomainRead(ctx context.Context, d *schema.ResourceData, meta inte
}

if ds.VPCOptions != nil {
if err := d.Set("vpc_options", flattenVPCDerivedInfo(ds.VPCOptions)); err != nil {
if err := d.Set("vpc_options", []interface{}{flattenVPCDerivedInfo(ds.VPCOptions)}); err != nil {
return sdkdiag.AppendErrorf(diags, "setting vpc_options: %s", err)
}

Expand Down
10 changes: 10 additions & 0 deletions internal/service/opensearch/exports_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package opensearch

// Exports for use in tests only.
var (
FindVPCEndpointByID = findVPCEndpointByID
VPCEndpointsError = vpcEndpointsError
)
60 changes: 36 additions & 24 deletions internal/service/opensearch/flex.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,6 @@ func expandEncryptAtRestOptions(m map[string]interface{}) *opensearchservice.Enc
return &options
}

func expandVPCOptions(m map[string]interface{}) *opensearchservice.VPCOptions {
options := opensearchservice.VPCOptions{}

if v, ok := m["security_group_ids"]; ok {
options.SecurityGroupIds = flex.ExpandStringSet(v.(*schema.Set))
}
if v, ok := m["subnet_ids"]; ok {
options.SubnetIds = flex.ExpandStringSet(v.(*schema.Set))
}

return &options
}

func flattenCognitoOptions(c *opensearchservice.CognitoOptions) []map[string]interface{} {
m := map[string]interface{}{}

Expand Down Expand Up @@ -216,21 +203,46 @@ func flattenSnapshotOptions(snapshotOptions *opensearchservice.SnapshotOptions)
return []map[string]interface{}{m}
}

func flattenVPCDerivedInfo(o *opensearchservice.VPCDerivedInfo) []map[string]interface{} {
m := map[string]interface{}{}
func expandVPCOptions(tfMap map[string]interface{}) *opensearchservice.VPCOptions {
if tfMap == nil {
return nil
}

if o.AvailabilityZones != nil {
m["availability_zones"] = flex.FlattenStringSet(o.AvailabilityZones)
apiObject := &opensearchservice.VPCOptions{}

if v, ok := tfMap["security_group_ids"].(*schema.Set); ok && v.Len() > 0 {
apiObject.SecurityGroupIds = flex.ExpandStringSet(v)
}
if o.SecurityGroupIds != nil {
m["security_group_ids"] = flex.FlattenStringSet(o.SecurityGroupIds)

if v, ok := tfMap["subnet_ids"].(*schema.Set); ok && v.Len() > 0 {
apiObject.SubnetIds = flex.ExpandStringSet(v)
}
if o.SubnetIds != nil {
m["subnet_ids"] = flex.FlattenStringSet(o.SubnetIds)

return apiObject
}

func flattenVPCDerivedInfo(apiObject *opensearchservice.VPCDerivedInfo) map[string]interface{} {
if apiObject == nil {
return nil
}
if o.VPCId != nil {
m["vpc_id"] = aws.StringValue(o.VPCId)

tfMap := map[string]interface{}{}

if v := apiObject.AvailabilityZones; v != nil {
tfMap["availability_zones"] = aws.StringValueSlice(v)
}

return []map[string]interface{}{m}
if v := apiObject.SecurityGroupIds; v != nil {
tfMap["security_group_ids"] = aws.StringValueSlice(v)
}

if v := apiObject.SubnetIds; v != nil {
tfMap["subnet_ids"] = aws.StringValueSlice(v)
}

if v := apiObject.VPCId; v != nil {
tfMap["vpc_id"] = aws.StringValue(v)
}

return tfMap
}
4 changes: 4 additions & 0 deletions internal/service/opensearch/service_package_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading