Skip to content

Commit

Permalink
README.md: update defaults and examples
Browse files Browse the repository at this point in the history
- Use a default version for the `tailnet` configuration parameter and
  remove it from the example;
- Suggest a weaker version constraint that uses the latest patch
  release;
- Document using OAuth client credentials rather than personal API keys;
- Make it more clear that setting `base_url` is only necessary if you
  are using a non-default coordination server.

Fixes #207
Fixes #243
  • Loading branch information
knyar committed Aug 17, 2023
1 parent 63e3fc7 commit 912ce37
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
30 changes: 20 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# terraform-provider-tailscale
# terraform-provider-tailscale

[![Go Reference](https://pkg.go.dev/badge/github.com/tailscale/terraform-provider-tailscale.svg)](https://pkg.go.dev/github.com/tailscale/terraform-provider-tailscale)
[![Go Report Card](https://goreportcard.com/badge/github.com/tailscale/terraform-provider-tailscale)](https://goreportcard.com/report/github.com/tailscale/terraform-provider-tailscale)
Expand All @@ -21,26 +21,36 @@ terraform {
required_providers {
tailscale = {
source = "tailscale/tailscale"
version = "0.13.6"
version = "~> 0.13" // Latest 0.13.x
}
}
}
provider "tailscale" {
api_key = "my_api_key"
tailnet = "example.com"
api_key = "tskey-api-..."
}
```

In the `provider` block, replace `api_key` and `tailnet` with your own API key and tailnet organization name. Alternatively, use the
`TAILSCALE_API_KEY` and `TAILSCALE_TAILNET` environment variables.
In the `provider` block, set your API key in the `api_key` field. Alternatively, use the `TAILSCALE_API_KEY` environment variable.

The default api endpoint is `https://api.tailscale.com`. If your coordination/control server api is at another endpoint, you can pass in `base_url` in the provider block.
### Using OAuth client

Instead of using a personal API key, you can configure the provider to use an [OAuth client](https://tailscale.com/kb/1215/oauth-clients/), e.g.:

```terraform
provider "tailscale" {
oauth_client_id = "..."
oauth_client_secret = "tskey-client-..."
}
```

### API endpoint

The default api endpoint is `https://api.tailscale.com`. If your coordination/control server API is at another endpoint, you can pass in `base_url` in the provider block.

```terraform
provider "tailscale" {
api_key = "my_api_key"
tailnet = "example.com"
api_key = "tskey-api-..."
base_url = "https://api.us.tailscale.com"
}
```
Expand All @@ -54,5 +64,5 @@ terraform state replace-provider registry.terraform.io/davidsbond/tailscale regi
## Contributing

Please review the [contributing guidelines](./CONTRIBUTING.md) and [code of conduct](.github/CODE_OF_CONDUCT.md) before
contributing to this codebase. Please create a [new issue](https://github.com/tailscale/terraform-provider-tailscale/issues/new/choose)
contributing to this codebase. Please create a [new issue](https://github.com/tailscale/terraform-provider-tailscale/issues/new/choose)
for bugs and feature requests and fill in as much detail as you can.
4 changes: 2 additions & 2 deletions tailscale/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ func Provider(options ...ProviderOption) *schema.Provider {
},
"tailnet": {
Type: schema.TypeString,
DefaultFunc: schema.EnvDefaultFunc("TAILSCALE_TAILNET", ""),
DefaultFunc: schema.EnvDefaultFunc("TAILSCALE_TAILNET", "-"),
Optional: true,
Description: "The organization name of the Tailnet in which to perform actions. Can be set via the TAILSCALE_TAILNET environment variable.",
Description: "The organization name of the Tailnet in which to perform actions. Can be set via the TAILSCALE_TAILNET environment variable. Default is the tailnet that owns API credentials passed to the provider.",
},
"base_url": {
Type: schema.TypeString,
Expand Down

0 comments on commit 912ce37

Please sign in to comment.