Skip to content

Commit

Permalink
Add pubkey-from-file example
Browse files Browse the repository at this point in the history
  • Loading branch information
bkircher committed Jan 26, 2021
1 parent 49f3b94 commit a91bd66
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ To make use of the examples, you will need a [gridscale.io](https://my.gridscale
- [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.
- [pubkey-from-file](pubkey-from-file/README.md): Example that shows how to load an SSH public key file with `file()`.

## More

Expand Down
3 changes: 3 additions & 0 deletions pubkey-from-file/.envrc
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
10 changes: 10 additions & 0 deletions pubkey-from-file/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SSH pubkey from file

This is a small example that shows how to load an SSH public key file from disk with `file()`

```hcl
resource "gridscale_sshkey" "demo" {
name = "demo"
sshkey = file("/home/john/.ssh/id_rsa.pub")
}
```
36 changes: 36 additions & 0 deletions pubkey-from-file/example.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
terraform {
required_providers {
gridscale = {
source = "gridscale/gridscale"
version = "~> 1.8.2"
}
}
}

resource "gridscale_server" "demo" {
name = "demo"
cores = 1
memory = 1
storage {
object_uuid = gridscale_storage.demo.id
}
power = false
}

resource "gridscale_storage" "demo" {
name = "demo"
capacity = 10
template {
template_uuid = data.gridscale_template.ubuntu.id
sshkeys = [gridscale_sshkey.demo.id]
}
}

resource "gridscale_sshkey" "demo" {
name = "demo"
sshkey = file("/home/john/.ssh/id_rsa.pub")
}

data "gridscale_template" "ubuntu" {
name = "Ubuntu 18.04 LTS"
}

0 comments on commit a91bd66

Please sign in to comment.