Skip to content

Commit

Permalink
Merge branch 'main' into fmatavelli-add-extra-resources
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiomatavelli committed Feb 18, 2024
2 parents 11119dc + 27c14cf commit 5b3dd8a
Show file tree
Hide file tree
Showing 14 changed files with 509 additions and 19 deletions.
2 changes: 1 addition & 1 deletion cloudstack/data_source_cloudstack_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func dataSourceCloudstackZoneRead(d *schema.ResourceData, meta interface{}) erro
}

func zoneDescriptionAttributes(d *schema.ResourceData, zone *cloudstack.Zone) error {
d.SetId(zone.Name)
d.SetId(zone.Id)
d.Set("name", zone.Name)
d.Set("dns1", zone.Dns1)
d.Set("internal_dns1", zone.Internaldns1)
Expand Down
2 changes: 1 addition & 1 deletion cloudstack/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func testSetIDOnResourceData(t *testing.T) {
setValueOrID(&d, "id", "name", "54711781-274e-41b2-83c0-17194d0108f7")

if d.Get("id").(string) != "54711781-274e-41b2-83c0-17194d0108f7" {
t.Fatal("err: 'id' doest not match '54711781-274e-41b2-83c0-17194d0108f7'")
t.Fatal("err: 'id' does not match '54711781-274e-41b2-83c0-17194d0108f7'")
}
}

Expand Down
17 changes: 14 additions & 3 deletions cloudstack/resource_cloudstack_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,12 @@ func resourceCloudStackInstance() *schema.Resource {
Optional: true,
},

"hostid": {
"host_id": {
Type: schema.TypeString,
Optional: true,
},

"cluster_id": {
Type: schema.TypeString,
Optional: true,
},
Expand Down Expand Up @@ -333,12 +338,18 @@ func resourceCloudStackInstanceCreate(d *schema.ResourceData, meta interface{})
p.SetKeypair(keypair.(string))
}

// If a hostid is supplied, add it to the parameter struct
// If a host_id is supplied, add it to the parameter struct

if hostid, ok := d.GetOk("hostid"); ok {
if hostid, ok := d.GetOk("host_id"); ok {
p.SetHostid(hostid.(string))
}

// If a cluster_id is supplied, add it to the parameter struct

if clusterid, ok := d.GetOk("cluster_id"); ok {
p.SetClusterid(clusterid.(string))
}

if userData, ok := d.GetOk("user_data"); ok {
ud, err := getUserData(userData.(string), cs.HTTPGETOnly)
if err != nil {
Expand Down
52 changes: 52 additions & 0 deletions website/docs/r/account.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
layout: default
page_title: "CloudStack: cloudstack_account"
sidebar_current: "docs-cloudstack-resource-account"
description: |-
Creates a Account
---

# CloudStack: cloudstack_account

A `cloudstack_account` resource manages an account within CloudStack.

## Example Usage

```hcl
resource "cloudstack_account" "example" {
email = "[email protected]"
first_name = "John"
last_name = "Doe"
password = "securepassword"
username = "jdoe"
account_type = 1 # 1 for admin, 2 for domain admin, 0 for regular user
role_id = "1234abcd" # ID of the role associated with the account
}
```

## Argument Reference

The following arguments are supported:

* `email` - (Required) The email address of the account owner.
* `first_name` - (Required) The first name of the account owner.
* `last_name` - (Required) The last name of the account owner.
* `password` - (Required) The password for the account.
* `username` - (Required) The username of the account.
* `account_type` - (Required) The account type. Possible values are `0` for regular user, `1` for admin, and `2` for domain admin.
* `role_id` - (Required) The ID of the role associated with the account.
* `account` - (Optional) The account name. If not specified, the username will be used as the account name.

## Attributes Reference

The following attributes are exported:

* `id` - The ID of the account.

## Import

Accounts can be imported; use `<ACCOUNTID>` as the import ID. For example:

```shell
$ terraform import cloudstack_account.example <ACCOUNTID>
```
47 changes: 47 additions & 0 deletions website/docs/r/disk_offering.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
layout: default
page_title: "CloudStack: cloudstack_disk_offering"
sidebar_current: "docs-cloudstack-resource-disk_offering"
description: |-
Creates a Disk Offering
---

# CloudStack: cloudstack_disk_offering

A `cloudstack_disk_offering` resource manages a disk offering within CloudStack.

## Example Usage

```hcl
resource "cloudstack_disk_offering" "example" {
name = "example-disk-offering"
display_text = "Example Disk Offering"
disk_size = 100
}
```


## Argument Reference

The following arguments are supported:

* `name` - (Required) The name of the disk offering.
* `display_text` - (Required) The display text of the disk offering.
* `disk_size` - (Required) The size of the disk offering in GB.

## Attributes Reference

The following attributes are exported:

* `id` - The ID of the disk offering.
* `name` - The name of the disk offering.
* `display_text` - The display text of the disk offering.
* `disk_size` - The size of the disk offering in GB.

## Import

Disk offerings can be imported; use `<DISKOFFERINGID>` as the import ID. For example:

```shell
$ terraform import cloudstack_disk_offering.example <DISKOFFERINGID>
```
48 changes: 48 additions & 0 deletions website/docs/r/domain.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
layout: default
page_title: "CloudStack: cloudstack_domain"
sidebar_current: "docs-cloudstack-resource-domain"
description: |-
Creates a Domain
---

# CloudStack: cloudstack_domain

A `cloudstack_domain` resource manages a domain within CloudStack.

## Example Usage

```hcl
resource "cloudstack_domain" "example" {
name = "example-domain"
network_domain = "example.local"
parent_domain_id = "ROOT"
}
```


## Argument Reference

The following arguments are supported:

* `name` - (Required) The name of the domain.
* `domain_id` - (Optional) The ID of the domain.
* `network_domain` - (Optional) The network domain for the domain.
* `parent_domain_id` - (Optional) The ID of the parent domain.

## Attributes Reference

The following attributes are exported:

* `id` - The ID of the domain.
* `name` - The name of the domain.
* `network_domain` - The network domain for the domain.
* `parent_domain_id` - The ID of the parent domain.

## Import

Domains can be imported; use `<DOMAINID>` as the import ID. For example:

```shell
$ terraform import cloudstack_domain.example <DOMAINID>
```
6 changes: 6 additions & 0 deletions website/docs/r/instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ The following arguments are supported:
* `service_offering` - (Required) The name or ID of the service offering used
for this instance.

* `host_id` - (Optional) destination Host ID to deploy the VM to - parameter available
for root admin only

* `cluster_id` - (Optional) destination Cluster ID to deploy the VM to - parameter available
for root admin only

* `network_id` - (Optional) The ID of the network to connect this instance
to. Changing this forces a new resource to be created.

Expand Down
79 changes: 79 additions & 0 deletions website/docs/r/kubernetes_cluster.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
layout: default
page_title: "CloudStack: cloudstack_kubernetes_cluster"
sidebar_current: "docs-cloudstack-resource-kubernetes_cluster"
description: |-
Creates a Kubernetes Cluster
---

# CloudStack: cloudstack_kubernetes_cluster

A `cloudstack_kubernetes_cluster` resource manages a Kubernetes cluster within CloudStack.

## Example Usage

```hcl
resource "cloudstack_kubernetes_cluster" "example" {
name = "example-cluster"
zone = "zone-id"
kubernetes_version = "1.18.6"
service_offering = "small"
size = 1
autoscaling_enabled = true
min_size = 1
max_size = 5
control_nodes_size = 1
description = "An example Kubernetes cluster"
keypair = "my-ssh-key"
network_id = "net-id"
state = "Running"
project = "my-project"
}
```


## Argument Reference

The following arguments are supported:

* `name` - (Required) The name of the Kubernetes cluster.
* `zone` - (Required) The zone where the Kubernetes cluster will be deployed.
* `kubernetes_version` - (Required) The Kubernetes version for the cluster.
* `service_offering` - (Required) The service offering for the nodes in the cluster.
* `size` - (Optional) The initial size of the Kubernetes cluster. Defaults to `1`.
* `autoscaling_enabled` - (Optional) Whether autoscaling is enabled for the cluster.
* `min_size` - (Optional) The minimum size of the Kubernetes cluster when autoscaling is enabled.
* `max_size` - (Optional) The maximum size of the Kubernetes cluster when autoscaling is enabled.
* `control_nodes_size` - (Optional) The size of the control nodes in the cluster.
* `description` - (Optional) A description for the Kubernetes cluster.
* `keypair` - (Optional) The SSH key pair to use for the nodes in the cluster.
* `network_id` - (Optional) The network ID to connect the Kubernetes cluster to.
* `ip_address` - (Computed) The IP address of the Kubernetes cluster.
* `state` - (Optional) The state of the Kubernetes cluster. Defaults to `"Running"`.
* `project` - (Optional) The project to assign the Kubernetes cluster to.

## Attributes Reference

The following attributes are exported:

* `id` - The ID of the Kubernetes cluster.
* `name` - The name of the Kubernetes cluster.
* `description` - The description of the Kubernetes cluster.
* `control_nodes_size` - The size of the control nodes in the cluster.
* `size` - The size of the Kubernetes cluster.
* `autoscaling_enabled` - Whether autoscaling is enabled for the cluster.
* `min_size` - The minimum size of the Kubernetes cluster when autoscaling is enabled.
* `max_size` - The maximum size of the Kubernetes cluster when autoscaling is enabled.
* `keypair` - The SSH key pair used for the nodes in the cluster.
* `network_id` - The network ID connected to the Kubernetes cluster.
* `ip_address` - The IP address of the Kubernetes cluster.
* `state` - The state of the Kubernetes cluster.
* `project` - The project assigned to the Kubernetes cluster.

## Import

Kubernetes clusters can be imported; use `<KUBERNETESCLUSTERID>` as the import ID. For example:

```shell
$ terraform import cloudstack_kubernetes_cluster.example <KUBERNETESCLUSTERID>
```
54 changes: 54 additions & 0 deletions website/docs/r/kubernetes_version.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
layout: default
page_title: "CloudStack: cloudstack_kubernetes_version"
sidebar_current: "docs-cloudstack-resource-kubernetes_version"
description: |-
Creates a Kubernetes Version
---

# CloudStack: cloudstack_kubernetes_version

A `cloudstack_kubernetes_version` resource manages a Kubernetes version within CloudStack.

## Example Usage

```hcl
resource "cloudstack_kubernetes_version" "example" {
semantic_version = "1.19.0"
url = "https://example.com/k8s/1.19.0.tar.gz"
min_cpu = 2
min_memory = 2048
}
```

## Argument Reference

The following arguments are supported:

* `semantic_version` - (Required) The semantic version of the Kubernetes version.
* `url` - (Required) The URL to download the Kubernetes version package.
* `min_cpu` - (Required) The minimum CPU requirement for the Kubernetes version.
* `min_memory` - (Required) The minimum memory requirement for the Kubernetes version.
* `name` - (Optional) The name of the Kubernetes version.
* `zone` - (Optional) The zone in which the Kubernetes version should be added.
* `checksum` - (Optional) The checksum of the Kubernetes version package.
* `state` - (Optional) The state of the Kubernetes version. Defaults to "Enabled".

## Attributes Reference

The following attributes are exported:

* `id` - The ID of the Kubernetes version.
* `semantic_version` - The semantic version of the Kubernetes version.
* `name` - The name of the Kubernetes version.
* `min_cpu` - The minimum CPU requirement for the Kubernetes version.
* `min_memory` - The minimum memory requirement for the Kubernetes version.
* `state` - The state of the Kubernetes version.

## Import

Kubernetes versions can be imported using the ID of the resource; use `<KUBERNETESVERSIONID>` as the import ID. For example:

```shell
$ terraform import cloudstack_kubernetes_version.example <KUBERNETESVERSIONID>
```
Loading

0 comments on commit 5b3dd8a

Please sign in to comment.