Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Commit

Permalink
Add quickstart section about resource dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
floriandejonckheere committed Feb 13, 2022
1 parent 4e17b91 commit 8770c89
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.2.0] - 2021-12-02
## [0.3.0] - 2022-02-13

Initial release.
- Add dependencies between resources
- Show old and new attribute values in execution plan

## [0.2.0] - 2021-12-02

- Add SSH Key and Server resource
- Update only changed attributes
Expand Down
49 changes: 49 additions & 0 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,55 @@ end
Try changing the name of the SSH key in the Hetzner Cloud panel as well.
You'll see that Kozo tries to revert the name change.

## Dependent resources

Resource can depend on other resources for their values.
Kozo will make sure that the dependent resources are created in the correct order.

Append the following to your `main.kz` file:

```ruby
resource "hcloud_server", "default" do |s|
s.name = "default"
s.location = "fsn1"
s.image = "debian-11"
s.server_type = "cx11"
s.ssh_keys = [hcloud_ssh_key.default]
s.user_data = File.read("cloud-init.yml")

s.labels = {
primary: "true",
}
end
```

```sh
$ kozo plan
...

# hcloud_server.default:
+ resource "hcloud_server", "default" do |r|
r.id = (known after apply)
+ r.name = "default"
+ r.image = "debian-11"
+ r.server_type = "cx11"
+ r.location = "fsn1"
r.datacenter = nil
+ r.labels = {
primary = "true"
}
r.locked = (known after apply)
r.created = (known after apply)
+ r.user_data = "#cloud-config timezone: Europe/Berlin locale: C.UTF-8 ntp: enabled: ..."
+ r.ssh_keys = [
5562231
]
end

```

Note that the SSH key reference was resolved to the ID of the SSH key that was previously created.

## Destroy a resource

Instruct Kozo that the resource should be deleted simply by removing the relevant lines in the `main.kz` file.
Expand Down

0 comments on commit 8770c89

Please sign in to comment.