Skip to content

Commit

Permalink
init commit of elasticsearch require https
Browse files Browse the repository at this point in the history
  • Loading branch information
barrytam20 committed Oct 9, 2019
1 parent 071671b commit ac8d447
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions aws/resource_aws_elasticsearch_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ func resourceAwsElasticSearchDomain() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"require_https": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"endpoint": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -361,6 +366,12 @@ func resourceAwsElasticSearchDomainCreate(d *schema.ResourceData, meta interface
input.AdvancedOptions = stringMapToPointers(v.(map[string]interface{}))
}

if d.Get("require_https").(bool) {
input.DomainEndpointOptions = &elasticsearch.DomainEndpointOptions{
EnforceHTTPS: aws.Bool(true),
}
}

if v, ok := d.GetOk("ebs_options"); ok {
options := v.([]interface{})

Expand Down Expand Up @@ -642,6 +653,10 @@ func resourceAwsElasticSearchDomainRead(d *schema.ResourceData, meta interface{}
d.Set("log_publishing_options", m)
}

if ds.DomainEndpointOptions != nil && ds.DomainEndpointOptions.EnforceHTTPS {
d.Set("require_https", true)
}

d.Set("arn", ds.ARN)

listOut, err := conn.ListTags(&elasticsearch.ListTagsInput{
Expand Down Expand Up @@ -684,6 +699,12 @@ func resourceAwsElasticSearchDomainUpdate(d *schema.ResourceData, meta interface
input.AdvancedOptions = stringMapToPointers(d.Get("advanced_options").(map[string]interface{}))
}

if d.HasChange("require_https") {
input.SetDomainEndpointOptions(&elasticsearch.DomainEndpointOptions{
EnforceHTTPS: aws.Bool(d.Get("require_https").(string)),
})
}

if d.HasChange("ebs_options") || d.HasChange("cluster_config") {
options := d.Get("ebs_options").([]interface{})

Expand Down
1 change: 1 addition & 0 deletions website/docs/r/elasticsearch_domain.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ The following arguments are supported:
* `vpc_options` - (Optional) VPC related options, see below. Adding or removing this configuration forces a new resource ([documentation](https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-vpc.html#es-vpc-limitations)).
* `log_publishing_options` - (Optional) Options for publishing slow logs to CloudWatch Logs.
* `elasticsearch_version` - (Optional) The version of Elasticsearch to deploy. Defaults to `1.5`
* `require_https` - (Optional) Whether the Elasticsearch domain requires HTTPS to connect
* `tags` - (Optional) A mapping of tags to assign to the resource

**ebs_options** supports the following attributes:
Expand Down

0 comments on commit ac8d447

Please sign in to comment.