Skip to content

Commit

Permalink
r/aws_elasticsearch_domain: Add custom_endpoint validators
Browse files Browse the repository at this point in the history
  • Loading branch information
matiaszilli committed Nov 18, 2020
1 parent 8250597 commit 5e7841b
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions aws/resource_aws_elasticsearch_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,22 @@ func resourceAwsElasticSearchDomain() *schema.Resource {
Default: false,
},
"custom_endpoint": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringDoesNotMatch(regexp.MustCompile(`\.$`), "cannot end with a period"),
},
"custom_endpoint_certificate_arn": {
Type: schema.TypeString,
Optional: true,
StateFunc: func(v interface{}) string {
// AWS Provider aws_acm_certification.domain_validation_options.resource_record_name
// references (and perhaps others) contain a trailing period, requiring a custom StateFunc
// to trim the string to prevent Route53 API error
value := strings.TrimSuffix(v.(string), ".")
return strings.ToLower(value)
},
DiffSuppressFunc: isCustomEndpointDisabled,
},
"custom_endpoint_certificate_arn": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validateArn,
DiffSuppressFunc: isCustomEndpointDisabled,
},
},
},
Expand Down Expand Up @@ -1051,6 +1060,15 @@ func isDedicatedMasterDisabled(k, old, new string, d *schema.ResourceData) bool
return false
}

func isCustomEndpointDisabled(k, old, new string, d *schema.ResourceData) bool {
v, ok := d.GetOk("domain_endpoint_options")
if ok {
domainEndpointOptions := v.([]interface{})[0].(map[string]interface{})
return !domainEndpointOptions["custom_endpoint_enabled"].(bool)
}
return false
}

func expandESNodeToNodeEncryptionOptions(s map[string]interface{}) *elasticsearch.NodeToNodeEncryptionOptions {
options := elasticsearch.NodeToNodeEncryptionOptions{}

Expand Down

0 comments on commit 5e7841b

Please sign in to comment.