-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Make sure examples use plugin from Terraform Registry and TF 0.13 by giving this preamble: terraform { required_providers { gridscale = { source = "gridscale/gridscale" } } } - Flatten hierarchy and remove trivial examples - List examples and a short summary in README - Make sure every example has it's own README - Make sure all examples actually work
- Loading branch information
Showing
15 changed files
with
117 additions
and
179 deletions.
There are no files selected for viewing
This file contains 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,9 +1,19 @@ | ||
# Terraform configuration examples for gridscale | ||
# Terraform Examples for gridscale | ||
|
||
This repository contains configuration files you can use as a starting point for [Terraform](https://www.terraform.io/) on gridscale. We also have some step-by-step guides on how to use these config files in our [tutorials](https://gridscale.io/en/community/tutorials/terraform-ubuntu-einrichten-gridscale/) section. Check them out! | ||
This repository contains small self-contained Terraform projects you can use as a starting point for using [Terraform](https://www.terraform.io/) with gridscale. It showcases how easy it is to manage gridscale resources with Terraform in simple as well as more advanced scenarios. | ||
|
||
To use the config files, you'll need an [API token](https://my.gridscale.io/Easy/APIs/) and a [gridscale](https://my.gridscale.io/signup/) account. | ||
To make use of the examples, you will need a [gridscale.io](https://my.gridscale.io/signup/) account and an [API token](https://my.gridscale.io/Easy/APIs/). | ||
|
||
After Terraform is up and running, you can navigate to one of the example directories and run `terraform init` and `terraform apply`. You will be prompted to enter your API credentials by Terraform. | ||
## Examples | ||
|
||
- [single-server](single-server/README.md): A simple example that shows how a complete server with attached storage, template selection, and networking can be described in Terraform. | ||
- [provisioner](provisioner/README.md): Shows how to integrate Ansible with Terraform to provision your servers and assign them your Ansible roles. | ||
- [multi-project](multi-project/README.md): Describes how you could get Terraform to work in a multi-project scenario. | ||
|
||
## More | ||
|
||
Check out the provider's [reference documentation](https://registry.terraform.io/providers/gridscale/gridscale/latest/docs) for all Data Sources and Resources, along with a complete list of the arguments they accept. | ||
|
||
We also have an introductory-level guide on how to setup and use Terraform in our [tutorials](https://gridscale.io/en/community/tutorials/terraform-ubuntu-einrichten-gridscale/) section. Check it out. | ||
|
||
Have fun! |
This file contains 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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,3 +1,3 @@ | ||
export GRIDSCALE_TOKEN=project-a-api-token | ||
export GRIDSCALE_TOKEN=your-api-token | ||
export GRIDSCALE_URL=https://api.gridscale.io | ||
export GRIDSCALE_UUID=your-user-id |
File renamed without changes.
This file contains 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
File renamed without changes.
This file contains 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 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,3 @@ | ||
export GRIDSCALE_TOKEN=your-api-token | ||
export GRIDSCALE_URL=https://api.gridscale.io | ||
export GRIDSCALE_UUID=your-user-id |
This file contains 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,42 @@ | ||
# A Simple Server | ||
|
||
This is a simple example that show how to use resources and data sources to create a basic running server. | ||
|
||
## Running the Example | ||
|
||
Set `GRIDSCALE_TOKEN` and `GRIDSCALE_UUID` environment variables to the values you got from your panel. | ||
|
||
$ export GRIDSCALE_TOKEN=your-api-token | ||
$ export GRIDSCALE_UUID=your-user-id | ||
|
||
Open `server.tf` and paste your SSH public key where it says `"INSERT KEY"`. Then do | ||
|
||
$ terraform init | ||
|
||
Note that this will download the gridscale provider plugin to `.terraform/`. | ||
|
||
Let's create the server. Do | ||
|
||
$ terraform apply | ||
|
||
Terraform will now plan the actions it is about to perform. You should see something like: | ||
|
||
```raw | ||
Plan: 5 to add, 0 to change, 0 to destroy. | ||
``` | ||
|
||
Investigate the actions that Terraform is about to perform and type `yes`. After about 30 seconds, Terraform will print | ||
|
||
```raw | ||
Apply complete! Resources: 5 added, 0 changed, 0 destroyed. | ||
``` | ||
|
||
Go ahead and inspect the panel for the newly created objects. When your done, remove all resources again by doing | ||
|
||
$ terraform destroy | ||
|
||
After a few moments, everything is removed again. | ||
|
||
```raw | ||
Destroy complete! Resources: 5 destroyed. | ||
``` |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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,47 @@ | ||
terraform { | ||
required_providers { | ||
gridscale = { | ||
source = "gridscale/gridscale" | ||
} | ||
} | ||
} | ||
|
||
resource "gridscale_server" "demo" { | ||
name = "demo" | ||
cores = 1 | ||
memory = 2 | ||
storage { | ||
object_uuid = gridscale_storage.demo.id | ||
} | ||
network { | ||
object_uuid = gridscale_network.demo.id | ||
} | ||
ipv4 = gridscale_ipv4.demo.id | ||
power = true | ||
} | ||
|
||
resource "gridscale_storage" "demo" { | ||
name = "demo" | ||
capacity = 10 | ||
template { | ||
template_uuid = data.gridscale_template.ubuntu.id | ||
sshkeys = [gridscale_sshkey.demo.id] | ||
} | ||
} | ||
|
||
resource "gridscale_network" "demo" { | ||
name = "demo" | ||
} | ||
|
||
resource "gridscale_ipv4" "demo" { | ||
name = "demo" | ||
} | ||
|
||
resource "gridscale_sshkey" "demo" { | ||
name = "demo" | ||
sshkey = "INSERT KEY" | ||
} | ||
|
||
data "gridscale_template" "ubuntu" { | ||
name = "Ubuntu 18.04 LTS" | ||
} |
This file was deleted.
Oops, something went wrong.