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

Elasticsearch adding vpc endpoint resource #33925

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .changelog/33925.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

```release-note:new-resource
aws_elasticsearch_vpc_endpoint
```
2 changes: 1 addition & 1 deletion internal/service/elasticsearch/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,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/elasticsearch/domain_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,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
9 changes: 9 additions & 0 deletions internal/service/elasticsearch/exports_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package elasticsearch

// Exports for use in tests only.
var (
FindVPCEndpointByID = findVPCEndpointByID
VPCEndpointsError = vpcEndpointsError
)
20 changes: 14 additions & 6 deletions internal/service/elasticsearch/flex.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,17 @@ func expandEncryptAtRestOptions(m map[string]interface{}) *elasticsearch.Encrypt
}

func expandVPCOptions(m map[string]interface{}) *elasticsearch.VPCOptions {
if m == nil {
return nil
}

options := elasticsearch.VPCOptions{}

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

return &options
Expand Down Expand Up @@ -215,7 +219,11 @@ func flattenSnapshotOptions(snapshotOptions *elasticsearch.SnapshotOptions) []ma
return []map[string]interface{}{m}
}

func flattenVPCDerivedInfo(o *elasticsearch.VPCDerivedInfo) []map[string]interface{} {
func flattenVPCDerivedInfo(o *elasticsearch.VPCDerivedInfo) map[string]interface{} {
if o == nil {
return nil
}

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

if o.AvailabilityZones != nil {
Expand All @@ -231,5 +239,5 @@ func flattenVPCDerivedInfo(o *elasticsearch.VPCDerivedInfo) []map[string]interfa
m["vpc_id"] = aws.StringValue(o.VPCId)
}

return []map[string]interface{}{m}
return m
}
4 changes: 4 additions & 0 deletions internal/service/elasticsearch/service_package_gen.go

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

Loading
Loading