Skip to content

Commit

Permalink
Stateless resources require kibana (#792)
Browse files Browse the repository at this point in the history
* Stateless resources require kibana

* Changelog
  • Loading branch information
tobio authored Mar 6, 2024
1 parent 0f02f8d commit 8c29ee8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/792.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:feature
resource/deployment: Validate the Kibana is present when attempting to enable other stateless resources.
```
6 changes: 6 additions & 0 deletions ec/ecresource/deploymentresource/apm/v2/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,22 @@ package v2

import (
"github.com/elastic/terraform-provider-ec/ec/internal/planmodifiers"
"github.com/hashicorp/terraform-plugin-framework-validators/objectvalidator"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
)

func ApmConfigSchema() schema.Attribute {
return schema.SingleNestedAttribute{
Description: `Optionally define the Apm configuration options for the APM Server`,
Optional: true,
Validators: []validator.Object{
objectvalidator.AlsoRequires(path.MatchRoot("kibana")),
},
Attributes: map[string]schema.Attribute{
"docker_image": schema.StringAttribute{
Description: "Optionally override the docker image the APM nodes will use. This option will not work in ESS customers and should only be changed if you know what you're doing.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,23 @@ package v2

import (
"github.com/elastic/terraform-provider-ec/ec/internal/planmodifiers"
"github.com/hashicorp/terraform-plugin-framework-validators/objectvalidator"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
)

func EnterpriseSearchSchema() schema.Attribute {
return schema.SingleNestedAttribute{
Description: "Enterprise Search cluster definition.",
Optional: true,
Validators: []validator.Object{
objectvalidator.AlsoRequires(path.MatchRoot("kibana")),
},
Attributes: map[string]schema.Attribute{
"elasticsearch_cluster_ref_id": schema.StringAttribute{
Optional: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,25 @@ package v2

import (
"github.com/elastic/terraform-provider-ec/ec/internal/planmodifiers"
"github.com/hashicorp/terraform-plugin-framework-validators/objectvalidator"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
)

func IntegrationsServerSchema() schema.Attribute {
return schema.SingleNestedAttribute{
Description: "Integrations Server cluster definition. Integrations Server replaces `apm` in Stack versions > 8.0",
Optional: true,
Validators: []validator.Object{
objectvalidator.AlsoRequires(path.MatchRoot("kibana")),
},
Attributes: map[string]schema.Attribute{
"elasticsearch_cluster_ref_id": schema.StringAttribute{
Optional: true,
Expand Down

0 comments on commit 8c29ee8

Please sign in to comment.