This Terraform custom provider is designed for managing domains.
Terraform version | minimum provider version | maxmimum provider version |
---|---|---|
>= 1.3.x | 0.1.1 | latest |
-
Run make file
make install-local-domain-management
to install the provider under ~/.terraform.d/plugins. -
The provider source should be change to the path that configured in the Makefile:
terraform { required_providers { domain-management = { source = "example.local/myklst/domain-management" } } } provider "domain-management" { url = "http://localhost:10800 }
-
domain-management_domain_annotations
This resource is desgined to accept a domain name, and a Dynamic Terraform Object with a
JSON
like syntax, which will be assigned as annotations to the domain.
- Dot
.
and dollar sign$
are not allowed for key name. Null
value or empty value on right hand side is not allowed.Object
cannot be empty.List / Set / Tuple
cannot have length of zero.List / Set / Tuple
must have contents that are of a single type.List / Set / Tuple
of objects, the object must have the exact same keys and nested keys.
- Flat data structure is accepted.
resource "..." "example" {
domain = test.com
annotations = {
"common/devops/status" = true
"common/devops/last-run" = "yesterday"
}
}
- Object data structure is also accepted.
resource "..." "example" {
domain = test.com
annotations = {
"common/devops" = {
status = true
"last-run" = "yesterday"
}
}
}
- Note that in the two examples above
common/devops
andcommon/devops/status
are stored as two separate root keys in the database. They will not be merged. - When in doubt, follow Kubernetes labels and annotations style.
- Use
tolist([1,2,3])
to avoid using tuple. Tuple is not ordered and will cause terraform to see it as configuration drift.
- Each terraform module is responsible for their own annotations.
- Module A would not, and should not interfere with annotations of Module B.
- Each module takes ownership of single or multiple root keys, by having the equivalent key in its statefile.
DB Data
annotations = {
common/A = {...}
common/B = {...}
common/C = {...}
}
ModuleA
resource "..." "example" {
domain = test.com
annotations = {
"common/A" = {
status = true
}
}
}
ModuleB
resource "..." "example" {
domain = test.com
annotations = {
"common/B" = {
status = false
}
}
}
- If root key exists, further
Create
reqest of the same key will fail. Update
is used to update the entire right hand side of a key.Update
cannot be used on a non-existent root key.- In Terraform's update lifecycle, root keys may be created, updated or deleted. Each will be handled by separate API calls.
-
domain-management_domain_filter
This resource is desgined to filter domains based on key value, namely filter by labels and / or filter by tags. This data source returns a list of string of domain names for further use in
domain-management_domain_annotations
.