Skip to content

Commit

Permalink
Updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
disc committed Sep 6, 2021
1 parent 9929107 commit 2a1f250
Showing 1 changed file with 68 additions and 3 deletions.
71 changes: 68 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ resource "pritunl_organization" "developers" {
# Create a pritunl user resource
resource "pritunl_user" "steve" {
name = "steve"
organization_id = pritunl_organization.test.id
organization_id = pritunl_organization.developers.id
email = "[email protected]"
groups = [
"developers",
]
}
# Create a pritunl server resource
resource "pritunl_server" "test" {
name = "test"
resource "pritunl_server" "example" {
name = "example"
port = 15500
protocol = "udp"
network = "192.168.1.0/24"
Expand Down Expand Up @@ -109,6 +109,71 @@ resource "pritunl_server" "test" {
}
```

## Importing exist resources

Describe exist resource in the terraform file first and then import them:

```hcl
# Describe a pritunl organization resource
resource "pritunl_organization" "developers" {
name = "Developers"
}
```

Import an organization:
```sh
terraform import pritunl_organization.developers ${ORGANIZATION_ID}
terraform import pritunl_organization.developers 610e42d2a0ed366f41dfe6e8
```
The organization ID (as well as other resource IDs) can be found in the Pritunl API responses or in the HTML document response.

```hcl
# Describe a pritunl user resource
resource "pritunl_user" "steve" {
name = "steve"
organization_id = pritunl_organization.developers.id
email = "[email protected]"
}
```

Import a user:
```sh
terraform import pritunl_user.steve ${ORGANIZATION_ID}-${USER_ID}
terraform import pritunl_user.steve 610e42d2a0ed366f41dfe6e8-610e42d6a0ed366f41dfe72b
```

```hcl
# Describe a pritunl server resource
resource "pritunl_server" "example" {
name = "example"
port = 15500
protocol = "udp"
network = "192.168.1.0/24"
groups = [
"developers",
]
# Attach the organization to the server
organization_ids = [
pritunl_organization.developers.id,
]
# Describe all the routes manually
# Default route 0.0.0.0/0 will be deleted on the server creation
route {
network = "10.0.0.0/24"
comment = "Private network #1"
nat = true
}
}
```

Import a server:
```sh
terraform import pritunl_server.example ${SERVER_ID}
terraform import pritunl_server.example 60cd0bfa7723cf3c911468a8
```

## License

The Terraform Pritunl Provider is available to everyone under the terms of the Mozilla Public License Version 2.0. [Take a look the LICENSE file](LICENSE).

0 comments on commit 2a1f250

Please sign in to comment.