-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
r/aws_elasticsearch_domain: Add custom endpoint support #16192
Changes from 7 commits
34e2ebf
8250597
5e7841b
5217ecb
6522655
f0aceec
cffafc4
02f9366
9cb98eb
5e686ec
b3102a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,7 +140,8 @@ func resourceAwsElasticSearchDomain() *schema.Resource { | |
Schema: map[string]*schema.Schema{ | ||
"enforce_https": { | ||
Type: schema.TypeBool, | ||
Required: true, | ||
Optional: true, | ||
Default: true, | ||
}, | ||
"tls_security_policy": { | ||
Type: schema.TypeString, | ||
|
@@ -151,6 +152,29 @@ func resourceAwsElasticSearchDomain() *schema.Resource { | |
elasticsearch.TLSSecurityPolicyPolicyMinTls12201907, | ||
}, false), | ||
}, | ||
"custom_endpoint_enabled": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
Default: false, | ||
}, | ||
"custom_endpoint": { | ||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like it has been lifted directly from https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-customendpoint.html suggests you can leave a trailing dot at the end but the console may just strip that. I was also wondering if there was a common validate function that checks it's a valid FQDN (max length in total and per label etc) but I don't see one elsewhere in the code base or in the plugin SDK. At the least the comment here probably wants updating. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, I have just lifted that code from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is generally preferable to leave out these types of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perfect @bflad , I will get rid of that validation. |
||
}, | ||
DiffSuppressFunc: isCustomEndpointDisabled, | ||
}, | ||
"custom_endpoint_certificate_arn": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ValidateFunc: validateArn, | ||
DiffSuppressFunc: isCustomEndpointDisabled, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
@@ -1037,6 +1061,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{} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the reasoning for this change? I don't see any explanation in 5217ecb and it looks like an unnecessary change at a glance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, because it doesn't has to be a necessary attribute to set. For example, you might want to enable a custom endpoint, so you would have to just set
custom_endpoint_enabled
andcustom_endpoint
attributes and no more that that.