-
Notifications
You must be signed in to change notification settings - Fork 3
chore: update readme, add version warnings, examples #71
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
ethanndickson
merged 1 commit into
main
from
08-13-chore_update_readme_add_version_warnings_examples
Aug 13, 2024
Merged
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,35 @@ | ||
# Coderd Terraform Provider | ||
# terraform-provider-coderd | ||
|
||
# ⚠️ WORK IN PROGRESS - DO NOT USE ⚠️ | ||
`terraform-provider-coderd` enables managing a [Coder](https://github.com/coder/coder) deployment using [Terraform](https://github.com/hashicorp/terraform) IaC. | ||
|
||
_This template repository is built on the [Terraform Plugin Framework](https://github.com/hashicorp/terraform-plugin-framework). The template repository built on the [Terraform Plugin SDK](https://github.com/hashicorp/terraform-plugin-sdk) can be found at [terraform-provider-scaffolding](https://github.com/hashicorp/terraform-provider-scaffolding). See [Which SDK Should I Use?](https://developer.hashicorp.com/terraform/plugin/framework-benefits) in the Terraform documentation for additional information._ | ||
|
||
This repository is a *template* for a [Terraform](https://www.terraform.io) provider. It is intended as a starting point for creating Terraform providers, containing: | ||
|
||
- A resource and a data source (`internal/provider/`), | ||
- Examples (`examples/`) and generated documentation (`docs/`), | ||
- Miscellaneous meta files. | ||
|
||
These files contain boilerplate code that you will need to edit to create your own Terraform provider. Tutorials for creating Terraform providers can be found on the [HashiCorp Developer](https://developer.hashicorp.com/terraform/tutorials/providers-plugin-framework) platform. _Terraform Plugin Framework specific guides are titled accordingly._ | ||
|
||
Please see the [GitHub template repository documentation](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template) for how to create a new repository from this template on GitHub. | ||
|
||
Once you've written your provider, you'll want to [publish it on the Terraform Registry](https://developer.hashicorp.com/terraform/registry/providers/publishing) so that others can use it. | ||
The provider currently supports resources and data sources for: | ||
- Users | ||
- Templates + Template Versions | ||
- Groups | ||
- Workspace Proxies | ||
- Organizations (Data Source only) | ||
|
||
## Requirements | ||
|
||
- [Terraform](https://developer.hashicorp.com/terraform/downloads) >= 1.0 | ||
- [Go](https://golang.org/doc/install) >= 1.21 | ||
- [Coder](https://github.com/coder/coder) >= 2.10.1 | ||
|
||
## Building The Provider | ||
|
||
1. Clone the repository | ||
1. Enter the repository directory | ||
1. Build the provider using the Go `install` command: | ||
|
||
```shell | ||
go install | ||
``` | ||
|
||
## Adding Dependencies | ||
|
||
This provider uses [Go modules](https://github.com/golang/go/wiki/Modules). | ||
Please see the Go documentation for the most up to date information about using Go modules. | ||
|
||
To add a new dependency `github.com/author/dependency` to your Terraform provider: | ||
|
||
```shell | ||
go get github.com/author/dependency | ||
go mod tidy | ||
``` | ||
|
||
Then commit the changes to `go.mod` and `go.sum`. | ||
|
||
## Using the provider | ||
## Usage | ||
|
||
Fill this in for each provider | ||
See the [`examples`](examples) and the [documentation](https://registry.terraform.io/providers/coder/coderd/latest/docs). | ||
|
||
## Developing the Provider | ||
|
||
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (see [Requirements](#requirements) above). | ||
|
||
To compile the provider, run `go install`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory. | ||
|
||
To generate or update documentation, run `go generate`. | ||
To generate or update documentation, run `make gen`. | ||
|
||
In order to run the full suite of Acceptance tests, run `make testacc`. | ||
### Terraform Acceptance Tests | ||
|
||
*Note:* Acceptance tests create real resources, and often cost money to run. | ||
Acceptance tests are run against a live Coder deployment in a local Docker container. To run the full suite of Acceptance tests, run `make testacc`. | ||
|
||
```shell | ||
make testacc | ||
``` | ||
> [!NOTE] | ||
> Our [CI workflow](./github/workflows/test.yml) runs an acceptance test matrix against multiple Terraform versions. |
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
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 |
---|---|---|
|
@@ -10,7 +10,33 @@ description: |- | |
|
||
A group on the Coder deployment. If you want to have a group resource with unmanaged members, but still want to read the members in Terraform, use the `data.coderd_group` data source. Creating groups requires an Enterprise license. | ||
|
||
|
||
## Example Usage | ||
|
||
```terraform | ||
// Provider populated from environment variables | ||
provider "coderd" {} | ||
|
||
resource "coderd_user" "coder1" { | ||
username = "coder1" | ||
name = "Coder One" | ||
email = "[email protected]" | ||
} | ||
|
||
resource "coderd_user" "coder2" { | ||
username = "coder2" | ||
name = "Coder One" | ||
email = "[email protected]" | ||
} | ||
|
||
// Add two users to the group by their ID. | ||
resource "coderd_group" "group1" { | ||
name = "group1" | ||
members = [ | ||
coderd_user.coder1.id, | ||
coderd_user.coder2.id | ||
] | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
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 |
---|---|---|
|
@@ -10,7 +10,40 @@ description: |- | |
|
||
A Coder template | ||
|
||
|
||
## Example Usage | ||
|
||
```terraform | ||
// Provider populated from environment variables | ||
provider "coderd" {} | ||
|
||
// Get the commit SHA of the configuration's git repository | ||
variable "TFC_CONFIGURATION_VERSION_GIT_COMMIT_SHA" { | ||
type = string | ||
} | ||
|
||
resource "coderd_user" "coder1" { | ||
username = "coder1" | ||
name = "Coder One" | ||
email = "[email protected]" | ||
} | ||
|
||
resource "coderd_template" "ubuntu-main" { | ||
name = "ubuntu-main" | ||
description = "The main template for developing on Ubuntu." | ||
versions = [ | ||
{ | ||
name = "stable-${var.TFC_CONFIGURATION_VERSION_GIT_COMMIT_SHA}" | ||
description = "The stable version of the template." | ||
directory = "./stable-template" | ||
}, | ||
{ | ||
name = "staging-${var.TFC_CONFIGURATION_VERSION_GIT_COMMIT_SHA}" | ||
description = "The staging version of the template." | ||
directory = "./staging-template" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
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 |
---|---|---|
|
@@ -10,7 +10,37 @@ description: |- | |
|
||
A user on the Coder deployment. | ||
|
||
|
||
## Example Usage | ||
|
||
```terraform | ||
// Provider populated from environemnt variables | ||
provider "coderd" {} | ||
|
||
// Create a bot user for Jenkins | ||
resource "coderd_user" "jenkins" { | ||
username = "jenkins" | ||
name = "Jenkins CI/CD" | ||
email = "[email protected]" | ||
roles = ["template-admin"] | ||
login_type = "none" | ||
} | ||
|
||
// Keep the password of a user account up to date from an external source | ||
resource "coderd_user" "audit" { | ||
username = "auditor" | ||
name = "Auditor" | ||
email = "[email protected]" | ||
roles = ["auditor"] | ||
login_type = "password" | ||
password = data.vault_password.auditor.value | ||
} | ||
|
||
// Ensure the admin account is suspended | ||
resource "coderd_user" "admin" { | ||
username = "admin" | ||
suspended = true | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,23 @@ | ||
// Provider populated from environment variables | ||
provider "coderd" {} | ||
|
||
resource "coderd_user" "coder1" { | ||
username = "coder1" | ||
name = "Coder One" | ||
email = "[email protected]" | ||
} | ||
|
||
resource "coderd_user" "coder2" { | ||
username = "coder2" | ||
name = "Coder One" | ||
email = "[email protected]" | ||
} | ||
|
||
// Add two users to the group by their ID. | ||
resource "coderd_group" "group1" { | ||
name = "group1" | ||
members = [ | ||
coderd_user.coder1.id, | ||
coderd_user.coder2.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Provider populated from environment variables | ||
provider "coderd" {} | ||
|
||
// Get the commit SHA of the configuration's git repository | ||
variable "TFC_CONFIGURATION_VERSION_GIT_COMMIT_SHA" { | ||
type = string | ||
} | ||
|
||
resource "coderd_user" "coder1" { | ||
username = "coder1" | ||
name = "Coder One" | ||
email = "[email protected]" | ||
} | ||
|
||
resource "coderd_template" "ubuntu-main" { | ||
name = "ubuntu-main" | ||
description = "The main template for developing on Ubuntu." | ||
versions = [ | ||
{ | ||
name = "stable-${var.TFC_CONFIGURATION_VERSION_GIT_COMMIT_SHA}" | ||
description = "The stable version of the template." | ||
directory = "./stable-template" | ||
}, | ||
{ | ||
name = "staging-${var.TFC_CONFIGURATION_VERSION_GIT_COMMIT_SHA}" | ||
description = "The staging version of the template." | ||
directory = "./staging-template" | ||
} | ||
] | ||
} |
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,27 @@ | ||
// Provider populated from environemnt variables | ||
provider "coderd" {} | ||
|
||
// Create a bot user for Jenkins | ||
resource "coderd_user" "jenkins" { | ||
username = "jenkins" | ||
name = "Jenkins CI/CD" | ||
email = "[email protected]" | ||
roles = ["template-admin"] | ||
login_type = "none" | ||
} | ||
|
||
// Keep the password of a user account up to date from an external source | ||
resource "coderd_user" "audit" { | ||
username = "auditor" | ||
name = "Auditor" | ||
email = "[email protected]" | ||
roles = ["auditor"] | ||
login_type = "password" | ||
password = data.vault_password.auditor.value | ||
} | ||
|
||
// Ensure the admin account is suspended | ||
resource "coderd_user" "admin" { | ||
username = "admin" | ||
suspended = true | ||
} |
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
Oops, something went wrong.
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.