Skip to content

Commit

Permalink
r/aws_elasticsearch_domain: export kibana endpoint (#2804)
Browse files Browse the repository at this point in the history
* r/aws_elasticsearch_domain: export kibana endpoint

* add testacc to check kibana_endpoint;
add documentation;
extract function to get kibana endpoint
  • Loading branch information
loivis authored and Ninir committed Jan 10, 2018
1 parent 9dda90a commit 10d502a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions aws/resource_aws_elasticsearch_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ func resourceAwsElasticSearchDomain() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"kibana_endpoint": {
Type: schema.TypeString,
Computed: true,
},
"ebs_options": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -480,12 +484,14 @@ func resourceAwsElasticSearchDomainRead(d *schema.ResourceData, meta interface{}
if err != nil {
return err
}
d.Set("kibana_endpoint", getKibanaEndpoint(d))
if ds.Endpoint != nil {
return fmt.Errorf("%q: Elasticsearch domain in VPC expected to have null Endpoint value", d.Id())
}
} else {
if ds.Endpoint != nil {
d.Set("endpoint", *ds.Endpoint)
d.Set("kibana_endpoint", getKibanaEndpoint(d))
}
if ds.Endpoints != nil {
return fmt.Errorf("%q: Elasticsearch domain not in VPC expected to have null Endpoints value", d.Id())
Expand Down Expand Up @@ -676,3 +682,7 @@ func resourceAwsElasticSearchDomainDelete(d *schema.ResourceData, meta interface

return err
}

func getKibanaEndpoint(d *schema.ResourceData) string {
return d.Get("endpoint").(string) + "/_plugin/kibana/"
}
1 change: 1 addition & 0 deletions aws/resource_aws_elasticsearch_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func TestAccAWSElasticSearchDomain_basic(t *testing.T) {
testAccCheckESDomainExists("aws_elasticsearch_domain.example", &domain),
resource.TestCheckResourceAttr(
"aws_elasticsearch_domain.example", "elasticsearch_version", "1.5"),
resource.TestMatchResourceAttr("aws_elasticsearch_domain.example", "kibana_endpoint", regexp.MustCompile(".*es.amazonaws.com/_plugin/kibana/")),
),
},
},
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 @@ -109,6 +109,7 @@ The following attributes are exported:
* `arn` - Amazon Resource Name (ARN) of the domain.
* `domain_id` - Unique identifier for the domain.
* `endpoint` - Domain-specific endpoint used to submit index, search, and data upload requests.
* `kibana_endpoint` - Domain-specific endpoint for kibana without https scheme.
* `vpc_options.0.availability_zones` - If the domain was created inside a VPC, the names of the availability zones the configured `subnet_ids` were created inside.
* `vpc_options.0.vpc_id` - If the domain was created inside a VPC, the ID of the VPC.

Expand Down

0 comments on commit 10d502a

Please sign in to comment.