-
Notifications
You must be signed in to change notification settings - Fork 148
Add alerting connector data source #607
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
Merged
Merged
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
7991613
Add alerting connector data source
wandergeek 6266939
wee fixes
wandergeek 9ab7916
add docs
wandergeek 47e4866
docs detail
wandergeek 5d9eedb
Changelog
wandergeek e8921fd
Update internal/clients/kibana/connector_test.go
wandergeek fcc5262
fix tabs
wandergeek 1159735
add action connector template
wandergeek aa9da27
add docs
wandergeek 6ce6cc8
error message tweaks
wandergeek 0586f8a
wip
wandergeek 242fb7d
wip tests
wandergeek a9d9e5d
bail early on connector search
wandergeek 14b280e
set ID on found resource
wandergeek f0f1dfa
fix example
wandergeek eab4a16
fix acc test
wandergeek b8c3a26
data source schema tweaks
wandergeek 3c98ee1
regen docs
wandergeek 64c3c0e
rename doc template name
wandergeek 0d20608
regen docs again
wandergeek 19f51fa
allow searches on connector type
wandergeek 7c63a69
move data source function
wandergeek 40f45f8
remove checks in connector client used for data source, add more tests
wandergeek 8570d15
Merge branch 'main' into connector-data-source
wandergeek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| --- | ||
| subcategory: "Kibana" | ||
| layout: "" | ||
| page_title: "Elasticstack: elasticstack_kibana_action_connector Data Source" | ||
| description: |- | ||
| Retrieve a specific action connector role. See https://www.elastic.co/guide/en/kibana/current/get-all-connectors-api.html. | ||
| --- | ||
|
|
||
| # Data Source: elasticstack_kibana_action_connector | ||
|
|
||
| Use this data source to get information about an existing action connector. | ||
|
|
||
| ## Example Usage | ||
|
|
||
| ```terraform | ||
| provider "elasticstack" { | ||
| elasticsearch {} | ||
| kibana {} | ||
| } | ||
|
|
||
| data "elasticstack_kibana_action_connector" "example" { | ||
| name = "myslackconnector" | ||
| space_id = "default" | ||
| connector_type_id = ".slack" | ||
| } | ||
|
|
||
| output "connector_id" { | ||
| value = data.elasticstack_kibana_action_connector.example.connector_id | ||
| } | ||
| ``` | ||
|
|
||
| <!-- schema generated by tfplugindocs --> | ||
| ## Schema | ||
|
|
||
| ### Required | ||
|
|
||
| - `name` (String) The name of the connector. While this name does not have to be unique, a distinctive name can help you identify a connector. | ||
|
|
||
| ### Optional | ||
|
|
||
| - `connector_type_id` (String) The ID of the connector type, e.g. `.index`. | ||
| - `space_id` (String) An identifier for the space. If space_id is not provided, the default space is used. | ||
|
|
||
| ### Read-Only | ||
|
|
||
| - `config` (String) The configuration for the connector. Configuration properties vary depending on the connector type. | ||
| - `connector_id` (String) A UUID v1 or v4 randomly generated ID. | ||
| - `id` (String) The ID of this resource. | ||
| - `is_deprecated` (Boolean) Indicates whether the connector type is deprecated. | ||
| - `is_missing_secrets` (Boolean) Indicates whether secrets are missing for the connector. | ||
| - `is_preconfigured` (Boolean) Indicates whether it is a preconfigured connector. |
14 changes: 14 additions & 0 deletions
14
examples/data-sources/elasticstack_kibana_action_connector/data-source.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| provider "elasticstack" { | ||
| elasticsearch {} | ||
| kibana {} | ||
| } | ||
|
|
||
| data "elasticstack_kibana_action_connector" "example" { | ||
| name = "myslackconnector" | ||
| space_id = "default" | ||
| connector_type_id = ".slack" | ||
| } | ||
|
|
||
| output "connector_id" { | ||
| value = data.elasticstack_kibana_action_connector.example.connector_id | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| package kibana | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/elastic/terraform-provider-elasticstack/internal/clients" | ||
| "github.com/elastic/terraform-provider-elasticstack/internal/clients/kibana" | ||
| "github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
| "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
| ) | ||
|
|
||
| func DataSourceConnector() *schema.Resource { | ||
|
wandergeek marked this conversation as resolved.
|
||
| var connectorSchema = map[string]*schema.Schema{ | ||
| "connector_id": { | ||
| Description: "A UUID v1 or v4 randomly generated ID.", | ||
| Type: schema.TypeString, | ||
| Computed: true, | ||
| }, | ||
| "space_id": { | ||
| Description: "An identifier for the space. If space_id is not provided, the default space is used.", | ||
| Type: schema.TypeString, | ||
| Optional: true, | ||
| Default: "default", | ||
| }, | ||
| "name": { | ||
| Description: "The name of the connector. While this name does not have to be unique, a distinctive name can help you identify a connector.", | ||
| Type: schema.TypeString, | ||
| Required: true, | ||
| }, | ||
| "connector_type_id": { | ||
| Description: "The ID of the connector type, e.g. `.index`.", | ||
| Type: schema.TypeString, | ||
| Optional: true, | ||
|
wandergeek marked this conversation as resolved.
|
||
| }, | ||
| "config": { | ||
| Description: "The configuration for the connector. Configuration properties vary depending on the connector type.", | ||
| Type: schema.TypeString, | ||
| Computed: true, | ||
| }, | ||
| "is_deprecated": { | ||
| Description: "Indicates whether the connector type is deprecated.", | ||
| Type: schema.TypeBool, | ||
| Computed: true, | ||
| }, | ||
| "is_missing_secrets": { | ||
| Description: "Indicates whether secrets are missing for the connector.", | ||
| Type: schema.TypeBool, | ||
| Computed: true, | ||
| }, | ||
| "is_preconfigured": { | ||
| Description: "Indicates whether it is a preconfigured connector.", | ||
| Type: schema.TypeBool, | ||
| Computed: true, | ||
| }, | ||
| } | ||
|
|
||
| return &schema.Resource{ | ||
| Description: "Search for a connector by name, space id, and type. Note, that this data source will fail if more than one connector shares the same name.", | ||
| ReadContext: datasourceConnectorRead, | ||
| Schema: connectorSchema, | ||
| } | ||
| } | ||
|
|
||
| func datasourceConnectorRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { | ||
| client, diags := clients.NewApiClientFromSDKResource(d, meta) | ||
| if diags.HasError() { | ||
| return diags | ||
| } | ||
| name := d.Get("name").(string) | ||
| spaceId := d.Get("space_id").(string) | ||
| connectorType := d.Get("connector_type_id").(string) | ||
|
|
||
| connector, diags := kibana.SearchConnector(ctx, client, name, spaceId, connectorType) | ||
| if diags.HasError() { | ||
| return diags | ||
| } | ||
|
wandergeek marked this conversation as resolved.
|
||
|
|
||
| compositeID := &clients.CompositeId{ClusterId: spaceId, ResourceId: connector.ConnectorID} | ||
| d.SetId(compositeID.String()) | ||
|
|
||
| return flattenActionConnector(connector, d) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.