Skip to content

Commit

Permalink
Merge pull request #36 from achachw/master
Browse files Browse the repository at this point in the history
feat: Add support for env variables
  • Loading branch information
pablo-ruth authored Jan 27, 2022
2 parents d5ae8e3 + ad0f71b commit c105cfd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,23 @@ provider "ldap" {
```

<!-- schema generated by tfplugindocs -->

## Environment variables

You can provide your credentials via the LDAP_USER, LDAP_PASSWORD, LDAP_HOST and LDAP_PORT environment variables.
In this case, ldap provider could be represented like this
```
provider "ldap" {}
```
Usage
```
$ export LDAP_USER="ldap_user"
$ export LDAP_PASSWORD="ldap_password"
$ export LDAP_HOST="ldap.mycompany.tld"
$ export LDAP_PORT=389
$ terraform plan
```

## Schema

### Required
Expand Down
4 changes: 4 additions & 0 deletions ldap/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,24 @@ func Provider() *schema.Provider {
"host": {
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("LDAP_HOST", nil),
Description: "LDAP host",
},
"port": {
Type: schema.TypeInt,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("LDAP_PORT", nil),
Description: "LDAP port",
},
"bind_user": {
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("LDAP_USER", nil),
Description: "LDAP username",
},
"bind_password": {
Type: schema.TypeString,
DefaultFunc: schema.EnvDefaultFunc("LDAP_PASSWORD", nil),
Required: true,
Description: "LDAP password",
},
Expand Down

0 comments on commit c105cfd

Please sign in to comment.