Skip to content

Commit

Permalink
Fixed error in the instance resource and update the doc for the templ…
Browse files Browse the repository at this point in the history
…ate datasource

close #43

Signed-off-by: Alejandro J. Nuñez Madrazo <alejandrojnm@gmail.com>
  • Loading branch information
alejandrojnm committed Jul 27, 2021
1 parent 7dcacff commit d0b506a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 3 additions & 1 deletion civo/resource_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func resourceInstance() *schema.Resource {
"template": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "The ID for the template to use to build the instance",
},
"initial_user": {
Expand All @@ -80,6 +81,7 @@ func resourceInstance() *schema.Resource {
"firewall_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "The ID of the firewall to use, from the current list. If left blank or not sent, the default firewall will be used (open to all)",
},
"tags": {
Expand Down Expand Up @@ -326,7 +328,7 @@ func resourceInstanceRead(d *schema.ResourceData, m interface{}) error {
d.Set("notes", resp.Notes)

if _, ok := d.GetOk("template"); ok {
d.Set("template", resp.TemplateID)
d.Set("template", d.Get("template").(string))
}

return nil
Expand Down
27 changes: 26 additions & 1 deletion docs/data-sources/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,36 @@ resource "civo_instance" "foo-host" {
}
```

It is similar to the previous one with the difference that in this one we use region to only look for the templates of that region.
The Instance/Kubernetes cluster where you use this data source must be in the same region.

```hcl
data "civo_template" "debian" {
region = "LON1"
filter {
key = "name"
values = ["debian"]
match_by = "re"
}
sort {
key = "version"
direction = "asc"
}
}
resource "civo_instance" "foo-host" {
region = "LON1"
hostname = "foo.com"
size = element(data.civo_instances_size.small.sizes, 0).name
template = element(data.civo_template.debian.templates, 0).id
}
```

## Argument Reference

The following arguments are supported:

* `region` - (Optional) If is used, them all instances will be from that region.
* `region` - (Optional) If is used, them all template will be from that region, has to be declared here if is not declared in the provider
* `filter` - (Optional) Filter the results. The `filter` block is documented below.
* `sort` - (Optional) Sort the results. The `sort` block is documented below.

Expand Down

0 comments on commit d0b506a

Please sign in to comment.