Skip to content

Commit 0413885

Browse files
authored
Document all environment variables used within the provider. (#405)
* Add additional env variables for client config * Update docs with env variable configuration * Generate docs * CHANGELOG.md
1 parent 9be9f1f commit 0413885

File tree

12 files changed

+89
-15
lines changed

12 files changed

+89
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### Added
44
- Add support for Kibana SLOs ([#385](https://github.com/elastic/terraform-provider-elasticstack/pull/385))
5+
- Document all available environment variables ([#405](https://github.com/elastic/terraform-provider-elasticstack/pull/405))
56

67
## [0.6.2] - 2023-06-19
78

docs/index.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ The following methods are supported:
2626

2727
### Static credentials
2828

29-
Default static credentials can be provided by adding the `username`, `password` and `endpoints` in `elasticsearch` block:
29+
#### Elasticsearch
30+
31+
Default static credentials can be provided by adding the `username`, `password` and `endpoints` in the `elasticsearch` block:
3032

3133
```terraform
3234
provider "elasticstack" {
@@ -49,16 +51,47 @@ provider "elasticstack" {
4951
}
5052
```
5153

54+
#### Kibana
55+
56+
Default static credentials can be provided by adding the `username`, `password` and `endpoints` in the `kibana` block:
57+
58+
```terraform
59+
provider "elasticstack" {
60+
kibana {
61+
username = "elastic"
62+
password = "changeme"
63+
endpoints = ["http://localhost:5601"]
64+
}
65+
}
66+
```
67+
68+
If no credentials are supplied the provider will fall back to using those provided in the `elasticsearch` block.
69+
5270
### Environment Variables
5371

54-
You can provide your credentials for the default connection via the `ELASTICSEARCH_USERNAME`, `ELASTICSEARCH_PASSWORD` and comma-separated list `ELASTICSEARCH_ENDPOINTS`,
55-
environment variables, representing your user, password and Elasticsearch API endpoints respectively.
72+
The provider configuration can be specified through environment variables.
73+
74+
For Elasticsearch resources, you can use the following variables:
75+
- `ELASTICSEARCH_USERNAME` - The username to use for Elasticsearch authentication
76+
- `ELASTICSEARCH_PASSWORD` - The password to use for Elasticsearch authentication
77+
- `ELASTICSEARCH_ENDPOINTS` - A comma separated list of Elasticsearch hosts to connect to
78+
- `ELASTICSEARCH_API_KEY` - An Elasticsearch API key to use instead of `ELASTICSEARCH_USERNAME` and `ELASTICSEARCH_PASSWORD`
79+
80+
Kibana resources will re-use any Elasticsearch credentials specified, these may be overridden with the following variables:
81+
- `KIBANA_USERNAME` - The username to use for Kibana authentication
82+
- `KIBANA_PASSWORD` - The password to use for Kibana authentication
83+
- `KIBANA_ENDPOINT` - The Kibana host to connect to
5684

57-
Alternatively the `ELASTICSEARCH_API_KEY` variable can be specified instead of `ELASTICSEARCH_USERNAME` and `ELASTICSEARCH_PASSWORD`.
85+
Fleet resources will re-use any Kibana or Elasticsearch credentials specified, these may be overridden with the following variables:
86+
- `FLEET_USERNAME` - The username to use for Kibana authentication
87+
- `FLEET_PASSWORD` - The password to use for Kibana authentication
88+
- `FLEET_ENDPOINT` - The Kibana host to connect to. ** Note the Fleet API is hosted within Kibana. This must be a Kibana HTTP host **
89+
- `FLEET_API_KEY` - API key to use for authentication to Fleet
5890

5991
```terraform
6092
provider "elasticstack" {
6193
elasticsearch {}
94+
kibana {}
6295
}
6396
```
6497

docs/resources/kibana_action_connector.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Creates or updates a Kibana action connector. See https://www.elastic.co/guide/e
1414

1515
```terraform
1616
provider "elasticstack" {
17-
elasticsearch {}
17+
kibana {}
1818
}
1919
2020
resource "elasticstack_kibana_action_connector" "example" {

docs/resources/kibana_alerting_rule.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Creates or updates a Kibana alerting rule. See https://www.elastic.co/guide/en/k
1414

1515
```terraform
1616
provider "elasticstack" {
17-
elasticsearch {}
17+
kibana {}
1818
}
1919
2020
resource "elasticstack_kibana_alerting_rule" "example" {

docs/resources/kibana_space.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Creates or updates a Kibana space. See https://www.elastic.co/guide/en/kibana/ma
1414

1515
```terraform
1616
provider "elasticstack" {
17-
elasticsearch {}
17+
kibana {}
1818
}
1919
2020
resource "elasticstack_kibana_space" "example" {

examples/provider/kibana.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
provider "elasticstack" {
2+
kibana {
3+
username = "elastic"
4+
password = "changeme"
5+
endpoints = ["http://localhost:5601"]
6+
}
7+
}

examples/provider/provider-env.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
provider "elasticstack" {
22
elasticsearch {}
3+
kibana {}
34
}
4-

examples/resources/elasticstack_kibana_action_connector/resource.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
provider "elasticstack" {
2-
elasticsearch {}
2+
kibana {}
33
}
44

55
resource "elasticstack_kibana_action_connector" "example" {

examples/resources/elasticstack_kibana_alerting_rule/resource.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
provider "elasticstack" {
2-
elasticsearch {}
2+
kibana {}
33
}
44

55
resource "elasticstack_kibana_alerting_rule" "example" {

examples/resources/elasticstack_kibana_space/resource.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
provider "elasticstack" {
2-
elasticsearch {}
2+
kibana {}
33
}
44

55
resource "elasticstack_kibana_space" "example" {

internal/clients/api_client.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,15 @@ func buildFleetClient(d *schema.ResourceData, kibanaCfg kibana.Config) (*fleet.C
668668
}
669669
}
670670

671+
if v := os.Getenv("FLEET_ENDPOINT"); v != "" {
672+
config.URL = v
673+
}
674+
if v := os.Getenv("FLEET_USERNAME"); v != "" {
675+
config.Username = v
676+
}
677+
if v := os.Getenv("FLEET_PASSWORD"); v != "" {
678+
config.Password = v
679+
}
671680
if v := os.Getenv("FLEET_API_KEY"); v != "" {
672681
config.APIKey = v
673682
}

templates/index.md.tmpl

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,44 @@ The following methods are supported:
2626

2727
### Static credentials
2828

29-
Default static credentials can be provided by adding the `username`, `password` and `endpoints` in `elasticsearch` block:
29+
#### Elasticsearch
30+
31+
Default static credentials can be provided by adding the `username`, `password` and `endpoints` in the `elasticsearch` block:
3032

3133
{{tffile "examples/provider/provider.tf"}}
3234

3335
Alternatively an `api_key` can be specified instead of `username` and `password`:
3436

3537
{{tffile "examples/provider/provider-apikey.tf"}}
3638

39+
#### Kibana
40+
41+
Default static credentials can be provided by adding the `username`, `password` and `endpoints` in the `kibana` block:
42+
43+
{{tffile "examples/provider/kibana.tf"}}
44+
45+
If no credentials are supplied the provider will fall back to using those provided in the `elasticsearch` block.
46+
3747
### Environment Variables
3848

39-
You can provide your credentials for the default connection via the `ELASTICSEARCH_USERNAME`, `ELASTICSEARCH_PASSWORD` and comma-separated list `ELASTICSEARCH_ENDPOINTS`,
40-
environment variables, representing your user, password and Elasticsearch API endpoints respectively.
49+
The provider configuration can be specified through environment variables.
50+
51+
For Elasticsearch resources, you can use the following variables:
52+
- `ELASTICSEARCH_USERNAME` - The username to use for Elasticsearch authentication
53+
- `ELASTICSEARCH_PASSWORD` - The password to use for Elasticsearch authentication
54+
- `ELASTICSEARCH_ENDPOINTS` - A comma separated list of Elasticsearch hosts to connect to
55+
- `ELASTICSEARCH_API_KEY` - An Elasticsearch API key to use instead of `ELASTICSEARCH_USERNAME` and `ELASTICSEARCH_PASSWORD`
56+
57+
Kibana resources will re-use any Elasticsearch credentials specified, these may be overridden with the following variables:
58+
- `KIBANA_USERNAME` - The username to use for Kibana authentication
59+
- `KIBANA_PASSWORD` - The password to use for Kibana authentication
60+
- `KIBANA_ENDPOINT` - The Kibana host to connect to
4161

42-
Alternatively the `ELASTICSEARCH_API_KEY` variable can be specified instead of `ELASTICSEARCH_USERNAME` and `ELASTICSEARCH_PASSWORD`.
62+
Fleet resources will re-use any Kibana or Elasticsearch credentials specified, these may be overridden with the following variables:
63+
- `FLEET_USERNAME` - The username to use for Kibana authentication
64+
- `FLEET_PASSWORD` - The password to use for Kibana authentication
65+
- `FLEET_ENDPOINT` - The Kibana host to connect to. ** Note the Fleet API is hosted within Kibana. This must be a Kibana HTTP host **
66+
- `FLEET_API_KEY` - API key to use for authentication to Fleet
4367

4468
{{tffile "examples/provider/provider-env.tf"}}
4569

0 commit comments

Comments
 (0)