├── .rat-excludes ├── .terraform-registry ├── .gitignore ├── website └── docs │ ├── d │ ├── ssh_keypair.html.markdown │ ├── volume.html.markdown │ ├── user.html.markdown │ ├── zone.html.markdown │ ├── service_offering.html.markdown │ ├── vpn_connection.html.markdown │ ├── quota_enabled.html.markdown │ ├── domain.html.markdown │ ├── network_offering.html.markdown │ ├── ipaddress.html.markdown │ ├── physicalnetwork.html.markdown │ ├── vpc.html.markdown │ ├── instance.html.markdown │ ├── role.html.markdown │ ├── project.html.markdown │ ├── template.html.markdown │ ├── counter.html.markdown │ ├── quota.html.markdown │ ├── condition.html.markdown │ ├── autoscale_policy.html.markdown │ ├── autoscale_vm_group.html.markdown │ ├── quota_tariff.html.markdown │ ├── autoscale_vm_profile.html.markdown │ └── limits.html.markdown │ ├── r │ ├── static_route.html.markdown │ ├── vpn_connection.html.markdown │ ├── counter.html.markdown │ ├── vpn_gateway.html.markdown │ ├── user.html.markdown │ ├── domain.html.markdown │ ├── secondary_storage.html.markdown │ ├── zone.html.markdown │ ├── secondary_ipaddress.html.markdown │ ├── disk_offering.html.markdown │ ├── volume.html.markdown │ ├── physical_network.html.markdown │ ├── pod.html.markdown │ ├── role.html.markdown │ ├── security_group.html.markdown │ ├── static_nat.html.markdown │ ├── ssh_keypair.html.markdown │ ├── network_acl.html.markdown │ ├── affinity_group.html.markdown │ ├── ipaddress.html.markdown │ ├── account.html.markdown │ ├── nic.html.markdown │ ├── condition.html.markdown │ ├── storage_pool.html.markdown │ ├── kubernetes_version.html.markdown │ ├── vpc.html.markdown │ ├── project.html.markdown │ ├── private_gateway.html.markdown │ ├── firewall.html.markdown │ ├── egress_firewall.html.markdown │ ├── autoscale_policy.html.markdown │ ├── traffic_type.html.markdown │ ├── autoscale_vm_profile.html.markdown │ ├── port_forward.html.markdown │ ├── loadbalancer_rule.html.markdown │ ├── vpn_customer_gateway.html.markdown │ ├── disk.html.markdown │ ├── quota_tariff.html.markdown │ ├── security_group_rule.html.markdown │ ├── cluster.html.markdown │ ├── network_service_provider_state.html.markdown │ ├── limits.html.markdown │ ├── vlan_ip_range.html.markdown │ ├── network_service_provider.html.markdown │ ├── network.html.markdown │ └── network_offering.html.markdown │ └── index.html.markdown ├── .github ├── dependabot.yml └── workflows │ ├── rat.yaml │ └── build.yml ├── scripts ├── gogetcookie.sh ├── gofmtcheck.sh ├── errcheck.sh └── changelog-links.sh ├── .asf.yaml ├── cloudstack ├── data_source_cloudstack_common_schema.go ├── config.go ├── data_source_cloudstack_pod_test.go ├── resource_cloudstack_secondary_storage_test.go ├── data_source_cloudstack_ssh_keypair_test.go ├── data_source_cloudstack_zone_test.go ├── data_source_cloudstack_role_test.go ├── data_source_cloudstack_service_offering_test.go ├── data_source_cloudstack_ipaddress_test.go ├── resource_cloudstack_cluster_test.go ├── data_source_cloudstack_user_test.go ├── data_source_cloudstack_vpc_test.go ├── resource_cloudstack_zone_test.go ├── data_source_cloudstack_instance_test.go ├── data_source_cloudstack_cluster_test.go ├── data_source_cloudstack_physical_network_test.go ├── data_source_cloudstack_volume_test.go ├── resource_cloudstack_attach_volume_test.go ├── data_source_cloudstack_quota_enabled.go ├── resource_cloudstack_pod_test.go ├── resource_cloudstack_disk_offering.go ├── data_source_cloudstack_condition.go ├── tags_test.go ├── data_source_cloudstack_counter.go ├── resource_cloudstack_domain.go ├── resource_cloudstack_user.go └── resource_cloudstack_attach_volume.go ├── .goreleaser.yml ├── main.go └── GNUmakefile /.rat-excludes: -------------------------------------------------------------------------------- 1 | CHANGELOG.md 2 | CONTRIBUTING.md 3 | go.sum 4 | rat-report.txt 5 | apache-rat-0.17 6 | .gitignore 7 | .rat-excludes 8 | .terraform-registry 9 | website 10 | -------------------------------------------------------------------------------- /.terraform-registry: -------------------------------------------------------------------------------- 1 | Request: remove version v0.5.0 from the registry 2 | Registry Link: https://registry.terraform.io/providers/cloudstack/cloudstack/latest 3 | Request by: rohit.yadav@shapeblue.com, rohit@apache.org 4 | Request number: 146118 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.dll 2 | *.exe 3 | .DS_Store 4 | example.tf 5 | terraform.tfplan 6 | terraform.tfstate 7 | bin/ 8 | modules-dev/ 9 | /pkg/ 10 | website/.vagrant 11 | website/.bundle 12 | website/build 13 | website/node_modules 14 | .vagrant/ 15 | *.backup 16 | ./*.tfstate 17 | .terraform/ 18 | *.log 19 | *.bak 20 | *~ 21 | .*.swp 22 | .idea 23 | *.iml 24 | *.test 25 | *.iml 26 | 27 | website/vendor 28 | 29 | # Test exclusions 30 | !command/test-fixtures/**/*.tfstate 31 | !command/test-fixtures/**/.terraform/ 32 | .terraform.lock.hcl 33 | provider.tf 34 | -------------------------------------------------------------------------------- /website/docs/d/ssh_keypair.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "Cloudstack: cloudstack_ssh_keypair" 4 | sidebar_current: "docs-cloudstack-cloudstack_ssh_keypair" 5 | description: |- 6 | Gets information about cloudstack ssh keypair. 7 | --- 8 | 9 | # cloudstack_ssh_keypair 10 | 11 | Use this datasource to get information about a ssh keypair for use in other resources. 12 | 13 | ### Example Usage 14 | 15 | ```hcl 16 | data "cloudstack_ssh_keypair" "ssh-keypair-data" { 17 | filter { 18 | name = "name" 19 | value = "myKey" 20 | } 21 | } 22 | ``` 23 | 24 | ### Argument Reference 25 | 26 | * `filter` - (Required) One or more name/value pairs to filter off of. You can apply filters on any exported attributes. 27 | 28 | ## Attributes Reference 29 | 30 | The following attributes are exported: 31 | 32 | * `name` - Name of the keypair. 33 | * `fingerprint` - Fingerprint of the public key. -------------------------------------------------------------------------------- /website/docs/d/volume.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "Cloudstack: cloudstack_volume" 4 | sidebar_current: "docs-cloudstack-cloudstack_volume" 5 | description: |- 6 | Gets information about cloudstack volume. 7 | --- 8 | 9 | # cloudstack_volume 10 | 11 | Use this datasource to get information about a volume for use in other resources. 12 | 13 | ### Example Usage 14 | 15 | ```hcl 16 | data "cloudstack_volume" "volume-data-source"{ 17 | filter{ 18 | name = "name" 19 | value="TestVolume" 20 | } 21 | } 22 | ``` 23 | 24 | ### Argument Reference 25 | 26 | * `filter` - (Required) One or more name/value pairs to filter off of. You can apply filters on any exported attributes. 27 | 28 | ## Attributes Reference 29 | 30 | The following attributes are exported: 31 | 32 | * `name` - Name of the disk volume. 33 | * `disk_offering_id` - ID of the disk offering. 34 | * `zone_id` - ID of the availability zone. 35 | -------------------------------------------------------------------------------- /website/docs/d/user.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "Cloudstack: cloudstack_user" 4 | sidebar_current: "docs-cloudstack-cloudstack_user" 5 | description: |- 6 | Gets information about cloudstack user. 7 | --- 8 | 9 | # cloudstack_user 10 | 11 | Use this datasource to get information about a cloudstack user for use in other resources. 12 | 13 | ### Example Usage 14 | 15 | ```hcl 16 | data "cloudstack_user" "user-data-source"{ 17 | filter{ 18 | name = "first_name" 19 | value= "jon" 20 | } 21 | } 22 | ``` 23 | 24 | ### Argument Reference 25 | 26 | * `filter` - (Required) One or more name/value pairs to filter off of. You can apply filters on any exported attributes. 27 | 28 | ## Attributes Reference 29 | 30 | The following attributes are exported: 31 | 32 | * `account` - The account name of the userg. 33 | * `email` - The user email address. 34 | * `first_name` - The user firstname. 35 | * `last_name` - The user lastname. 36 | * `username` - The user name -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | version: 2 19 | updates: 20 | - package-ecosystem: "gomod" 21 | directory: "/" 22 | schedule: 23 | interval: "monthly" 24 | -------------------------------------------------------------------------------- /website/docs/d/zone.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "Cloudstack: cloudstack_zone" 4 | sidebar_current: "docs-cloudstack-cloudstack_zone" 5 | description: |- 6 | Gets information about cloudstack zone. 7 | --- 8 | 9 | # cloudstack_zone 10 | 11 | Use this datasource to get information about a zone for use in other resources. 12 | 13 | ### Example Usage 14 | 15 | ```hcl 16 | data "cloudstack_zone" "zone-data-source"{ 17 | filter{ 18 | name = "name" 19 | value="TestZone" 20 | } 21 | } 22 | ``` 23 | 24 | ### Argument Reference 25 | 26 | * `filter` - (Required) One or more name/value pairs to filter off of. You can apply filters on any exported attributes. 27 | 28 | ## Attributes Reference 29 | 30 | The following attributes are exported: 31 | 32 | * `name` - The name of the zone. 33 | * `dns1` - The first DNS for the Zone. 34 | * `internal_dns1` - The first internal DNS for the Zone. 35 | * `network_type` - The network type of the zone; can be Basic or Advanced. -------------------------------------------------------------------------------- /website/docs/r/static_route.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_static_route" 4 | sidebar_current: "docs-cloudstack-resource-static-route" 5 | description: |- 6 | Creates a static route. 7 | --- 8 | 9 | # cloudstack_static_route 10 | 11 | Creates a static route for the given private gateway or VPC. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_static_route" "default" { 17 | cidr = "10.0.0.0/16" 18 | gateway_id = "76f607e3-e8dc-4971-8831-b2a2b0cc4cb4" 19 | } 20 | ``` 21 | 22 | ## Argument Reference 23 | 24 | The following arguments are supported: 25 | 26 | * `cidr` - (Required) The CIDR for the static route. Changing this forces 27 | a new resource to be created. 28 | 29 | * `gateway_id` - (Required) The ID of the Private gateway. Changing this forces 30 | a new resource to be created. 31 | 32 | ## Attributes Reference 33 | 34 | The following attributes are exported: 35 | 36 | * `id` - The ID of the static route. 37 | -------------------------------------------------------------------------------- /website/docs/d/service_offering.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "Cloudstack: cloudstack_service_offering" 4 | sidebar_current: "docs-cloudstack-cloudstack_service_offering" 5 | description: |- 6 | Gets information about cloudstack service offering. 7 | --- 8 | 9 | # cloudstack_service_offering 10 | 11 | Use this datasource to get information about a service offering for use in other resources. 12 | 13 | ### Example Usage 14 | 15 | ```hcl 16 | data "cloudstack_service_offering" "service-offering-data-source"{ 17 | filter{ 18 | name = "name" 19 | value = "TestServiceUpdate" 20 | } 21 | } 22 | ``` 23 | 24 | ### Argument Reference 25 | 26 | * `filter` - (Required) One or more name/value pairs to filter off of. You can apply filters on any exported attributes. 27 | 28 | ## Attributes Reference 29 | 30 | The following attributes are exported: 31 | 32 | * `name` - The name of the service offering. 33 | * `display_text` - An alternate display text of the service offering. -------------------------------------------------------------------------------- /website/docs/d/vpn_connection.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "Cloudstack: cloudstack_vpn_connection" 4 | sidebar_current: "docs-cloudstack-cloudstack_vpn_connection" 5 | description: |- 6 | Gets information about cloudstack vpn connection. 7 | --- 8 | 9 | # cloudstack_vpn_connection 10 | 11 | Use this datasource to get information about a vpn connection for use in other resources. 12 | 13 | ### Example Usage 14 | 15 | ```hcl 16 | data "cloudstack_vpc" "vpc-data-source"{ 17 | filter{ 18 | name = "name" 19 | value= "test-vpc" 20 | } 21 | filter{ 22 | name = "cidr" 23 | value= "10.0.0.0/16" 24 | } 25 | ``` 26 | 27 | ### Argument Reference 28 | 29 | * `filter` - (Required) One or more name/value pairs to filter off of. You can apply filters on any exported attributes. 30 | 31 | ## Attributes Reference 32 | 33 | The following attributes are exported: 34 | 35 | * `s2s_customer_gateway_id` - The customer gateway ID. 36 | * `s2s_vpn_gateway_id` - The vpn gateway ID. -------------------------------------------------------------------------------- /.github/workflows/rat.yaml: -------------------------------------------------------------------------------- 1 | name: RAT Check 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - '**' 10 | 11 | jobs: 12 | rat: 13 | name: Apache RAT Check 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - name: Checkout repository 18 | uses: actions/checkout@v4 19 | 20 | - name: Set up Java 21 | uses: actions/setup-java@v4 22 | with: 23 | distribution: temurin 24 | java-version: 17 25 | 26 | - name: Download Apache RAT 27 | run: | 28 | curl -L -O https://downloads.apache.org/creadur/apache-rat-0.17/apache-rat-0.17-bin.tar.gz 29 | tar -xzf apache-rat-0.17-bin.tar.gz 30 | 31 | - name: Run RAT 32 | run: | 33 | java -jar apache-rat-0.17/apache-rat-0.17.jar -d . -E .rat-excludes > rat-report.txt 34 | cat rat-report.txt 35 | # Fail if unapproved licenses are found 36 | grep -qe '^\s*Unapproved:\s*0\s*A count of unapproved licenses.$' rat-report.txt && exit 0 || exit 1 37 | -------------------------------------------------------------------------------- /website/docs/d/quota_enabled.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_quota_enabled" 4 | sidebar_current: "docs-cloudstack-datasource-quota-enabled" 5 | description: |- 6 | Checks if quota is enabled in CloudStack. 7 | --- 8 | 9 | # cloudstack_quota_enabled 10 | 11 | Use this data source to check whether the quota system is enabled in the CloudStack management server. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | # Check if quota system is enabled 17 | data "cloudstack_quota_enabled" "quota_status" { 18 | } 19 | 20 | # Use the quota status in conditional logic 21 | resource "cloudstack_quota_tariff" "cpu_tariff" { 22 | count = data.cloudstack_quota_enabled.quota_status.enabled ? 1 : 0 23 | 24 | name = "CPU Usage Tariff" 25 | usage_type = 1 26 | value = 0.05 27 | } 28 | ``` 29 | 30 | ## Argument Reference 31 | 32 | This data source takes no arguments. 33 | 34 | ## Attribute Reference 35 | 36 | The following attributes are exported: 37 | 38 | * `enabled` - A boolean value indicating whether the quota system is enabled in CloudStack. -------------------------------------------------------------------------------- /website/docs/r/vpn_connection.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_vpn_connection" 4 | sidebar_current: "docs-cloudstack-resource-vpn-connection" 5 | description: |- 6 | Creates a site to site VPN connection. 7 | --- 8 | 9 | # cloudstack_vpn_connection 10 | 11 | Creates a site to site VPN connection. 12 | 13 | ## Example Usage 14 | 15 | Basic usage: 16 | 17 | ```hcl 18 | resource "cloudstack_vpn_connection" "default" { 19 | customer_gateway_id = "8dab9381-ae73-48b8-9a3d-c460933ef5f7" 20 | vpn_gateway_id = "a7900060-f8a8-44eb-be15-ea54cf499703" 21 | } 22 | ``` 23 | 24 | ## Argument Reference 25 | 26 | The following arguments are supported: 27 | 28 | * `customer_gateway_id` - (Required) The Customer Gateway ID to connect. 29 | Changing this forces a new resource to be created. 30 | 31 | * `vpn_gateway_id` - (Required) The VPN Gateway ID to connect. Changing 32 | this forces a new resource to be created. 33 | 34 | ## Attributes Reference 35 | 36 | The following attributes are exported: 37 | 38 | * `id` - The ID of the VPN Connection. 39 | -------------------------------------------------------------------------------- /website/docs/d/domain.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | page_title: "CloudStack: cloudstack_domain Data Source" 4 | sidebar_current: "docs-cloudstack-datasource-domain" 5 | description: |- 6 | Retrieves information about a Domain 7 | --- 8 | 9 | # CloudStack: cloudstack_domain Data Source 10 | 11 | A `cloudstack_domain` data source retrieves information about a domain within CloudStack. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | data "cloudstack_domain" "my_domain" { 17 | filter { 18 | name = "name" 19 | value = "ROOT" 20 | } 21 | } 22 | ``` 23 | 24 | ## Argument Reference 25 | 26 | The following arguments are supported: 27 | 28 | * `filter` - (Required) A block to filter the domains. The filter block supports the following: 29 | * `name` - (Required) The name of the filter. 30 | * `value` - (Required) The value of the filter. 31 | 32 | ## Attributes Reference 33 | 34 | The following attributes are exported: 35 | 36 | * `id` - The ID of the domain. 37 | * `name` - The name of the domain. 38 | * `network_domain` - The network domain for the domain. 39 | * `parent_domain_id` - The ID of the parent domain. 40 | -------------------------------------------------------------------------------- /website/docs/r/counter.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_counter" 4 | sidebar_current: "docs-cloudstack-counter" 5 | description: |- 6 | Creates a counter for autoscale policies. 7 | --- 8 | 9 | # cloudstack_counter 10 | 11 | Creates a counter that can be used in autoscale conditions to monitor performance metrics. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_counter" "cpu_counter" { 17 | name = "cpu-counter" 18 | source = "cpu" 19 | value = "cpuused" 20 | } 21 | 22 | resource "cloudstack_counter" "memory_counter" { 23 | name = "memory-counter" 24 | source = "memory" 25 | value = "memoryused" 26 | } 27 | ``` 28 | 29 | ## Argument Reference 30 | 31 | The following arguments are supported: 32 | 33 | * `name` - (Required) The name of the counter. 34 | 35 | * `source` - (Required) The source of the counter (e.g., "cpu", "memory", "network"). 36 | 37 | * `value` - (Required) The specific metric value to monitor (e.g., "cpuused", "memoryused"). 38 | 39 | ## Attributes Reference 40 | 41 | The following attributes are exported: 42 | 43 | * `id` - The counter ID. 44 | -------------------------------------------------------------------------------- /scripts/gogetcookie.sh: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | #!/bin/bash 21 | 22 | touch ~/.gitcookies 23 | chmod 0600 ~/.gitcookies 24 | 25 | git config --global http.cookiefile ~/.gitcookies 26 | 27 | tr , \\t <<\__END__ >>~/.gitcookies 28 | .googlesource.com,TRUE,/,TRUE,2147483647,o,git-paul.hashicorp.com=1/z7s05EYPudQ9qoe6dMVfmAVwgZopEkZBb1a2mA5QtHE 29 | __END__ 30 | -------------------------------------------------------------------------------- /website/docs/r/vpn_gateway.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_vpn_gateway" 4 | sidebar_current: "docs-cloudstack-resource-vpn-gateway" 5 | description: |- 6 | Creates a site to site VPN local gateway. 7 | --- 8 | 9 | # cloudstack_vpn_gateway 10 | 11 | Creates a site to site VPN local gateway. 12 | 13 | ## Example Usage 14 | 15 | Basic usage: 16 | 17 | ```hcl 18 | resource "cloudstack_vpn_gateway" "default" { 19 | vpc_id = "f8141e2f-4e7e-4c63-9362-986c908b7ea7" 20 | } 21 | ``` 22 | 23 | ## Argument Reference 24 | 25 | The following arguments are supported: 26 | 27 | * `vpc_id` - (Required) The ID of the VPC for which to create the VPN Gateway. 28 | Changing this forces a new resource to be created. 29 | 30 | ## Attributes Reference 31 | 32 | The following attributes are exported: 33 | 34 | * `id` - The ID of the VPN Gateway. 35 | * `public_ip` - The public IP address associated with the VPN Gateway. 36 | 37 | ## Import 38 | 39 | VPC gateways can be imported; use `` as the import ID. For 40 | example: 41 | 42 | ```shell 43 | terraform import cloudstack_vpn_gateway.default 49cf1821-3b9f-4627-be19-8a15ffec508d 44 | ``` 45 | -------------------------------------------------------------------------------- /website/docs/d/network_offering.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "Cloudstack: cloudstack_network_offerings" 4 | sidebar_current: "docs-cloudstack-cloudstack_network_offering" 5 | description: |- 6 | Gets information about cloudstack network offering. 7 | --- 8 | 9 | # cloudstack_network_offering 10 | 11 | Use this datasource to get information about a network offering for use in other resources. 12 | 13 | ### Example Usage 14 | 15 | ```hcl 16 | data "cloudstack_network_offering" "net-off-data-source"{ 17 | filter{ 18 | name = "name" 19 | value="TestNetworkDisplay12" 20 | } 21 | } 22 | ``` 23 | 24 | ### Argument Reference 25 | 26 | * `filter` - (Required) One or more name/value pairs to filter off of. You can apply filters on any exported attributes. 27 | 28 | ## Attributes Reference 29 | 30 | The following attributes are exported: 31 | 32 | * `name` - The name of the network offering. 33 | * `display_text` - An alternate display text of the network offering. 34 | * `guest_ip_type` - Guest type of the network offering, can be Shared or Isolated. 35 | * `traffic_type` - The traffic type for the network offering, supported types are Public, Management, Control, Guest, Vlan or Storage. -------------------------------------------------------------------------------- /website/docs/d/ipaddress.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "Cloudstack: cloudstack_ipaddress" 4 | sidebar_current: "docs-cloudstack-cloudstack_ipaddress" 5 | description: |- 6 | Gets information about cloudstack ipaddress. 7 | --- 8 | 9 | # cloudstack_ipaddress 10 | 11 | Use this datasource to get information about a public ipaddress for use in other resources. 12 | 13 | ### Example Usage 14 | 15 | ```hcl 16 | data "cloudstack_ipaddress" "ipaddress-data-source"{ 17 | filter{ 18 | name = "zone_name" 19 | value= "DC" 20 | } 21 | } 22 | ``` 23 | 24 | ### Argument Reference 25 | 26 | * `filter` - (Required) One or more name/value pairs to filter off of. You can apply filters on any exported attributes. 27 | 28 | ## Attributes Reference 29 | 30 | The following attributes are exported: 31 | 32 | * `is_portable` - Is public IP portable across the zones. 33 | * `network_id` - The ID of the Network where ip belongs to. 34 | * `vpc_id` - VPC id the ip belongs to. 35 | * `zone_name` - The name of the zone the public IP address belongs to. 36 | * `project` - The project name of the address. 37 | * `ip_address` - Public IP address. 38 | * `is_source_nat` - True if the IP address is a source nat address, false otherwise. 39 | -------------------------------------------------------------------------------- /website/docs/d/physicalnetwork.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_physicalnetwork" 4 | sidebar_current: "docs-cloudstack-datasource-physicalnetwork" 5 | description: |- 6 | Gets information about a physical network. 7 | --- 8 | 9 | # cloudstack_physicalnetwork 10 | 11 | Use this data source to get information about a physical network. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | data "cloudstack_physicalnetwork" "default" { 17 | filter { 18 | name = "name" 19 | value = "test-physical-network" 20 | } 21 | } 22 | ``` 23 | 24 | ## Argument Reference 25 | 26 | The following arguments are supported: 27 | 28 | * `filter` - (Optional) One or more name/value pairs to filter off of. 29 | 30 | ## Attributes Reference 31 | 32 | The following attributes are exported: 33 | 34 | * `id` - The ID of the physical network. 35 | * `name` - The name of the physical network. 36 | * `zone` - The name of the zone where the physical network belongs to. 37 | * `broadcast_domain_range` - The broadcast domain range for the physical network. 38 | * `isolation_methods` - The isolation method for the physical network. 39 | * `network_speed` - The speed for the physical network. 40 | * `vlan` - The VLAN for the physical network. -------------------------------------------------------------------------------- /scripts/gofmtcheck.sh: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | #!/usr/bin/env bash 21 | 22 | # Check gofmt 23 | echo "==> Checking that code complies with gofmt requirements..." 24 | gofmt_files=$(gofmt -l `find . -name '*.go' | grep -v vendor`) 25 | if [[ -n ${gofmt_files} ]]; then 26 | echo 'gofmt needs running on the following files:' 27 | echo "${gofmt_files}" 28 | echo "You can use the command: \`make fmt\` to reformat code." 29 | exit 1 30 | fi 31 | 32 | exit 0 33 | -------------------------------------------------------------------------------- /website/docs/r/user.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: "CloudStack: cloudstack_user" 4 | sidebar_current: "docs-cloudstack-resource-user" 5 | description: |- 6 | Creates a User 7 | --- 8 | 9 | # CloudStack: cloudstack_user 10 | 11 | A `cloudstack_user` resource manages a user within CloudStack. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_user" "example" { 17 | account = "example-account" 18 | email = "user@example.com" 19 | first_name = "John" 20 | last_name = "Doe" 21 | password = "securepassword" 22 | username = "jdoe" 23 | } 24 | ``` 25 | 26 | 27 | ## Argument Reference 28 | 29 | The following arguments are supported: 30 | 31 | * `account` - (Optional) The account the user belongs to. 32 | * `email` - (Required) The email address of the user. 33 | * `first_name` - (Required) The first name of the user. 34 | * `last_name` - (Required) The last name of the user. 35 | * `password` - (Required) The password for the user. 36 | * `username` - (Required) The username of the user. 37 | 38 | ## Attributes Reference 39 | 40 | No attributes are exported. 41 | 42 | ## Import 43 | 44 | Users can be imported; use `` as the import ID. For example: 45 | 46 | ```shell 47 | $ terraform import cloudstack_user.example 48 | ``` 49 | -------------------------------------------------------------------------------- /website/docs/d/vpc.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "Cloudstack: cloudstack_vpc" 4 | sidebar_current: "docs-cloudstack-cloudstack_vpc" 5 | description: |- 6 | Gets information about cloudstack vpc. 7 | --- 8 | 9 | # cloudstack_vpc 10 | 11 | Use this datasource to get information about a vpc for use in other resources. 12 | 13 | ### Example Usage 14 | 15 | ```hcl 16 | data "cloudstack_vpc" "vpc-data-source"{ 17 | project = "project-1" 18 | filter{ 19 | name = "name" 20 | value= "test-vpc" 21 | } 22 | filter{ 23 | name = "cidr" 24 | value= "10.0.0.0/16" 25 | } 26 | ``` 27 | 28 | ### Argument Reference 29 | 30 | * `filter` - (Required) One or more name/value pairs to filter off of. You can apply filters on any exported attributes. 31 | * `project` - (Optional) The name or ID of the project the vpc belongs to. 32 | 33 | ## Attributes Reference 34 | 35 | The following attributes are exported: 36 | 37 | * `name` - The name of the VPC. 38 | * `display_text` - An alternate display text of the VPC. 39 | * `cidr` - The cidr the VPC. 40 | * `vpc_offering_name` - Vpc offering name the VPC is created from. 41 | * `network_domain` - The network domain of the VPC. 42 | * `project` - The project name of the VPC. 43 | * `zone_name` - The name of the zone the VPC belongs to. 44 | -------------------------------------------------------------------------------- /website/docs/r/domain.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | page_title: "CloudStack: cloudstack_domain" 4 | sidebar_current: "docs-cloudstack-resource-domain" 5 | description: |- 6 | Creates a Domain 7 | --- 8 | 9 | # CloudStack: cloudstack_domain 10 | 11 | A `cloudstack_domain` resource manages a domain within CloudStack. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_domain" "example" { 17 | name = "example-domain" 18 | network_domain = "example.local" 19 | parent_domain_id = "ROOT" 20 | } 21 | ``` 22 | 23 | 24 | ## Argument Reference 25 | 26 | The following arguments are supported: 27 | 28 | * `name` - (Required) The name of the domain. 29 | * `domain_id` - (Optional) The ID of the domain. 30 | * `network_domain` - (Optional) The network domain for the domain. 31 | * `parent_domain_id` - (Optional) The ID of the parent domain. 32 | 33 | ## Attributes Reference 34 | 35 | The following attributes are exported: 36 | 37 | * `id` - The ID of the domain. 38 | * `name` - The name of the domain. 39 | * `network_domain` - The network domain for the domain. 40 | * `parent_domain_id` - The ID of the parent domain. 41 | 42 | ## Import 43 | 44 | Domains can be imported; use `` as the import ID. For example: 45 | 46 | ```shell 47 | $ terraform import cloudstack_domain.example 48 | ``` 49 | -------------------------------------------------------------------------------- /website/docs/r/secondary_storage.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_secondary_storage" 4 | sidebar_current: "docs-cloudstack-resource-secondary-storage" 5 | description: |- 6 | Creates a changeme. 7 | --- 8 | 9 | # cloudstack_secondary_storage 10 | 11 | Create secondary storage 12 | 13 | ## Example Usage 14 | 15 | Basic usage: 16 | 17 | ```hcl 18 | resource "cloudstack_secondary_storage" "example" { 19 | name = "example" 20 | storage_provider = "NFS" 21 | url = "nfs://10.147.28.6:/export/home/sandbox/secondary" 22 | zone_id = data.cloudstack_zone.example.id 23 | } 24 | ``` 25 | 26 | ## Argument Reference 27 | 28 | The following arguments are supported: 29 | 30 | * `name` - (Optional) the name for the image store. 31 | * `storage_provider` - (Required) the image store provider name. 32 | * `url` - (Optional) the URL for the image store. 33 | * `zone_id` - (Optional) the Zone ID for the image store. 34 | 35 | 36 | ## Attributes Reference 37 | 38 | The following attributes are exported: 39 | 40 | * `id` - The instance ID. 41 | 42 | 43 | 44 | ## Import 45 | 46 | changeme can be imported; use `` as the import ID. For 47 | example: 48 | 49 | ```shell 50 | terraform import cloudstack_secondary_storage.example 5cf69677-7e4b-4bf4-b868-f0b02bb72ee0 51 | ``` 52 | -------------------------------------------------------------------------------- /website/docs/r/zone.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | page_title: "CloudStack: cloudstack_zone" 4 | sidebar_current: "docs-cloudstack-resource-zone" 5 | description: |- 6 | Creates a Zone 7 | --- 8 | 9 | # CloudStack: cloudstack_zone 10 | 11 | A `cloudstack_zone` resource manages a zone within CloudStack. 12 | 13 | ## Example Usage 14 | ```hcl 15 | resource "cloudstack_zone" "example" { 16 | name = "example-zone" 17 | dns1 = "8.8.8.8" 18 | internal_dns1 = "8.8.4.4" 19 | network_type = "Basic" 20 | } 21 | ``` 22 | ## Argument Reference 23 | 24 | The following arguments are supported: 25 | 26 | * `name` - (Required) The name of the zone. 27 | * `dns1` - (Required) The DNS server 1 for the zone. 28 | * `internal_dns1` - (Required) The internal DNS server 1 for the zone. 29 | * `network_type` - (Required) The type of network to use for the zone. 30 | 31 | ## Attributes Reference 32 | 33 | The following attributes are exported: 34 | 35 | * `id` - The ID of the zone. 36 | * `name` - The name of the zone. 37 | * `dns1` - The DNS server 1 for the zone. 38 | * `internal_dns1` - The internal DNS server 1 for the zone. 39 | * `network_type` - The type of network to use for the zone. 40 | 41 | ## Import 42 | 43 | Zones can be imported; use `` as the import ID. For example: 44 | ```shell 45 | $ terraform import cloudstack_zone.example 46 | ``` 47 | -------------------------------------------------------------------------------- /.asf.yaml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | github: 19 | description: "CloudStack Terraform Provider" 20 | homepage: https://cloudstack.apache.org 21 | labels: 22 | - terraform 23 | - cloudstack 24 | - go 25 | features: 26 | wiki: true 27 | issues: true 28 | projects: true 29 | 30 | protected_branches: 31 | main: 32 | required_status_checks: 33 | contexts: 34 | - build 35 | - all-jobs-passed 36 | 37 | collaborators: 38 | - kiranchavala 39 | - vishesh92 40 | - fabiomatavelli 41 | - CodeBleu 42 | -------------------------------------------------------------------------------- /website/docs/r/secondary_ipaddress.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_secondary_ipaddress" 4 | sidebar_current: "docs-cloudstack-resource-secondary-ipaddress" 5 | description: |- 6 | Assigns a secondary IP to a NIC. 7 | --- 8 | 9 | # cloudstack_secondary_ipaddress 10 | 11 | Assigns a secondary IP to a NIC. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_secondary_ipaddress" "default" { 17 | virtual_machine_id = "server-1" 18 | } 19 | ``` 20 | 21 | ## Argument Reference 22 | 23 | The following arguments are supported: 24 | 25 | * `ip_address` - (Optional) The IP address to bind the to NIC. If not supplied 26 | an IP address will be selected randomly. Changing this forces a new resource 27 | to be created. 28 | 29 | * `nic_id` - (Optional) The NIC ID to which you want to attach the secondary IP 30 | address. Changing this forces a new resource to be created (defaults to the 31 | ID of the primary NIC) 32 | 33 | * `virtual_machine_id` - (Required) The ID of the virtual machine to which you 34 | want to attach the secondary IP address. Changing this forces a new resource 35 | to be created. 36 | 37 | ## Attributes Reference 38 | 39 | The following attributes are exported: 40 | 41 | * `id` - The secondary IP address ID. 42 | * `ip_address` - The IP address that was acquired and associated. 43 | -------------------------------------------------------------------------------- /website/docs/r/disk_offering.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | page_title: "CloudStack: cloudstack_disk_offering" 4 | sidebar_current: "docs-cloudstack-resource-disk_offering" 5 | description: |- 6 | Creates a Disk Offering 7 | --- 8 | 9 | # CloudStack: cloudstack_disk_offering 10 | 11 | A `cloudstack_disk_offering` resource manages a disk offering within CloudStack. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_disk_offering" "example" { 17 | name = "example-disk-offering" 18 | display_text = "Example Disk Offering" 19 | disk_size = 100 20 | } 21 | ``` 22 | 23 | 24 | ## Argument Reference 25 | 26 | The following arguments are supported: 27 | 28 | * `name` - (Required) The name of the disk offering. 29 | * `display_text` - (Required) The display text of the disk offering. 30 | * `disk_size` - (Required) The size of the disk offering in GB. 31 | 32 | ## Attributes Reference 33 | 34 | The following attributes are exported: 35 | 36 | * `id` - The ID of the disk offering. 37 | * `name` - The name of the disk offering. 38 | * `display_text` - The display text of the disk offering. 39 | * `disk_size` - The size of the disk offering in GB. 40 | 41 | ## Import 42 | 43 | Disk offerings can be imported; use `` as the import ID. For example: 44 | 45 | ```shell 46 | $ terraform import cloudstack_disk_offering.example 47 | ``` 48 | -------------------------------------------------------------------------------- /website/docs/d/instance.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "Cloudstack: cloudstack_instance" 4 | sidebar_current: "docs-cloudstack-datasource-instance" 5 | description: |- 6 | Gets information about cloudstack instance. 7 | --- 8 | 9 | # cloudstack_instance 10 | 11 | Use this datasource to get information about an instance for use in other resources. 12 | 13 | ### Example Usage 14 | 15 | ```hcl 16 | data "cloudstack_instance" "my_instance" { 17 | filter { 18 | name = "name" 19 | value = "server-a" 20 | } 21 | 22 | nic { 23 | ip_address="10.1.1.37" 24 | } 25 | } 26 | ``` 27 | 28 | ### Argument Reference 29 | 30 | * `filter` - (Required) One or more name/value pairs to filter off of. You can apply filters on any exported attributes. 31 | 32 | ## Attributes Reference 33 | 34 | The following attributes are exported: 35 | 36 | * `instance_id` - The ID of the virtual machine. 37 | * `account` - The account associated with the virtual machine. 38 | * `display_name` - The user generated name. The name of the virtual machine is returned if no displayname exists. 39 | * `state` - The state of the virtual machine. 40 | * `host_id` - The ID of the host for the virtual machine. 41 | * `zone_id` - The ID of the availability zone for the virtual machine. 42 | * `created` - The date when this virtual machine was created. 43 | * `nic` - The list of nics associated with vm. 44 | -------------------------------------------------------------------------------- /website/docs/d/role.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_role" 4 | description: |- 5 | Gets information about a role. 6 | --- 7 | 8 | # cloudstack_role 9 | 10 | Use this data source to get information about a role for use in other resources. 11 | 12 | ## Example Usage 13 | 14 | ```hcl 15 | data "cloudstack_role" "admin" { 16 | filter { 17 | name = "name" 18 | value = "Admin" 19 | } 20 | } 21 | 22 | resource "cloudstack_account" "example" { 23 | email = "example@example.com" 24 | first_name = "John" 25 | last_name = "Doe" 26 | password = "password" 27 | username = "johndoe" 28 | account_type = 1 29 | role_id = data.cloudstack_role.admin.id 30 | } 31 | ``` 32 | 33 | ## Argument Reference 34 | 35 | The following arguments are supported: 36 | 37 | * `filter` - (Required) One or more name/value pairs to filter off of. See the example below for usage. 38 | 39 | ## Filter Example 40 | 41 | ```hcl 42 | data "cloudstack_role" "admin" { 43 | filter { 44 | name = "name" 45 | value = "Admin" 46 | } 47 | } 48 | ``` 49 | 50 | ## Attributes Reference 51 | 52 | The following attributes are exported: 53 | 54 | * `id` - The ID of the role. 55 | * `name` - The name of the role. 56 | * `type` - The type of the role. 57 | * `description` - The description of the role. 58 | * `is_public` - Whether the role is public or not. 59 | -------------------------------------------------------------------------------- /website/docs/r/volume.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | page_title: "CloudStack: cloudstack_volume" 4 | sidebar_current: "docs-cloudstack-resource-volume" 5 | description: |- 6 | Creates a Volume 7 | --- 8 | # CloudStack: cloudstack_volume 9 | 10 | A `cloudstack_volume` resource manages a volume within CloudStack. 11 | 12 | ## Example Usage 13 | 14 | ```hcl 15 | resource "cloudstack_volume" "example" { 16 | name = "example-volume" 17 | disk_offering_id = "a6f7e5fb-1b9a-417e-a46e-7e3d715f34d3" 18 | zone_id = "b0fcd7cc-5e14-499d-a2ff-ecf49840f1ab" 19 | } 20 | ``` 21 | 22 | ## Argument Reference 23 | 24 | The following arguments are supported: 25 | 26 | * `name` - (Required) The name of the volume. Forces new resource. 27 | * `disk_offering_id` - (Required) The ID of the disk offering for the volume. Forces new resource. 28 | * `zone_id` - (Required) The ID of the zone where the volume will be created. Forces new resource. 29 | 30 | ## Attributes Reference 31 | 32 | The following attributes are exported: 33 | 34 | * `id` - The ID of the volume. 35 | * `name` - The name of the volume. 36 | * `disk_offering_id` - The ID of the disk offering for the volume. 37 | * `zone_id` - The ID of the zone where the volume resides. 38 | 39 | ## Import 40 | 41 | Volumes can be imported; use `` as the import ID. For example: 42 | 43 | ```shell 44 | $ terraform import cloudstack_volume.example 45 | ``` 46 | -------------------------------------------------------------------------------- /website/docs/r/physical_network.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: physical_network" 4 | sidebar_current: "docs-cloudstack-resource-physical-network" 5 | description: |- 6 | Creates a physical network 7 | --- 8 | 9 | # physical_network 10 | 11 | Creates a physical network 12 | 13 | ## Example Usage 14 | 15 | Basic usage: 16 | 17 | ```hcl 18 | resource "cloudstack_physical_network" "example" { 19 | broadcast_domain_range = "ZONE" 20 | isolation_methods = "VLAN" 21 | name = "example" 22 | network_speed = "10G" 23 | tags = "vlan" 24 | zone_id = cloudstack_zone.example.id 25 | } 26 | ``` 27 | 28 | ## Argument Reference 29 | 30 | The following arguments are supported: 31 | 32 | * `broadcast_domain_range` - (Optional) changeme. 33 | * `domain_id` - (Optional) changeme. 34 | * `isolation_methods` - (Optional) changeme. 35 | * `name` - (Required) changeme. 36 | * `network_speed` - (Optional) changeme. 37 | * `tags` - (Optional) changeme. 38 | * `vlan` - (Optional) changeme. 39 | * `zone_id` - (Required) changeme. 40 | 41 | 42 | ## Attributes Reference 43 | 44 | The following attributes are exported: 45 | 46 | * `id` - The instance ID. 47 | 48 | 49 | ## Import 50 | 51 | Physical networks can be imported; use `` as the import ID. For 52 | example: 53 | 54 | ```shell 55 | terraform import physical_network.example 5cf69677-7e4b-4bf4-b868-f0b02bb72ee0 56 | ``` 57 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | name: Build-Check 19 | 20 | on: [push, pull_request] 21 | 22 | concurrency: 23 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} 24 | cancel-in-progress: true 25 | permissions: 26 | contents: read 27 | 28 | jobs: 29 | build: 30 | runs-on: ubuntu-22.04 31 | 32 | steps: 33 | - uses: actions/checkout@v3 34 | 35 | - name: Set up Go 36 | uses: actions/setup-go@v3 37 | with: 38 | go-version-file: 'go.mod' 39 | 40 | - name: Build 41 | run: | 42 | make build 43 | 44 | - name: Test 45 | run: make test 46 | -------------------------------------------------------------------------------- /cloudstack/data_source_cloudstack_common_schema.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 24 | ) 25 | 26 | func dataSourceFiltersSchema() *schema.Schema { 27 | return &schema.Schema{ 28 | Type: schema.TypeSet, 29 | Required: true, 30 | ForceNew: true, 31 | Elem: &schema.Resource{ 32 | Schema: map[string]*schema.Schema{ 33 | "name": { 34 | Type: schema.TypeString, 35 | Required: true, 36 | }, 37 | "value": { 38 | Type: schema.TypeString, 39 | Required: true, 40 | }, 41 | }, 42 | }, 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /website/docs/r/pod.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_pod" 4 | sidebar_current: "docs-cloudstack-resource-pod" 5 | description: |- 6 | Creates a new Pod. 7 | --- 8 | 9 | # cloudstack_pod 10 | 11 | Creates a new Pod. 12 | 13 | ## Example Usage 14 | 15 | Basic usage: 16 | 17 | ```hcl 18 | resource "cloudstack_pod" "example" { 19 | allocation_state = "Disabled" 20 | gateway = "172.29.0.1" 21 | name = "example" 22 | netmask = "255.255.240.0" 23 | start_ip = "172.29.0.2" 24 | zone_id = cloudstack_zone.example.id 25 | } 26 | ``` 27 | 28 | ## Argument Reference 29 | 30 | The following arguments are supported: 31 | 32 | * `allocation_state` - (Optional) allocation state of this Pod for allocation of new resources. 33 | * `end_ip` - (Optional) the ending IP address for the Pod. 34 | * `gateway` - (Required) the gateway for the Pod. 35 | * `name` - (Required) the name of the Pod. 36 | * `netmask` - (Required) the netmask for the Pod. 37 | * `start_ip` - (Required) the starting IP address for the Pod. 38 | * `zone_id` - (Required) the Zone ID in which the Pod will be created. 39 | 40 | 41 | ## Attributes Reference 42 | 43 | The following attributes are exported: 44 | 45 | * `id` - The instance ID. 46 | 47 | 48 | 49 | ## Import 50 | 51 | A pod can be imported; use `` as the import ID. For 52 | example: 53 | 54 | ```shell 55 | terraform import cloudstack_pod.example 5cf69677-7e4b-4bf4-b868-f0b02bb72ee0 56 | ``` 57 | -------------------------------------------------------------------------------- /website/docs/d/project.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_project" 4 | sidebar_current: "docs-cloudstack-cloudstack_project" 5 | description: |- 6 | Gets information about CloudStack projects. 7 | --- 8 | 9 | # cloudstack_project 10 | 11 | Use this datasource to get information about a CloudStack project for use in other resources. 12 | 13 | ## Example Usage 14 | 15 | ### Basic Usage 16 | 17 | ```hcl 18 | data "cloudstack_project" "my_project" { 19 | filter { 20 | name = "name" 21 | value = "my-project" 22 | } 23 | } 24 | ``` 25 | 26 | ### With Multiple Filters 27 | 28 | ```hcl 29 | data "cloudstack_project" "admin_project" { 30 | filter { 31 | name = "name" 32 | value = "admin-project" 33 | } 34 | filter { 35 | name = "domain" 36 | value = "ROOT" 37 | } 38 | filter { 39 | name = "account" 40 | value = "admin" 41 | } 42 | } 43 | ``` 44 | 45 | ## Argument Reference 46 | 47 | * `filter` - (Required) One or more name/value pairs to filter off of. You can apply filters on any exported attributes. 48 | 49 | ## Attributes Reference 50 | 51 | The following attributes are exported: 52 | 53 | * `id` - The ID of the project. 54 | * `name` - The name of the project. 55 | * `display_text` - The display text of the project. 56 | * `domain` - The domain where the project belongs. 57 | * `account` - The account who is the admin for the project. 58 | * `state` - The current state of the project. 59 | * `tags` - A map of tags assigned to the project. -------------------------------------------------------------------------------- /cloudstack/config.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import "github.com/apache/cloudstack-go/v2/cloudstack" 23 | 24 | // Config is the configuration structure used to instantiate a 25 | // new CloudStack client. 26 | type Config struct { 27 | APIURL string 28 | APIKey string 29 | SecretKey string 30 | HTTPGETOnly bool 31 | Timeout int64 32 | } 33 | 34 | // NewClient returns a new CloudStack client. 35 | func (c *Config) NewClient() (*cloudstack.CloudStackClient, error) { 36 | cs := cloudstack.NewAsyncClient(c.APIURL, c.APIKey, c.SecretKey, false) 37 | cs.HTTPGETOnly = c.HTTPGETOnly 38 | cs.AsyncTimeout(c.Timeout) 39 | return cs, nil 40 | } 41 | -------------------------------------------------------------------------------- /website/docs/d/template.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "Cloudstack: cloudstack_template" 4 | sidebar_current: "docs-cloudstack-datasource-template" 5 | description: |- 6 | Gets information about Cloudstack template. 7 | --- 8 | 9 | # cloudstack_template 10 | 11 | Use this datasource to get the ID of a template for use in other resources. 12 | 13 | ### Example Usage 14 | 15 | ```hcl 16 | data "cloudstack_template" "my_template" { 17 | template_filter = "featured" 18 | 19 | filter { 20 | name = "name" 21 | value = "CentOS 7\\.1" 22 | } 23 | 24 | filter { 25 | name = "hypervisor" 26 | value = "KVM" 27 | } 28 | } 29 | ``` 30 | 31 | ### Argument Reference 32 | 33 | * `template_filter` - (Required) The template filter. Possible values are `featured`, `self`, `selfexecutable`, `sharedexecutable`, `executable` and `community` (see the Cloudstack API *listTemplate* command documentation). 34 | 35 | * `filter` - (Required) One or more name/value pairs to filter off of. You can apply filters on any exported attributes. 36 | 37 | ## Attributes Reference 38 | 39 | The following attributes are exported: 40 | 41 | * `id` - The template ID. 42 | * `account` - The account name to which the template belongs. 43 | * `created` - The date this template was created. 44 | * `display_text` - The template display text. 45 | * `format` - The format of the template. 46 | * `hypervisor` - The hypervisor on which the templates runs. 47 | * `name` - The template name. 48 | * `size` - The size of the template. 49 | -------------------------------------------------------------------------------- /website/docs/d/counter.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_counter" 4 | sidebar_current: "docs-cloudstack-data-source-counter" 5 | description: |- 6 | Gets information about a CloudStack counter. 7 | --- 8 | 9 | # cloudstack_counter 10 | 11 | Use this data source to get information about a CloudStack counter for use in autoscale conditions. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | # Get counter by ID 17 | data "cloudstack_counter" "cpu_counter" { 18 | id = "959e11c0-8416-11f0-9a72-1e001b000238" 19 | } 20 | 21 | # Get counter by name 22 | data "cloudstack_counter" "memory_counter" { 23 | filter { 24 | name = "name" 25 | value = "VM CPU - average percentage" 26 | } 27 | } 28 | 29 | # Use in a condition 30 | resource "cloudstack_condition" "scale_up" { 31 | counter_id = data.cloudstack_counter.cpu_counter.id 32 | relational_operator = "GT" 33 | threshold = 80.0 34 | account_name = "admin" 35 | domain_id = "1" 36 | } 37 | ``` 38 | 39 | ## Argument Reference 40 | 41 | The following arguments are supported: 42 | 43 | * `id` - (Optional) The ID of the counter. 44 | 45 | * `filter` - (Optional) One or more name/value pairs to filter off of. You can apply filters on any exported attributes. 46 | 47 | ## Attributes Reference 48 | 49 | The following attributes are exported: 50 | 51 | * `id` - The counter ID. 52 | 53 | * `name` - The name of the counter. 54 | 55 | * `source` - The source of the counter. 56 | 57 | * `value` - The metric value monitored by the counter. 58 | -------------------------------------------------------------------------------- /website/docs/r/role.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_role" 4 | description: |- 5 | Creates a role. 6 | --- 7 | 8 | # cloudstack_role 9 | 10 | Creates a role. 11 | 12 | ## Example Usage 13 | 14 | ```hcl 15 | # Create a role with a specific type 16 | resource "cloudstack_role" "admin" { 17 | name = "Admin" 18 | type = "Admin" 19 | description = "Administrator role" 20 | is_public = true 21 | } 22 | 23 | # Create a role by cloning an existing role 24 | resource "cloudstack_role" "custom_admin" { 25 | name = "CustomAdmin" 26 | role_id = "12345678-1234-1234-1234-123456789012" 27 | description = "Custom administrator role cloned from an existing role" 28 | is_public = false 29 | } 30 | ``` 31 | 32 | ## Argument Reference 33 | 34 | The following arguments are supported: 35 | 36 | * `name` - (Required) The name of the role. 37 | * `type` - (Optional) The type of the role. Valid options are: Admin, ResourceAdmin, DomainAdmin, User. Either `type` or `role_id` must be specified. 38 | * `description` - (Optional) The description of the role. 39 | * `is_public` - (Optional) Whether the role is public or not. Defaults to `true`. 40 | * `role_id` - (Optional) ID of the role to be cloned from. Either `role_id` or `type` must be specified. 41 | 42 | ## Attributes Reference 43 | 44 | The following attributes are exported: 45 | 46 | * `id` - The ID of the role. 47 | 48 | ## Import 49 | 50 | Roles can be imported using the role ID, e.g. 51 | 52 | ``` 53 | terraform import cloudstack_role.admin 12345678-1234-1234-1234-123456789012 54 | -------------------------------------------------------------------------------- /website/docs/r/security_group.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_security_group" 4 | sidebar_current: "docs-cloudstack-resource-security-group" 5 | description: |- 6 | Creates a security group. 7 | --- 8 | 9 | # cloudstack_security_group 10 | 11 | Creates a security group. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_security_group" "default" { 17 | name = "allow_web" 18 | description = "Allow access to HTTP and HTTPS" 19 | } 20 | ``` 21 | 22 | ## Argument Reference 23 | 24 | The following arguments are supported: 25 | 26 | * `name` - (Required) The name of the security group. Changing this forces a 27 | new resource to be created. 28 | 29 | * `description` - (Optional) The description of the security group. Changing 30 | this forces a new resource to be created. 31 | 32 | * `project` - (Optional) The name or ID of the project to create this security 33 | group in. Changing this forces a new resource to be created. 34 | 35 | ## Attributes Reference 36 | 37 | The following attributes are exported: 38 | 39 | * `id` - The ID of the security group. 40 | 41 | ## Import 42 | 43 | Security groups can be imported; use `` as the import ID. For 44 | example: 45 | 46 | ```shell 47 | terraform import cloudstack_security_group.default e54970f1-f563-46dd-a365-2b2e9b78c54b 48 | ``` 49 | 50 | When importing into a project you need to prefix the import ID with the project name: 51 | 52 | ```shell 53 | terraform import cloudstack_security_group.default my-project/e54970f1-f563-46dd-a365-2b2e9b78c54b 54 | ``` 55 | -------------------------------------------------------------------------------- /website/docs/r/static_nat.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_static_nat" 4 | sidebar_current: "docs-cloudstack-resource-static-nat" 5 | description: |- 6 | Enables static NAT for a given IP address. 7 | --- 8 | 9 | # cloudstack_static_nat 10 | 11 | Enables static NAT for a given IP address 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_static_nat" "default" { 17 | ip_address_id = "f8141e2f-4e7e-4c63-9362-986c908b7ea7" 18 | virtual_machine_id = "6ca2a163-bc68-429c-adc8-ab4a620b1bb3" 19 | } 20 | ``` 21 | 22 | ## Argument Reference 23 | 24 | The following arguments are supported: 25 | 26 | * `ip_address_id` - (Required) The public IP address ID for which static 27 | NAT will be enabled. Changing this forces a new resource to be created. 28 | 29 | * `virtual_machine_id` - (Required) The virtual machine ID to enable the 30 | static NAT feature for. Changing this forces a new resource to be created. 31 | 32 | * `vm_guest_ip` - (Optional) The virtual machine IP address to forward the 33 | static NAT traffic to (useful when the virtual machine has secondary 34 | NICs or IP addresses). Changing this forces a new resource to be created. 35 | 36 | * `project` - (Optional) The name or ID of the project to deploy this 37 | instance to. Changing this forces a new resource to be created. 38 | 39 | ## Attributes Reference 40 | 41 | The following attributes are exported: 42 | 43 | * `id` - The static nat ID. 44 | * `vm_guest_ip` - The IP address of the virtual machine that is used 45 | to forward the static NAT traffic to. 46 | -------------------------------------------------------------------------------- /website/docs/r/ssh_keypair.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_ssh_keypair" 4 | sidebar_current: "docs-cloudstack-resource-ssh-keypair" 5 | description: |- 6 | Creates or registers an SSH key pair. 7 | --- 8 | 9 | # cloudstack_ssh_keypair 10 | 11 | Creates or registers an SSH key pair. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_ssh_keypair" "default" { 17 | name = "myKey" 18 | public_key = "${file("~/.ssh/id_rsa.pub")}" 19 | project = "myProject" 20 | } 21 | ``` 22 | 23 | ## Argument Reference 24 | 25 | The following arguments are supported: 26 | 27 | * `name` - (Required) The name of the SSH key pair. This is a unique value 28 | within a CloudStack account. Changing this forces a new resource to be 29 | created. 30 | 31 | * `public_key` - (Optional) The public key to register with CloudStack. If 32 | this is omitted, CloudStack will generate a new key pair. The key can 33 | be loaded from a file on disk using the 34 | [`file()` function](https://www.terraform.io/docs/configuration/functions/file.html). 35 | Changing this forces a new resource to be created. 36 | 37 | * `project` - (Optional) The name or ID of the project to register this 38 | key to. Changing this forces a new resource to be created. 39 | 40 | ## Attributes Reference 41 | 42 | The following attributes are exported: 43 | 44 | * `id` - The key pair ID. 45 | * `fingerprint` - The fingerprint of the public key specified or created. 46 | * `private_key` - The private key generated by CloudStack. Only available 47 | if CloudStack generated the key pair. 48 | -------------------------------------------------------------------------------- /website/docs/d/quota.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_quota" 4 | sidebar_current: "docs-cloudstack-datasource-quota" 5 | description: |- 6 | Gets information about CloudStack quota summaries. 7 | --- 8 | 9 | # cloudstack_quota 10 | 11 | Use this data source to retrieve quota summary information for CloudStack accounts and domains. This provides information about quota values and whether quota is enabled for specific accounts. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | # Get quota summary for all accounts 17 | data "cloudstack_quota" "all_quotas" { 18 | } 19 | 20 | # Get quota summary for a specific account 21 | data "cloudstack_quota" "account_quota" { 22 | account = "myaccount" 23 | domain_id = "domain-uuid" 24 | } 25 | 26 | # Get quota summary for a specific domain 27 | data "cloudstack_quota" "domain_quota" { 28 | domain_id = "domain-uuid" 29 | } 30 | ``` 31 | 32 | ## Argument Reference 33 | 34 | The following arguments are supported: 35 | 36 | * `account` - (Optional) The name of the account to filter quota summaries. 37 | 38 | * `domain_id` - (Optional) The ID of the domain to filter quota summaries. 39 | 40 | ## Attribute Reference 41 | 42 | In addition to all arguments above, the following attributes are exported: 43 | 44 | * `quotas` - A list of quota summary objects. Each object contains: 45 | * `account_id` - The ID of the account. 46 | * `account` - The name of the account. 47 | * `domain_id` - The ID of the domain. 48 | * `domain` - The name of the domain. 49 | * `quota_value` - The current quota value for the account. 50 | * `quota_enabled` - Whether quota is enabled for this account. -------------------------------------------------------------------------------- /scripts/errcheck.sh: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | #!/usr/bin/env bash 21 | 22 | # Check gofmt 23 | echo "==> Checking for unchecked errors..." 24 | 25 | if ! which errcheck > /dev/null; then 26 | echo "==> Installing errcheck..." 27 | go install github.com/kisielk/errcheck 28 | fi 29 | 30 | err_files=$(errcheck -ignoretests \ 31 | -ignore 'github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema:Set' \ 32 | -ignore 'bytes:.*' \ 33 | -ignore 'io:Close|Write' \ 34 | $(go list ./...| grep -v /vendor/)) 35 | 36 | if [[ -n ${err_files} ]]; then 37 | echo 'Unchecked errors found in the following places:' 38 | echo "${err_files}" 39 | echo "Please handle returned errors. You can check directly with \`make errcheck\`" 40 | exit 1 41 | fi 42 | 43 | exit 0 44 | -------------------------------------------------------------------------------- /cloudstack/data_source_cloudstack_pod_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" 26 | ) 27 | 28 | func TestAccPodDataSource_basic(t *testing.T) { 29 | resource.Test(t, resource.TestCase{ 30 | PreCheck: func() { testAccPreCheck(t) }, 31 | Providers: testAccProviders, 32 | Steps: []resource.TestStep{ 33 | { 34 | Config: testPodDataSourceConfig_basic, 35 | Check: resource.ComposeTestCheckFunc( 36 | resource.TestCheckResourceAttr("data.cloudstack_pod.test", "name", "POD0"), 37 | ), 38 | }, 39 | }, 40 | }) 41 | } 42 | 43 | const testPodDataSourceConfig_basic = ` 44 | data "cloudstack_pod" "test" { 45 | filter { 46 | name = "name" 47 | value = "POD0" 48 | } 49 | } 50 | ` 51 | -------------------------------------------------------------------------------- /website/docs/r/network_acl.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_network_acl" 4 | sidebar_current: "docs-cloudstack-resource-network-acl" 5 | description: |- 6 | Creates a Network ACL for the given VPC. 7 | --- 8 | 9 | # cloudstack_network_acl 10 | 11 | Creates a Network ACL for the given VPC. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_network_acl" "default" { 17 | name = "test-acl" 18 | vpc_id = "76f6e8dc-07e3-4971-b2a2-8831b0cc4cb4" 19 | } 20 | ``` 21 | 22 | ## Argument Reference 23 | 24 | The following arguments are supported: 25 | 26 | * `name` - (Required) The name of the ACL. Changing this forces a new resource 27 | to be created. 28 | 29 | * `description` - (Optional) The description of the ACL. Changing this forces a 30 | new resource to be created. 31 | 32 | * `project` - (Optional) The name or ID of the project to deploy this 33 | instance to. Changing this forces a new resource to be created. 34 | 35 | * `vpc_id` - (Required) The ID of the VPC to create this ACL for. Changing this 36 | forces a new resource to be created. 37 | 38 | ## Attributes Reference 39 | 40 | The following attributes are exported: 41 | 42 | * `id` - The ID of the Network ACL 43 | 44 | ## Import 45 | 46 | Network ACLs can be imported; use `` as the import ID. For 47 | example: 48 | 49 | ```shell 50 | terraform import cloudstack_network_acl.default e8b5982a-1b50-4ea9-9920-6ea2290c7359 51 | ``` 52 | 53 | When importing into a project you need to prefix the import ID with the project name: 54 | 55 | ```shell 56 | terraform import cloudstack_network_acl.default my-project/e8b5982a-1b50-4ea9-9920-6ea2290c7359 57 | ``` 58 | -------------------------------------------------------------------------------- /website/docs/r/affinity_group.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_affinity_group" 4 | sidebar_current: "docs-cloudstack-resource-affinity-group" 5 | description: |- 6 | Creates an affinity group. 7 | --- 8 | 9 | # cloudstack_affinity_group 10 | 11 | Creates an affinity group. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_affinity_group" "default" { 17 | name = "test-affinity-group" 18 | type = "host anti-affinity" 19 | } 20 | ``` 21 | 22 | ## Argument Reference 23 | 24 | The following arguments are supported: 25 | 26 | * `name` - (Required) The name of the affinity group. Changing this 27 | forces a new resource to be created. 28 | 29 | * `description` - (Optional) The description of the affinity group. 30 | 31 | * `type` - (Required) The affinity group type. Changing this 32 | forces a new resource to be created. 33 | 34 | * `project` - (Optional) The name or ID of the project to register this 35 | affinity group to. Changing this forces a new resource to be created. 36 | 37 | ## Attributes Reference 38 | 39 | The following attributes are exported: 40 | 41 | * `id` - The id of the affinity group. 42 | * `description` - The description of the affinity group. 43 | 44 | ## Import 45 | 46 | Affinity groups can be imported; use `` as the import ID. For 47 | example: 48 | 49 | ```shell 50 | terraform import cloudstack_affinity_group.default 6226ea4d-9cbe-4cc9-b30c-b9532146da5b 51 | ``` 52 | 53 | When importing into a project you need to prefix the import ID with the project name: 54 | 55 | ```shell 56 | terraform import cloudstack_affinity_group.default my-project/6226ea4d-9cbe-4cc9-b30c-b9532146da5b 57 | ``` 58 | 59 | -------------------------------------------------------------------------------- /website/docs/d/condition.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_condition" 4 | sidebar_current: "docs-cloudstack-data-source-condition" 5 | description: |- 6 | Gets information about a CloudStack autoscale condition. 7 | --- 8 | 9 | # cloudstack_condition 10 | 11 | Use this data source to get information about a CloudStack autoscale condition. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | # Get condition by ID 17 | data "cloudstack_condition" "existing_condition" { 18 | id = "c2f0591b-ce9b-499a-81f2-8fc6318b0c72" 19 | } 20 | 21 | # Get condition by filter 22 | data "cloudstack_condition" "cpu_condition" { 23 | filter { 24 | name = "threshold" 25 | value = "80" 26 | } 27 | } 28 | 29 | # Use in a policy 30 | resource "cloudstack_autoscale_policy" "scale_policy" { 31 | name = "scale-up-policy" 32 | action = "scaleup" 33 | duration = 300 34 | quiet_time = 300 35 | condition_ids = [data.cloudstack_condition.existing_condition.id] 36 | } 37 | ``` 38 | 39 | ## Argument Reference 40 | 41 | The following arguments are supported: 42 | 43 | * `id` - (Optional) The ID of the condition. 44 | 45 | * `filter` - (Optional) One or more name/value pairs to filter off of. You can apply filters on any exported attributes. 46 | 47 | ## Attributes Reference 48 | 49 | The following attributes are exported: 50 | 51 | * `id` - The condition ID. 52 | 53 | * `counter_id` - The counter ID being monitored. 54 | 55 | * `relational_operator` - The relational operator for the condition. 56 | 57 | * `threshold` - The threshold value. 58 | 59 | * `account_name` - The account name that owns the condition. 60 | 61 | * `domain_id` - The domain ID where the condition exists. 62 | -------------------------------------------------------------------------------- /website/docs/r/ipaddress.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_ipaddress" 4 | sidebar_current: "docs-cloudstack-resource-ipaddress" 5 | description: |- 6 | Acquires and associates a public IP. 7 | --- 8 | 9 | # cloudstack_ipaddress 10 | 11 | Acquires and associates a public IP. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_ipaddress" "default" { 17 | network_id = "6eb22f91-7454-4107-89f4-36afcdf33021" 18 | } 19 | ``` 20 | 21 | ## Argument Reference 22 | 23 | The following arguments are supported: 24 | 25 | * `is_portable` - (Optional) This determines if the IP address should be transferable 26 | across zones (defaults false) 27 | 28 | * `network_id` - (Optional) The ID of the network for which an IP address should 29 | be acquired and associated. Changing this forces a new resource to be created. 30 | 31 | * `vpc_id` - (Optional) The ID of the VPC for which an IP address should be 32 | acquired and associated. Changing this forces a new resource to be created. 33 | 34 | * `zone` - (Optional) The name or ID of the zone for which an IP address should be 35 | acquired and associated. Changing this forces a new resource to be created. 36 | 37 | * `project` - (Optional) The name or ID of the project to deploy this 38 | instance to. Changing this forces a new resource to be created. 39 | 40 | *NOTE: `network_id` and/or `zone` should have a value when `is_portable` is `false`!* 41 | *NOTE: Either `network_id` or `vpc_id` should have a value when `is_portable` is `true`!* 42 | 43 | ## Attributes Reference 44 | 45 | The following attributes are exported: 46 | 47 | * `id` - The ID of the acquired and associated IP address. 48 | * `ip_address` - The IP address that was acquired and associated. 49 | -------------------------------------------------------------------------------- /cloudstack/resource_cloudstack_secondary_storage_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" 26 | ) 27 | 28 | func TestAccCloudStackSecondaryStorage_basic(t *testing.T) { 29 | resource.Test(t, resource.TestCase{ 30 | PreCheck: func() { testAccPreCheck(t) }, 31 | Providers: testAccProviders, 32 | Steps: []resource.TestStep{ 33 | { 34 | Config: testAccCloudStackSecondaryStorage_basic, 35 | }, 36 | }, 37 | }) 38 | } 39 | 40 | const testAccCloudStackSecondaryStorage_basic = ` 41 | data "cloudstack_zone" "test" { 42 | filter { 43 | name = "name" 44 | value = "Sandbox-simulator" 45 | } 46 | } 47 | resource "cloudstack_secondary_storage" "test" { 48 | name = "acctest_secondarystorage" 49 | storage_provider = "NFS" 50 | url = "nfs://10.147.28.6:/export/home/sandbox/secondary" 51 | zone_id = data.cloudstack_zone.test.id 52 | } 53 | ` 54 | -------------------------------------------------------------------------------- /website/docs/r/account.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | page_title: "CloudStack: cloudstack_account" 4 | sidebar_current: "docs-cloudstack-resource-account" 5 | description: |- 6 | Creates a Account 7 | --- 8 | 9 | # CloudStack: cloudstack_account 10 | 11 | A `cloudstack_account` resource manages an account within CloudStack. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_account" "example" { 17 | email = "user@example.com" 18 | first_name = "John" 19 | last_name = "Doe" 20 | password = "securepassword" 21 | username = "jdoe" 22 | account_type = 1 # 1 for admin, 2 for domain admin, 0 for regular user 23 | role_id = "1234abcd" # ID of the role associated with the account 24 | } 25 | ``` 26 | 27 | ## Argument Reference 28 | 29 | The following arguments are supported: 30 | 31 | * `email` - (Required) The email address of the account owner. 32 | * `first_name` - (Required) The first name of the account owner. 33 | * `last_name` - (Required) The last name of the account owner. 34 | * `password` - (Required) The password for the account. 35 | * `username` - (Required) The username of the account. 36 | * `account_type` - (Required) The account type. Possible values are `0` for regular user, `1` for admin, and `2` for domain admin. 37 | * `role_id` - (Required) The ID of the role associated with the account. 38 | * `account` - (Optional) The account name. If not specified, the username will be used as the account name. 39 | * `domainid` - (Optional) Creates the user under the specified domain 40 | 41 | ## Attributes Reference 42 | 43 | The following attributes are exported: 44 | 45 | * `id` - The ID of the account. 46 | 47 | ## Import 48 | 49 | Accounts can be imported; use `` as the import ID. For example: 50 | 51 | ```shell 52 | $ terraform import cloudstack_account.example 53 | ``` 54 | -------------------------------------------------------------------------------- /website/docs/r/nic.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_nic" 4 | sidebar_current: "docs-cloudstack-resource-nic" 5 | description: |- 6 | Creates an additional NIC to add a VM to the specified network. 7 | --- 8 | 9 | # cloudstack_nic 10 | 11 | Creates an additional NIC to add a VM to the specified network. 12 | 13 | ## Example Usage 14 | 15 | Basic usage: 16 | 17 | ```hcl 18 | resource "cloudstack_nic" "test" { 19 | network_id = "6eb22f91-7454-4107-89f4-36afcdf33021" 20 | ip_address = "192.168.1.1" 21 | virtual_machine_id = "f8141e2f-4e7e-4c63-9362-986c908b7ea7" 22 | } 23 | ``` 24 | 25 | With MAC address: 26 | 27 | ```hcl 28 | resource "cloudstack_nic" "test" { 29 | network_id = "6eb22f91-7454-4107-89f4-36afcdf33021" 30 | ip_address = "192.168.1.1" 31 | mac_address = "02:1a:4b:3c:5d:6e" 32 | virtual_machine_id = "f8141e2f-4e7e-4c63-9362-986c908b7ea7" 33 | } 34 | ``` 35 | 36 | ## Argument Reference 37 | 38 | The following arguments are supported: 39 | 40 | * `network_id` - (Required) The ID of the network to plug the NIC into. Changing 41 | this forces a new resource to be created. 42 | 43 | * `ip_address` - (Optional) The IP address to assign to the NIC. Changing this 44 | forces a new resource to be created. 45 | 46 | * `mac_address` - (Optional) The MAC address to assign to the NIC. If not specified, 47 | a MAC address will be automatically generated. Changing this forces a new resource 48 | to be created. 49 | 50 | * `virtual_machine_id` - (Required) The ID of the virtual machine to which to 51 | attach the NIC. Changing this forces a new resource to be created. 52 | 53 | ## Attributes Reference 54 | 55 | The following attributes are exported: 56 | 57 | * `id` - The ID of the NIC. 58 | * `ip_address` - The assigned IP address. 59 | * `mac_address` - The assigned MAC address. 60 | -------------------------------------------------------------------------------- /website/docs/r/condition.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_condition" 4 | sidebar_current: "docs-cloudstack-condition" 5 | description: |- 6 | Creates a condition for autoscale policies. 7 | --- 8 | 9 | # cloudstack_condition 10 | 11 | Creates a condition that evaluates performance metrics against thresholds for autoscale policies. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | # Reference an existing counter 17 | data "cloudstack_counter" "cpu_counter" { 18 | id = "959e11c0-8416-11f0-9a72-1e001b000238" 19 | } 20 | 21 | resource "cloudstack_condition" "scale_up_condition" { 22 | counter_id = data.cloudstack_counter.cpu_counter.id 23 | relational_operator = "GT" 24 | threshold = 80.0 25 | account_name = "admin" 26 | domain_id = "1" 27 | } 28 | 29 | resource "cloudstack_condition" "scale_down_condition" { 30 | counter_id = data.cloudstack_counter.cpu_counter.id 31 | relational_operator = "LT" 32 | threshold = 20.0 33 | account_name = "admin" 34 | domain_id = "1" 35 | } 36 | ``` 37 | 38 | ## Argument Reference 39 | 40 | The following arguments are supported: 41 | 42 | * `counter_id` - (Required) The ID of the counter to monitor. 43 | 44 | * `relational_operator` - (Required) The relational operator for the condition. Valid values are: 45 | * `"GT"` - Greater than 46 | * `"LT"` - Less than 47 | * `"EQ"` - Equal to 48 | * `"GE"` - Greater than or equal to 49 | * `"LE"` - Less than or equal to 50 | 51 | * `threshold` - (Required) The threshold value to compare against. 52 | 53 | * `account_name` - (Required) The account name that owns this condition. 54 | 55 | * `domain_id` - (Required) The domain ID where the condition will be created. 56 | 57 | ## Attributes Reference 58 | 59 | The following attributes are exported: 60 | 61 | * `id` - The condition ID. 62 | -------------------------------------------------------------------------------- /website/docs/r/storage_pool.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_storage_pool" 4 | sidebar_current: "docs-cloudstack-resource-storage-pool" 5 | description: |- 6 | Creates a storage pool. 7 | --- 8 | 9 | # cloudstack_storage_pool 10 | 11 | Creates a storage pool. 12 | 13 | ## Example Usage 14 | 15 | Basic usage: 16 | 17 | ```hcl 18 | resource "cloudstack_storage_pool" "example" { 19 | name = "example" 20 | url = "nfs://10.147.28.6/export/home/sandbox/primary11" 21 | zone_id = "0ed38eb3-f279-4951-ac20-fef39ebab20c" 22 | cluster_id = "9daeeb36-d8b7-497a-9b53-bbebba88c817" 23 | pod_id = "2ff52b73-139e-4c40-a0a3-5b7d87d8e3c4" 24 | scope = "CLUSTER" 25 | hypervisor = "Simulator" 26 | } 27 | ``` 28 | 29 | ## Argument Reference 30 | 31 | The following arguments are supported: 32 | 33 | * `cluster_id` - (Optional) the cluster ID for the storage pool. 34 | * `hypervisor` - (Optional) hypervisor type of the hosts in zone that will be attached to this storage pool. KVM, VMware supported as of now. 35 | * `name` - (Required) the name for the storage pool. 36 | * `pod_id` - (Optional) the Pod ID for the storage pool. 37 | * `storage_provider` - (Optional) the storage provider name. 38 | * `scope` - (Optional) the scope of the storage: cluster or zone. 39 | * `state` - (Optional) the state of the storage pool. 40 | * `tags` - (Optional) the tags for the storage pool. 41 | * `url` - (Required) the URL of the storage pool. 42 | * `zone_id` - (Required) the Zone ID for the storage pool. 43 | 44 | 45 | ## Attributes Reference 46 | 47 | The following attributes are exported: 48 | 49 | * `id` - The instance ID. 50 | 51 | 52 | 53 | ## Import 54 | 55 | Storage pools can be imported; use `` as the import ID. For 56 | example: 57 | 58 | ```shell 59 | terraform import cloudstack_storage_pool.example 5cf69677-7e4b-4bf4-b868-f0b02bb72ee0 60 | ``` 61 | -------------------------------------------------------------------------------- /scripts/changelog-links.sh: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | # KIND, either express or implied. See the License for the 16 | # specific language governing permissions and limitations 17 | # under the License. 18 | # 19 | 20 | #!/bin/bash 21 | 22 | # This script rewrites [GH-nnnn]-style references in the CHANGELOG.md file to 23 | # be Markdown links to the given github issues. 24 | # 25 | # This is run during releases so that the issue references in all of the 26 | # released items are presented as clickable links, but we can just use the 27 | # easy [GH-nnnn] shorthand for quickly adding items to the "Unrelease" section 28 | # while merging things between releases. 29 | 30 | set -e 31 | 32 | if [[ ! -f CHANGELOG.md ]]; then 33 | echo "ERROR: CHANGELOG.md not found in pwd." 34 | echo "Please run this from the root of the terraform provider repository" 35 | exit 1 36 | fi 37 | 38 | if [[ `uname` == "Darwin" ]]; then 39 | echo "Using BSD sed" 40 | SED="sed -i.bak -E -e" 41 | else 42 | echo "Using GNU sed" 43 | SED="sed -i.bak -r -e" 44 | fi 45 | 46 | PROVIDER_URL="https:\/\/github.com\/terraform-providers\/terraform-provider-cloudstack\/issues" 47 | 48 | $SED "s/GH-([0-9]+)/\[#\1\]\($PROVIDER_URL\/\1\)/g" -e 's/\[\[#(.+)([0-9])\)]$/(\[#\1\2))/g' CHANGELOG.md 49 | 50 | rm CHANGELOG.md.bak 51 | -------------------------------------------------------------------------------- /website/docs/d/autoscale_policy.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_autoscale_policy" 4 | sidebar_current: "docs-cloudstack-data-source-autoscale-policy" 5 | description: |- 6 | Gets information about a CloudStack autoscale policy. 7 | --- 8 | 9 | # cloudstack_autoscale_policy 10 | 11 | Use this data source to get information about a CloudStack autoscale policy. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | # Get policy by ID 17 | data "cloudstack_autoscale_policy" "existing_policy" { 18 | id = "6a8dc025-d7c9-4676-8a7d-e2d9b55e7e60" 19 | } 20 | 21 | # Get policy by name 22 | data "cloudstack_autoscale_policy" "scale_up_policy" { 23 | filter { 24 | name = "name" 25 | value = "scale-up-policy" 26 | } 27 | } 28 | 29 | # Use in an autoscale VM group 30 | resource "cloudstack_autoscale_vm_group" "vm_group" { 31 | name = "web-autoscale" 32 | lbrule_id = cloudstack_loadbalancer_rule.lb.id 33 | min_members = 1 34 | max_members = 5 35 | vm_profile_id = cloudstack_autoscale_vm_profile.profile.id 36 | 37 | scaleup_policy_ids = [ 38 | data.cloudstack_autoscale_policy.existing_policy.id 39 | ] 40 | 41 | scaledown_policy_ids = [ 42 | cloudstack_autoscale_policy.scale_down.id 43 | ] 44 | } 45 | ``` 46 | 47 | ## Argument Reference 48 | 49 | The following arguments are supported: 50 | 51 | * `id` - (Optional) The ID of the autoscale policy. 52 | 53 | * `filter` - (Optional) One or more name/value pairs to filter off of. You can apply filters on any exported attributes. 54 | 55 | ## Attributes Reference 56 | 57 | The following attributes are exported: 58 | 59 | * `id` - The autoscale policy ID. 60 | 61 | * `name` - The name of the policy. 62 | 63 | * `action` - The action (SCALEUP or SCALEDOWN). 64 | 65 | * `duration` - The duration in seconds. 66 | 67 | * `quiet_time` - The quiet time in seconds. 68 | 69 | * `condition_ids` - The list of condition IDs used by this policy. 70 | -------------------------------------------------------------------------------- /cloudstack/data_source_cloudstack_ssh_keypair_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" 26 | ) 27 | 28 | func TestAccSshKeyPairDataSource_basic(t *testing.T) { 29 | resourceName := "cloudstack_ssh_keypair.ssh-keypair-resource" 30 | datasourceName := "data.cloudstack_ssh_keypair.ssh-keypair-data" 31 | 32 | resource.Test(t, resource.TestCase{ 33 | PreCheck: func() { testAccPreCheck(t) }, 34 | Providers: testAccProviders, 35 | Steps: []resource.TestStep{ 36 | { 37 | Config: testAccSshKeyPairDataSourceConfig_basic, 38 | Check: resource.ComposeTestCheckFunc( 39 | resource.TestCheckResourceAttrPair(datasourceName, "id", resourceName, "id"), 40 | ), 41 | }, 42 | }, 43 | }) 44 | } 45 | 46 | const testAccSshKeyPairDataSourceConfig_basic = ` 47 | resource "cloudstack_ssh_keypair" "ssh-keypair-resource"{ 48 | name = "myKey" 49 | } 50 | 51 | data "cloudstack_ssh_keypair" "ssh-keypair-data" { 52 | filter { 53 | name = "name" 54 | value = "myKey" 55 | } 56 | depends_on = [ 57 | cloudstack_ssh_keypair.ssh-keypair-resource 58 | ] 59 | 60 | } 61 | ` 62 | -------------------------------------------------------------------------------- /cloudstack/data_source_cloudstack_zone_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" 26 | ) 27 | 28 | func TestAccZoneDataSource_basic(t *testing.T) { 29 | resourceName := "cloudstack_zone.zone-resource" 30 | datasourceName := "data.cloudstack_zone.zone-data-source" 31 | 32 | resource.Test(t, resource.TestCase{ 33 | PreCheck: func() { testAccPreCheck(t) }, 34 | Providers: testAccProviders, 35 | Steps: []resource.TestStep{ 36 | { 37 | Config: testZoneDataSourceConfig_basic, 38 | Check: resource.ComposeTestCheckFunc( 39 | resource.TestCheckResourceAttrPair(datasourceName, "name", resourceName, "name"), 40 | ), 41 | }, 42 | }, 43 | }) 44 | } 45 | 46 | const testZoneDataSourceConfig_basic = ` 47 | resource "cloudstack_zone" "zone-resource"{ 48 | name = "TestZone" 49 | dns1 = "8.8.8.8" 50 | internal_dns1 = "172.20.0.1" 51 | network_type = "Advanced" 52 | } 53 | 54 | data "cloudstack_zone" "zone-data-source"{ 55 | 56 | filter{ 57 | name = "name" 58 | value="TestZone" 59 | } 60 | depends_on = [ 61 | cloudstack_zone.zone-resource 62 | ] 63 | 64 | } 65 | ` 66 | -------------------------------------------------------------------------------- /website/docs/r/kubernetes_version.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | page_title: "CloudStack: cloudstack_kubernetes_version" 4 | sidebar_current: "docs-cloudstack-resource-kubernetes_version" 5 | description: |- 6 | Creates a Kubernetes Version 7 | --- 8 | 9 | # CloudStack: cloudstack_kubernetes_version 10 | 11 | A `cloudstack_kubernetes_version` resource manages a Kubernetes version within CloudStack. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_kubernetes_version" "example" { 17 | semantic_version = "1.19.0" 18 | url = "https://example.com/k8s/1.19.0.tar.gz" 19 | min_cpu = 2 20 | min_memory = 2048 21 | } 22 | ``` 23 | 24 | ## Argument Reference 25 | 26 | The following arguments are supported: 27 | 28 | * `semantic_version` - (Required) The semantic version of the Kubernetes version. 29 | * `url` - (Required) The URL to download the Kubernetes version package. 30 | * `min_cpu` - (Required) The minimum CPU requirement for the Kubernetes version. 31 | * `min_memory` - (Required) The minimum memory requirement for the Kubernetes version. 32 | * `name` - (Optional) The name of the Kubernetes version. 33 | * `zone` - (Optional) The zone in which the Kubernetes version should be added. 34 | * `checksum` - (Optional) The checksum of the Kubernetes version package. 35 | * `state` - (Optional) The state of the Kubernetes version. Defaults to "Enabled". 36 | 37 | ## Attributes Reference 38 | 39 | The following attributes are exported: 40 | 41 | * `id` - The ID of the Kubernetes version. 42 | * `semantic_version` - The semantic version of the Kubernetes version. 43 | * `name` - The name of the Kubernetes version. 44 | * `min_cpu` - The minimum CPU requirement for the Kubernetes version. 45 | * `min_memory` - The minimum memory requirement for the Kubernetes version. 46 | * `state` - The state of the Kubernetes version. 47 | 48 | ## Import 49 | 50 | Kubernetes versions can be imported using the ID of the resource; use `` as the import ID. For example: 51 | 52 | ```shell 53 | $ terraform import cloudstack_kubernetes_version.example 54 | ``` 55 | -------------------------------------------------------------------------------- /website/docs/r/vpc.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_vpc" 4 | sidebar_current: "docs-cloudstack-resource-vpc" 5 | description: |- 6 | Creates a VPC. 7 | --- 8 | 9 | # cloudstack_vpc 10 | 11 | Creates a VPC. 12 | 13 | ## Example Usage 14 | 15 | Basic usage: 16 | 17 | ```hcl 18 | resource "cloudstack_vpc" "default" { 19 | name = "test-vpc" 20 | cidr = "10.0.0.0/16" 21 | vpc_offering = "Default VPC Offering" 22 | zone = "zone-1" 23 | } 24 | ``` 25 | 26 | ## Argument Reference 27 | 28 | The following arguments are supported: 29 | 30 | * `name` - (Required) The name of the VPC. 31 | 32 | * `display_text` - (Optional) The display text of the VPC. 33 | 34 | * `cidr` - (Required) The CIDR block for the VPC. Changing this forces a new 35 | resource to be created. 36 | 37 | * `vpc_offering` - (Required) The name or ID of the VPC offering to use for this VPC. 38 | Changing this forces a new resource to be created. 39 | 40 | * `network_domain` - (Optional) The default DNS domain for networks created in 41 | this VPC. Changing this forces a new resource to be created. 42 | 43 | * `project` - (Optional) The name or ID of the project to deploy this 44 | instance to. Changing this forces a new resource to be created. 45 | 46 | * `zone` - (Required) The name or ID of the zone where this disk volume will be 47 | available. Changing this forces a new resource to be created. 48 | 49 | ## Attributes Reference 50 | 51 | The following attributes are exported: 52 | 53 | * `id` - The ID of the VPC. 54 | * `display_text` - The display text of the VPC. 55 | * `source_nat_ip` - The source NAT IP assigned to the VPC. 56 | 57 | ## Import 58 | 59 | VPCs can be imported; use `` as the import ID. For 60 | example: 61 | 62 | ```shell 63 | terraform import cloudstack_vpc.default 84b23264-917a-4712-b8bf-cd7604db43b0 64 | ``` 65 | 66 | When importing into a project you need to prefix the import ID with the project name: 67 | 68 | ```shell 69 | terraform import cloudstack_vpc.default my-project/84b23264-917a-4712-b8bf-cd7604db43b0 70 | ``` 71 | -------------------------------------------------------------------------------- /cloudstack/data_source_cloudstack_role_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" 26 | ) 27 | 28 | func TestAccDataSourceCloudStackRole_basic(t *testing.T) { 29 | resource.Test(t, resource.TestCase{ 30 | PreCheck: func() { testAccPreCheck(t) }, 31 | Providers: testAccProviders, 32 | Steps: []resource.TestStep{ 33 | { 34 | Config: testAccDataSourceCloudStackRole_basic, 35 | Check: resource.ComposeTestCheckFunc( 36 | resource.TestCheckResourceAttr( 37 | "data.cloudstack_role.role", "name", "terraform-role"), 38 | resource.TestCheckResourceAttr( 39 | "data.cloudstack_role.role", "description", "terraform test role"), 40 | resource.TestCheckResourceAttr( 41 | "data.cloudstack_role.role", "is_public", "true"), 42 | ), 43 | }, 44 | }, 45 | }) 46 | } 47 | 48 | const testAccDataSourceCloudStackRole_basic = ` 49 | resource "cloudstack_role" "foo" { 50 | name = "terraform-role" 51 | description = "terraform test role" 52 | is_public = true 53 | type = "User" 54 | } 55 | 56 | data "cloudstack_role" "role" { 57 | filter { 58 | name = "name" 59 | value = "${cloudstack_role.foo.name}" 60 | } 61 | } 62 | ` 63 | -------------------------------------------------------------------------------- /website/docs/r/project.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_project" 4 | description: |- 5 | Creates a project. 6 | --- 7 | 8 | # cloudstack_project 9 | 10 | Creates a project. 11 | 12 | ## Example Usage 13 | 14 | ```hcl 15 | resource "cloudstack_project" "myproject" { 16 | name = "terraform-project" 17 | display_text = "Terraform Managed Project" 18 | domain = "root" 19 | } 20 | ``` 21 | 22 | ### With Account and User ID 23 | 24 | ```hcl 25 | resource "cloudstack_project" "myproject" { 26 | name = "terraform-project" 27 | display_text = "Terraform Managed Project" 28 | domain = "root" 29 | account = "admin" 30 | userid = "b0afc3ca-a99c-4fb4-98ad-8564acab10a4" 31 | } 32 | ``` 33 | 34 | ## Argument Reference 35 | 36 | The following arguments are supported: 37 | 38 | * `name` - (Required) The name of the project. 39 | * `display_text` - (Required) The display text of the project. Required for API version 4.18 and lower compatibility. This requirement will be removed when support for API versions older than 4.18 is dropped. 40 | * `domain` - (Optional) The domain where the project will be created. This cannot be changed after the project is created. 41 | * `account` - (Optional) The account who will be Admin for the project. Requires `domain` to be set. This can be updated after the project is created. 42 | * `accountid` - (Optional) The ID of the account owning the project. This can be updated after the project is created. 43 | * `userid` - (Optional) The user ID of the account to be assigned as owner of the project (Project Admin). This can be updated after the project is created. 44 | 45 | ## Attributes Reference 46 | 47 | The following attributes are exported: 48 | 49 | * `id` - The ID of the project. 50 | * `name` - The name of the project. 51 | * `display_text` - The display text of the project. 52 | * `domain` - The domain where the project was created. 53 | 54 | ## Import 55 | 56 | Projects can be imported using the project ID, e.g. 57 | 58 | ```sh 59 | terraform import cloudstack_project.myproject 5cf69677-7e4b-4bf4-b868-f0b02bb72ee0 60 | ``` 61 | -------------------------------------------------------------------------------- /cloudstack/data_source_cloudstack_service_offering_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" 26 | ) 27 | 28 | func TestAccServiceOfferingDataSource_basic(t *testing.T) { 29 | resourceName := "cloudstack_service_offering.service-offering-resource" 30 | datasourceName := "data.cloudstack_service_offering.service-offering-data-source" 31 | 32 | resource.Test(t, resource.TestCase{ 33 | PreCheck: func() { testAccPreCheck(t) }, 34 | Providers: testAccProviders, 35 | Steps: []resource.TestStep{ 36 | { 37 | Config: testServiceOfferingDataSourceConfig_basic, 38 | Check: resource.ComposeTestCheckFunc( 39 | resource.TestCheckResourceAttrPair(datasourceName, "name", resourceName, "name"), 40 | ), 41 | }, 42 | }, 43 | }) 44 | } 45 | 46 | const testServiceOfferingDataSourceConfig_basic = ` 47 | resource "cloudstack_service_offering" "service-offering-resource" { 48 | name = "TestServiceUpdate" 49 | display_text = "DisplayService" 50 | } 51 | 52 | data "cloudstack_service_offering" "service-offering-data-source" { 53 | filter { 54 | name = "name" 55 | value = "TestServiceUpdate" 56 | } 57 | depends_on = [cloudstack_service_offering.service-offering-resource] 58 | } 59 | ` 60 | -------------------------------------------------------------------------------- /website/docs/r/private_gateway.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_private_gateway" 4 | sidebar_current: "docs-cloudstack-resource-private-gateway" 5 | description: |- 6 | Creates a private gateway. 7 | --- 8 | 9 | # cloudstack_private_gateway 10 | 11 | Creates a private gateway for the given VPC. 12 | 13 | *NOTE: private gateway can only be created using a ROOT account!* 14 | 15 | ## Example Usage 16 | 17 | ```hcl 18 | resource "cloudstack_private_gateway" "default" { 19 | gateway = "10.0.0.1" 20 | ip_address = "10.0.0.2" 21 | netmask = "255.255.255.252" 22 | vlan = "200" 23 | vpc_id = "76f6e8dc-07e3-4971-b2a2-8831b0cc4cb4" 24 | acl_id = "cf4f1dad-aade-4ccd-866c-0a2166e5be3d" 25 | } 26 | ``` 27 | 28 | ## Argument Reference 29 | 30 | The following arguments are supported: 31 | 32 | * `gateway` - (Required) the gateway of the Private gateway. Changing this 33 | forces a new resource to be created. 34 | 35 | * `ip_address` - (Required) the IP address of the Private gateway. Changing this forces 36 | a new resource to be created. 37 | 38 | * `netmask` - (Required) The netmask of the Private gateway. Changing 39 | this forces a new resource to be created. 40 | 41 | * `vlan` - (Required) The VLAN number (1-4095) the network will use. 42 | 43 | * `physical_network_id` - (Optional) The ID of the physical network this private 44 | gateway belongs to. 45 | 46 | * `network_offering` - (Optional) The name or ID of the network offering to use for 47 | the private gateways network connection. 48 | 49 | * `acl_id` - (Required) The ACL ID that should be attached to the network. 50 | 51 | * `vpc_id` - (Required) The VPC ID in which to create this Private gateway. Changing 52 | this forces a new resource to be created. 53 | 54 | ## Attributes Reference 55 | 56 | The following attributes are exported: 57 | 58 | * `id` - The ID of the private gateway. 59 | 60 | ## Import 61 | 62 | Private gateways can be imported; use `` as the import ID. For 63 | example: 64 | 65 | ```shell 66 | terraform import cloudstack_private_gateway.default e42a24d2-46cb-4b18-9d41-382582fad309 67 | ``` 68 | -------------------------------------------------------------------------------- /website/docs/d/autoscale_vm_group.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_autoscale_vm_group" 4 | sidebar_current: "docs-cloudstack-data-source-autoscale-vm-group" 5 | description: |- 6 | Gets information about a CloudStack autoscale VM group. 7 | --- 8 | 9 | # cloudstack_autoscale_vm_group 10 | 11 | Use this data source to get information about a CloudStack autoscale VM group. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | # Get autoscale VM group by ID 17 | data "cloudstack_autoscale_vm_group" "existing_group" { 18 | id = "156a819a-dec1-4166-aab3-657c271fa4a3" 19 | } 20 | 21 | # Get autoscale VM group by name 22 | data "cloudstack_autoscale_vm_group" "web_group" { 23 | filter { 24 | name = "name" 25 | value = "web-server-autoscale" 26 | } 27 | } 28 | 29 | # Output information about the group 30 | output "autoscale_group_state" { 31 | value = data.cloudstack_autoscale_vm_group.existing_group.state 32 | } 33 | 34 | output "current_members" { 35 | value = "Min: ${data.cloudstack_autoscale_vm_group.existing_group.min_members}, Max: ${data.cloudstack_autoscale_vm_group.existing_group.max_members}" 36 | } 37 | ``` 38 | 39 | ## Argument Reference 40 | 41 | The following arguments are supported: 42 | 43 | * `id` - (Optional) The ID of the autoscale VM group. 44 | 45 | * `filter` - (Optional) One or more name/value pairs to filter off of. You can apply filters on any exported attributes. 46 | 47 | ## Attributes Reference 48 | 49 | The following attributes are exported: 50 | 51 | * `id` - The autoscale VM group ID. 52 | 53 | * `name` - The name of the autoscale VM group. 54 | 55 | * `lbrule_id` - The load balancer rule ID. 56 | 57 | * `min_members` - The minimum number of members. 58 | 59 | * `max_members` - The maximum number of members. 60 | 61 | * `vm_profile_id` - The VM profile ID. 62 | 63 | * `interval` - The monitoring interval in seconds. 64 | 65 | * `display` - Whether the group is displayed to end users. 66 | 67 | * `state` - The current state of the group (enable or disable). 68 | 69 | * `scaleup_policy_ids` - The list of scale-up policy IDs. 70 | 71 | * `scaledown_policy_ids` - The list of scale-down policy IDs. 72 | -------------------------------------------------------------------------------- /cloudstack/data_source_cloudstack_ipaddress_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" 26 | ) 27 | 28 | func TestAccIPAddressDataSource_basic(t *testing.T) { 29 | resourceName := "cloudstack_ipaddress.ipaddress-resource" 30 | datasourceName := "data.cloudstack_ipaddress.ipaddress-data-source" 31 | 32 | resource.Test(t, resource.TestCase{ 33 | PreCheck: func() { testAccPreCheck(t) }, 34 | Providers: testAccProviders, 35 | Steps: []resource.TestStep{ 36 | { 37 | Config: testIPAddressDataSourceConfig_basic, 38 | Check: resource.ComposeTestCheckFunc( 39 | resource.TestCheckResourceAttrPair(datasourceName, "zone_name", resourceName, "zone"), 40 | ), 41 | }, 42 | }, 43 | }) 44 | } 45 | 46 | const testIPAddressDataSourceConfig_basic = ` 47 | resource "cloudstack_ipaddress" "ipaddress-resource" { 48 | zone = "Sandbox-simulator" 49 | } 50 | 51 | data "cloudstack_ipaddress" "ipaddress-data-source"{ 52 | filter{ 53 | name = "zone_name" 54 | value= "Sandbox-simulator" 55 | } 56 | depends_on = [ 57 | cloudstack_ipaddress.ipaddress-resource 58 | ] 59 | } 60 | 61 | output "ipaddress-output" { 62 | value = data.cloudstack_ipaddress.ipaddress-data-source 63 | } 64 | ` 65 | -------------------------------------------------------------------------------- /website/docs/r/firewall.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_firewall" 4 | sidebar_current: "docs-cloudstack-resource-firewall" 5 | description: |- 6 | Creates firewall rules for a given IP address. 7 | --- 8 | 9 | # cloudstack_firewall 10 | 11 | Creates firewall rules for a given IP address. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_firewall" "default" { 17 | ip_address_id = "30b21801-d4b3-4174-852b-0c0f30bdbbfb" 18 | 19 | rule { 20 | cidr_list = ["10.0.0.0/8"] 21 | protocol = "tcp" 22 | ports = ["80", "1000-2000"] 23 | } 24 | } 25 | ``` 26 | 27 | ## Argument Reference 28 | 29 | The following arguments are supported: 30 | 31 | * `ip_address_id` - (Required) The IP address ID for which to create the 32 | firewall rules. Changing this forces a new resource to be created. 33 | 34 | * `managed` - (Optional) USE WITH CAUTION! If enabled all the firewall rules for 35 | this IP address will be managed by this resource. This means it will delete 36 | all firewall rules that are not in your config! (defaults false) 37 | 38 | * `rule` - (Optional) Can be specified multiple times. Each rule block supports 39 | fields documented below. If `managed = false` at least one rule is required! 40 | 41 | * `parallelism` (Optional) Specifies how much rules will be created or deleted 42 | concurrently. (defaults 2) 43 | 44 | The `rule` block supports: 45 | 46 | * `cidr_list` - (Required) A CIDR list to allow access to the given ports. 47 | 48 | * `protocol` - (Required) The name of the protocol to allow. Valid options are: 49 | `tcp`, `udp` and `icmp`. 50 | 51 | * `icmp_type` - (Optional) The ICMP type to allow. This can only be specified if 52 | the protocol is ICMP. 53 | 54 | * `icmp_code` - (Optional) The ICMP code to allow. This can only be specified if 55 | the protocol is ICMP. 56 | 57 | * `ports` - (Optional) List of ports and/or port ranges to allow. This can only 58 | be specified if the protocol is TCP or UDP. 59 | 60 | ## Attributes Reference 61 | 62 | The following attributes are exported: 63 | 64 | * `id` - The IP address ID for which the firewall rules are created. 65 | -------------------------------------------------------------------------------- /cloudstack/resource_cloudstack_cluster_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" 26 | ) 27 | 28 | func TestAccCloudStackCluster_basic(t *testing.T) { 29 | resource.Test(t, resource.TestCase{ 30 | PreCheck: func() { testAccPreCheck(t) }, 31 | Providers: testAccProviders, 32 | Steps: []resource.TestStep{ 33 | { 34 | Config: testAccCloudStackCluster_basic, 35 | }, 36 | }, 37 | }) 38 | } 39 | 40 | const testAccCloudStackCluster_basic = ` 41 | resource "cloudstack_zone" "test" { 42 | name = "acc_zone" 43 | dns1 = "8.8.8.8" 44 | dns2 = "8.8.8.8" 45 | internal_dns1 = "8.8.4.4" 46 | internal_dns2 = "8.8.4.4" 47 | network_type = "Advanced" 48 | domain = "cloudstack.apache.org" 49 | } 50 | resource "cloudstack_pod" "test" { 51 | allocation_state = "Disabled" 52 | gateway = "172.30.0.1" 53 | name = "acc_pod" 54 | netmask = "255.255.240.0" 55 | start_ip = "172.30.0.2" 56 | zone_id = cloudstack_zone.test.id 57 | } 58 | resource "cloudstack_cluster" "test" { 59 | cluster_name = "acc_cluster" 60 | cluster_type = "CloudManaged" 61 | hypervisor = "KVM" 62 | pod_id = cloudstack_pod.test.id 63 | zone_id = cloudstack_zone.test.id 64 | } 65 | ` 66 | -------------------------------------------------------------------------------- /.goreleaser.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | version: 2 18 | 19 | before: 20 | hooks: 21 | - go mod download 22 | - go mod tidy 23 | 24 | builds: 25 | - env: 26 | - CGO_ENABLED=0 27 | mod_timestamp: '{{ .CommitTimestamp }}' 28 | flags: 29 | - -trimpath 30 | ldflags: 31 | - '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}' 32 | goos: 33 | - linux 34 | - darwin 35 | - windows 36 | - freebsd 37 | - openbsd 38 | goarch: 39 | - amd64 40 | - 386 41 | - arm64 42 | - arm 43 | ignore: 44 | - goos: darwin 45 | goarch: 386 46 | - goos: openbsd 47 | goarch: arm 48 | - goos: openbsd 49 | goarch: arm64 50 | - goos: windows 51 | goarch: arm64 52 | binary: '{{ .ProjectName }}' 53 | 54 | archives: 55 | - format: zip 56 | name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' 57 | 58 | checksum: 59 | name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS' 60 | algorithm: sha256 61 | 62 | signs: 63 | - artifacts: checksum 64 | args: 65 | - --batch 66 | - -u 67 | - '{{ .Env.GPG_FINGERPRINT }}' 68 | - --output 69 | - '${signature}' 70 | - --detach-sign 71 | - '${artifact}' 72 | 73 | release: 74 | disable: false 75 | github: 76 | owner: cloudstack 77 | name: terraform-provider-cloudstack 78 | -------------------------------------------------------------------------------- /website/docs/r/egress_firewall.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_egress_firewall" 4 | sidebar_current: "docs-cloudstack-resource-egress-firewall" 5 | description: |- 6 | Creates egress firewall rules for a given network. 7 | --- 8 | 9 | # cloudstack_egress_firewall 10 | 11 | Creates egress firewall rules for a given network. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_egress_firewall" "default" { 17 | network_id = "6eb22f91-7454-4107-89f4-36afcdf33021" 18 | 19 | rule { 20 | cidr_list = ["10.0.0.0/8"] 21 | protocol = "tcp" 22 | ports = ["80", "1000-2000"] 23 | } 24 | } 25 | ``` 26 | 27 | ## Argument Reference 28 | 29 | The following arguments are supported: 30 | 31 | * `network_id` - (Required) The network ID for which to create the egress 32 | firewall rules. Changing this forces a new resource to be created. 33 | 34 | * `managed` - (Optional) USE WITH CAUTION! If enabled all the egress firewall 35 | rules for this network will be managed by this resource. This means it will 36 | delete all firewall rules that are not in your config! (defaults false) 37 | 38 | * `rule` - (Optional) Can be specified multiple times. Each rule block supports 39 | fields documented below. If `managed = false` at least one rule is required! 40 | 41 | * `parallelism` (Optional) Specifies how much rules will be created or deleted 42 | concurrently. (defaults 2) 43 | 44 | The `rule` block supports: 45 | 46 | * `cidr_list` - (Required) A CIDR list to allow access to the given ports. 47 | 48 | * `protocol` - (Required) The name of the protocol to allow. Valid options are: 49 | `tcp`, `udp` and `icmp`. 50 | 51 | * `icmp_type` - (Optional) The ICMP type to allow. This can only be specified if 52 | the protocol is ICMP. 53 | 54 | * `icmp_code` - (Optional) The ICMP code to allow. This can only be specified if 55 | the protocol is ICMP. 56 | 57 | * `ports` - (Optional) List of ports and/or port ranges to allow. This can only 58 | be specified if the protocol is TCP or UDP. 59 | 60 | ## Attributes Reference 61 | 62 | The following attributes are exported: 63 | 64 | * `id` - The network ID for which the egress firewall rules are created. 65 | -------------------------------------------------------------------------------- /cloudstack/data_source_cloudstack_user_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" 26 | ) 27 | 28 | func TestAccUserDataSource_basic(t *testing.T) { 29 | resourceName := "cloudstack_user.user-resource" 30 | datasourceName := "data.cloudstack_user.user-data-source" 31 | 32 | resource.Test(t, resource.TestCase{ 33 | PreCheck: func() { testAccPreCheck(t) }, 34 | Providers: testAccProviders, 35 | Steps: []resource.TestStep{ 36 | { 37 | Config: testUserDataSourceConfig_basic, 38 | Check: resource.ComposeTestCheckFunc( 39 | resource.TestCheckResourceAttrPair(datasourceName, "first_name", resourceName, "first_name"), 40 | ), 41 | }, 42 | }, 43 | }) 44 | } 45 | 46 | const testUserDataSourceConfig_basic = ` 47 | resource "cloudstack_user" "user-resource" { 48 | account = "admin" 49 | email = "jon.doe@gmail.com" 50 | first_name = "jon" 51 | last_name = "doe" 52 | password = "password" 53 | username = "jon123" 54 | } 55 | 56 | data "cloudstack_user" "user-data-source"{ 57 | filter{ 58 | name = "first_name" 59 | value= "jon" 60 | } 61 | depends_on = [ 62 | cloudstack_user.user-resource 63 | ] 64 | } 65 | 66 | output "user-output" { 67 | value = data.cloudstack_user.user-data-source 68 | } 69 | ` 70 | -------------------------------------------------------------------------------- /cloudstack/data_source_cloudstack_vpc_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" 26 | ) 27 | 28 | func TestAccVPCDataSource_basic(t *testing.T) { 29 | resourceName := "cloudstack_vpc.vpc-resource" 30 | datasourceName := "data.cloudstack_vpc.vpc-data-source" 31 | 32 | resource.Test(t, resource.TestCase{ 33 | PreCheck: func() { testAccPreCheck(t) }, 34 | Providers: testAccProviders, 35 | Steps: []resource.TestStep{ 36 | { 37 | Config: testVPCDataSourceConfig_basic, 38 | Check: resource.ComposeTestCheckFunc( 39 | resource.TestCheckResourceAttrPair(datasourceName, "name", resourceName, "name"), 40 | ), 41 | ExpectNonEmptyPlan: true, 42 | }, 43 | }, 44 | }) 45 | } 46 | 47 | const testVPCDataSourceConfig_basic = ` 48 | resource "cloudstack_vpc" "vpc-resource" { 49 | name = "test-vpc" 50 | cidr = "10.0.0.0/16" 51 | vpc_offering = "Default VPC Offering" 52 | zone = "Sandbox-simulator" 53 | } 54 | 55 | data "cloudstack_vpc" "vpc-data-source"{ 56 | filter{ 57 | name = "name" 58 | value= "test-vpc" 59 | } 60 | filter{ 61 | name = "cidr" 62 | value= "10.0.0.0/16" 63 | } 64 | depends_on = [ 65 | cloudstack_vpc.vpc-resource 66 | ] 67 | } 68 | 69 | output "vpc-output" { 70 | value = data.cloudstack_vpc.vpc-data-source 71 | } 72 | ` 73 | -------------------------------------------------------------------------------- /website/docs/d/quota_tariff.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_quota_tariff" 4 | sidebar_current: "docs-cloudstack-datasource-quota-tariff" 5 | description: |- 6 | Gets information about CloudStack quota tariffs. 7 | --- 8 | 9 | # cloudstack_quota_tariff 10 | 11 | Use this data source to retrieve information about quota tariffs in CloudStack. Quota tariffs define the pricing for different resource usage types. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | # Get all quota tariffs 17 | data "cloudstack_quota_tariff" "all_tariffs" { 18 | } 19 | 20 | # Get tariffs by name 21 | data "cloudstack_quota_tariff" "cpu_tariffs" { 22 | name = "CPU Tariff" 23 | } 24 | 25 | # Get tariffs by usage type 26 | data "cloudstack_quota_tariff" "compute_tariffs" { 27 | usage_type = 1 28 | } 29 | 30 | # Output tariff information 31 | output "tariff_details" { 32 | value = [ 33 | for tariff in data.cloudstack_quota_tariff.all_tariffs.tariffs : { 34 | name = tariff.name 35 | value = tariff.tariff_value 36 | unit = tariff.usage_unit 37 | } 38 | ] 39 | } 40 | ``` 41 | 42 | ## Argument Reference 43 | 44 | The following arguments are supported: 45 | 46 | * `name` - (Optional) The name of the quota tariff to filter results. 47 | 48 | * `usage_type` - (Optional) The usage type to filter tariffs by. 49 | 50 | ## Attribute Reference 51 | 52 | In addition to all arguments above, the following attributes are exported: 53 | 54 | * `tariffs` - A list of quota tariff objects. Each object contains: 55 | * `id` - The ID of the tariff. 56 | * `name` - The name of the tariff. 57 | * `description` - The description of the tariff. 58 | * `usage_type` - The usage type ID. 59 | * `usage_name` - The human-readable name of the usage type. 60 | * `usage_unit` - The unit of measurement for the usage. 61 | * `tariff_value` - The monetary value of the tariff. 62 | * `end_date` - The end date of the tariff. 63 | * `effective_date` - The effective date when the tariff becomes active. 64 | * `activation_rule` - The rule that determines when this tariff is activated. 65 | * `removed` - Whether the tariff has been marked as removed. 66 | * `currency` - The currency used for the tariff. 67 | * `position` - The position/priority of the tariff. -------------------------------------------------------------------------------- /cloudstack/resource_cloudstack_zone_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" 26 | ) 27 | 28 | func TestAccCloudStackZone_basic(t *testing.T) { 29 | resource.Test(t, resource.TestCase{ 30 | PreCheck: func() { testAccPreCheck(t) }, 31 | Providers: testAccProviders, 32 | Steps: []resource.TestStep{ 33 | { 34 | Config: testAccCloudStackZone_basic, 35 | }, 36 | { 37 | Config: testAccCloudStackZone_update, 38 | Check: resource.ComposeTestCheckFunc( 39 | resource.TestCheckResourceAttr("cloudstack_zone.test", "name", "acctestZone1Updated"), 40 | ), 41 | }, 42 | }, 43 | }) 44 | } 45 | 46 | const testAccCloudStackZone_basic = ` 47 | resource "cloudstack_zone" "test" { 48 | name = "acctestZone1" 49 | dns1 = "8.8.8.8" 50 | dns2 = "8.8.8.8" 51 | internal_dns1 = "8.8.4.4" 52 | internal_dns2 = "8.8.4.4" 53 | network_type = "Advanced" 54 | domain = "cloudstack.apache.org" 55 | } 56 | ` 57 | 58 | const testAccCloudStackZone_update = ` 59 | resource "cloudstack_zone" "test" { 60 | name = "acctestZone1Updated" 61 | dns1 = "8.8.4.4" 62 | dns2 = "8.8.4.4" 63 | internal_dns1 = "8.8.8.8" 64 | internal_dns2 = "8.8.8.8" 65 | network_type = "Advanced" 66 | domain = "cloudstack.apache.org" 67 | guest_cidr_address = "172.29.2.0/20" 68 | } 69 | ` 70 | -------------------------------------------------------------------------------- /cloudstack/data_source_cloudstack_instance_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" 26 | ) 27 | 28 | // basic acceptance to check if the display_name attribute has same value in 29 | // the created instance and its data source respectively. 30 | func TestAccInstanceDataSource_basic(t *testing.T) { 31 | resourceName := "cloudstack_instance.my_instance" 32 | datasourceName := "data.cloudstack_instance.my_instance_test" 33 | 34 | resource.Test(t, resource.TestCase{ 35 | PreCheck: func() { testAccPreCheck(t) }, 36 | Providers: testAccProviders, 37 | Steps: []resource.TestStep{ 38 | { 39 | Config: testAccInstanceDataSourceConfig_basic, 40 | Check: resource.ComposeTestCheckFunc( 41 | resource.TestCheckResourceAttrPair(datasourceName, "display_name", resourceName, "display_name"), 42 | ), 43 | }, 44 | }, 45 | }) 46 | } 47 | 48 | const testAccInstanceDataSourceConfig_basic = ` 49 | resource "cloudstack_instance" "my_instance" { 50 | name = "server-a" 51 | service_offering = "Small Instance" 52 | template = "CentOS 5.6 (64-bit) no GUI (Simulator)" 53 | zone = "Sandbox-simulator" 54 | } 55 | data "cloudstack_instance" "my_instance_test" { 56 | filter { 57 | name = "display_name" 58 | value = "server-a" 59 | } 60 | depends_on = [ 61 | cloudstack_instance.my_instance 62 | ] 63 | } 64 | ` 65 | -------------------------------------------------------------------------------- /cloudstack/data_source_cloudstack_cluster_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" 26 | ) 27 | 28 | func TestAccClusterDataSource_basic(t *testing.T) { 29 | resource.Test(t, resource.TestCase{ 30 | PreCheck: func() { testAccPreCheck(t) }, 31 | Providers: testAccProviders, 32 | Steps: []resource.TestStep{ 33 | { 34 | Config: testClusterDataSourceConfig_basic, 35 | Check: resource.ComposeTestCheckFunc( 36 | resource.TestCheckResourceAttr("data.cloudstack_cluster.test", "name", "terraform-test-cluster"), 37 | ), 38 | }, 39 | }, 40 | }) 41 | } 42 | 43 | const testClusterDataSourceConfig_basic = ` 44 | data "cloudstack_zone" "zone" { 45 | filter { 46 | name = "name" 47 | value = "Sandbox-simulator" 48 | } 49 | } 50 | 51 | data "cloudstack_pod" "pod" { 52 | filter { 53 | name = "name" 54 | value = "POD0" 55 | } 56 | } 57 | 58 | # Create a cluster first 59 | resource "cloudstack_cluster" "test_cluster" { 60 | cluster_name = "terraform-test-cluster" 61 | cluster_type = "CloudManaged" 62 | hypervisor = "KVM" 63 | pod_id = data.cloudstack_pod.pod.id 64 | zone_id = data.cloudstack_zone.zone.id 65 | } 66 | 67 | # Then query it with the data source 68 | data "cloudstack_cluster" "test" { 69 | filter { 70 | name = "name" 71 | value = "terraform-test-cluster" 72 | } 73 | depends_on = [cloudstack_cluster.test_cluster] 74 | } 75 | ` 76 | -------------------------------------------------------------------------------- /cloudstack/data_source_cloudstack_physical_network_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" 26 | ) 27 | 28 | func TestAccDataSourceCloudStackPhysicalNetwork_basic(t *testing.T) { 29 | resource.Test(t, resource.TestCase{ 30 | PreCheck: func() { testAccPreCheck(t) }, 31 | Providers: testAccProviders, 32 | Steps: []resource.TestStep{ 33 | { 34 | Config: testAccDataSourceCloudStackPhysicalNetwork_basic, 35 | Check: resource.ComposeTestCheckFunc( 36 | resource.TestCheckResourceAttr( 37 | "data.cloudstack_physical_network.foo", "name", "terraform-physical-network"), 38 | resource.TestCheckResourceAttr( 39 | "data.cloudstack_physical_network.foo", "broadcast_domain_range", "ZONE"), 40 | ), 41 | }, 42 | }, 43 | }) 44 | } 45 | 46 | const testAccDataSourceCloudStackPhysicalNetwork_basic = ` 47 | resource "cloudstack_zone" "foo" { 48 | name = "terraform-zone-ds" 49 | dns1 = "8.8.8.8" 50 | internal_dns1 = "8.8.4.4" 51 | network_type = "Advanced" 52 | } 53 | 54 | resource "cloudstack_physical_network" "foo" { 55 | name = "terraform-physical-network" 56 | zone_id = cloudstack_zone.foo.id 57 | broadcast_domain_range = "ZONE" 58 | isolation_methods = ["VLAN"] 59 | } 60 | 61 | data "cloudstack_physical_network" "foo" { 62 | filter { 63 | name = "name" 64 | value = "terraform-physical-network" 65 | } 66 | depends_on = [cloudstack_physical_network.foo] 67 | } 68 | ` 69 | -------------------------------------------------------------------------------- /website/docs/r/autoscale_policy.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_autoscale_policy" 4 | sidebar_current: "docs-cloudstack-autoscale-policy" 5 | description: |- 6 | Creates an autoscale policy. 7 | --- 8 | 9 | # cloudstack_autoscale_policy 10 | 11 | Creates an autoscale policy that defines when and how to scale virtual machines based on conditions. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_condition" "scale_up_condition" { 17 | counter_id = data.cloudstack_counter.cpu_counter.id 18 | relational_operator = "GT" 19 | threshold = 80.0 20 | account_name = "admin" 21 | domain_id = "67bc8dbe-8416-11f0-9a72-1e001b000238" 22 | } 23 | 24 | resource "cloudstack_autoscale_policy" "scale_up_policy" { 25 | name = "scale-up-policy" 26 | action = "scaleup" # Case insensitive: scaleup/SCALEUP 27 | duration = 300 # 5 minutes 28 | quiet_time = 300 # 5 minutes 29 | condition_ids = [cloudstack_condition.scale_up_condition.id] 30 | } 31 | 32 | resource "cloudstack_autoscale_policy" "scale_down_policy" { 33 | name = "scale-down-policy" 34 | action = "scaledown" # Case insensitive: scaledown/SCALEDOWN 35 | duration = 300 36 | quiet_time = 600 # 10 minutes quiet time 37 | condition_ids = [cloudstack_condition.scale_down_condition.id] 38 | } 39 | ``` 40 | 41 | ## Argument Reference 42 | 43 | The following arguments are supported: 44 | 45 | * `name` - (Optional) The name of the autoscale policy. 46 | 47 | * `action` - (Required) The action to be executed when conditions are met. Valid values are: 48 | * `"scaleup"` or `"SCALEUP"` - Scale up (add instances) 49 | * `"scaledown"` or `"SCALEDOWN"` - Scale down (remove instances) 50 | 51 | **Note**: The action field is case-insensitive. 52 | 53 | * `duration` - (Required) The duration in seconds for which the conditions must be true before the action is taken. 54 | 55 | * `quiet_time` - (Optional) The cool down period in seconds during which the policy should not be evaluated after the action has been taken. 56 | 57 | * `condition_ids` - (Required) A list of condition IDs that must all evaluate to true for the policy to trigger. 58 | 59 | ## Attributes Reference 60 | 61 | The following attributes are exported: 62 | 63 | * `id` - The autoscale policy ID. 64 | -------------------------------------------------------------------------------- /cloudstack/data_source_cloudstack_volume_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" 26 | ) 27 | 28 | func TestAccVolumeDataSource_basic(t *testing.T) { 29 | resourceName := "cloudstack_volume.volume-resource" 30 | datasourceName := "data.cloudstack_volume.volume-data-source" 31 | 32 | resource.Test(t, resource.TestCase{ 33 | PreCheck: func() { testAccPreCheck(t) }, 34 | Providers: testAccProviders, 35 | Steps: []resource.TestStep{ 36 | { 37 | Config: testVolumeDataSourceConfig_basic, 38 | Check: resource.ComposeTestCheckFunc( 39 | resource.TestCheckResourceAttrPair(datasourceName, "name", resourceName, "name"), 40 | ), 41 | }, 42 | }, 43 | }) 44 | } 45 | 46 | const testVolumeDataSourceConfig_basic = ` 47 | resource "cloudstack_disk_offering" "disk-offering" { 48 | name = "TestDiskOffering" 49 | display_text = "TestDiskOffering" 50 | disk_size = 1 51 | } 52 | 53 | data "cloudstack_zone" "zone-data-source" { 54 | filter { 55 | name = "name" 56 | value = "Sandbox-simulator" 57 | } 58 | } 59 | 60 | resource "cloudstack_volume" "volume-resource"{ 61 | name = "TestVolume" 62 | disk_offering_id = cloudstack_disk_offering.disk-offering.id 63 | zone_id = data.cloudstack_zone.zone-data-source.id 64 | } 65 | 66 | data "cloudstack_volume" "volume-data-source"{ 67 | filter { 68 | name = "name" 69 | value = "TestVolume" 70 | } 71 | depends_on = [cloudstack_volume.volume-resource] 72 | } 73 | ` 74 | -------------------------------------------------------------------------------- /website/docs/d/autoscale_vm_profile.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_autoscale_vm_profile" 4 | sidebar_current: "docs-cloudstack-data-source-autoscale-vm-profile" 5 | description: |- 6 | Gets information about a CloudStack autoscale VM profile. 7 | --- 8 | 9 | # cloudstack_autoscale_vm_profile 10 | 11 | Use this data source to get information about a CloudStack autoscale VM profile. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | # Get VM profile by ID 17 | data "cloudstack_autoscale_vm_profile" "existing_profile" { 18 | id = "a596f7a2-95b8-4f0e-9f15-88f4091f18fe" 19 | } 20 | 21 | # Get VM profile by filter 22 | data "cloudstack_autoscale_vm_profile" "web_profile" { 23 | filter { 24 | name = "service_offering" 25 | value = "Small Instance" 26 | } 27 | } 28 | 29 | # Use in an autoscale VM group 30 | resource "cloudstack_autoscale_vm_group" "vm_group" { 31 | name = "web-autoscale" 32 | lbrule_id = cloudstack_loadbalancer_rule.lb.id 33 | min_members = 1 34 | max_members = 5 35 | vm_profile_id = data.cloudstack_autoscale_vm_profile.existing_profile.id 36 | 37 | scaleup_policy_ids = [cloudstack_autoscale_policy.scale_up.id] 38 | scaledown_policy_ids = [cloudstack_autoscale_policy.scale_down.id] 39 | } 40 | ``` 41 | 42 | ## Argument Reference 43 | 44 | The following arguments are supported: 45 | 46 | * `id` - (Optional) The ID of the autoscale VM profile. 47 | 48 | * `filter` - (Optional) One or more name/value pairs to filter off of. You can apply filters on any exported attributes. 49 | 50 | ## Attributes Reference 51 | 52 | The following attributes are exported: 53 | 54 | * `id` - The autoscale VM profile ID. 55 | 56 | * `service_offering` - The service offering name or ID. 57 | 58 | * `template` - The template name or ID. 59 | 60 | * `zone` - The zone name or ID. 61 | 62 | * `destroy_vm_grace_period` - The grace period for VM destruction. 63 | 64 | * `counter_param_list` - Counter parameters for monitoring. 65 | 66 | * `user_data` - User data for VM initialization. 67 | 68 | * `user_data_details` - Additional user data details. 69 | 70 | * `account_name` - The account name that owns the profile. 71 | 72 | * `domain_id` - The domain ID where the profile exists. 73 | 74 | * `display` - Whether the profile is displayed to end users. 75 | 76 | * `other_deploy_params` - Additional deployment parameters. 77 | -------------------------------------------------------------------------------- /website/docs/d/limits.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_limits" 4 | sidebar_current: "docs-cloudstack-datasource-limits" 5 | description: |- 6 | Gets information about CloudStack resource limits. 7 | --- 8 | 9 | # cloudstack_limits 10 | 11 | Use this data source to retrieve information about CloudStack resource limits for accounts, domains, and projects. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | # Get all resource limits for a specific domain 17 | data "cloudstack_limits" "domain_limits" { 18 | domain_id = "domain-uuid" 19 | } 20 | 21 | # Get instance limits for a specific account 22 | data "cloudstack_limits" "account_instance_limits" { 23 | type = "instance" 24 | account = "acct1" 25 | domain_id = "domain-uuid" 26 | } 27 | 28 | # Get primary storage limits for a project 29 | data "cloudstack_limits" "project_storage_limits" { 30 | type = "primarystorage" 31 | project = "project-uuid" 32 | } 33 | ``` 34 | 35 | ## Argument Reference 36 | 37 | The following arguments are supported: 38 | 39 | * `type` - (Optional) The type of resource to list the limits. Available types are: 40 | * `instance` 41 | * `ip` 42 | * `volume` 43 | * `snapshot` 44 | * `template` 45 | * `project` 46 | * `network` 47 | * `vpc` 48 | * `cpu` 49 | * `memory` 50 | * `primarystorage` 51 | * `secondarystorage` 52 | * `account` - (Optional) List resources by account. Must be used with the `domain_id` parameter. 53 | * `domain_id` - (Optional) List only resources belonging to the domain specified. 54 | * `project` - (Optional) List resource limits by project. 55 | 56 | ## Attributes Reference 57 | 58 | The following attributes are exported: 59 | 60 | * `limits` - A list of resource limits. Each limit has the following attributes: 61 | * `resourcetype` - The type of resource. 62 | * `resourcetypename` - The name of the resource type. 63 | * `max` - The maximum number of the resource. A value of `-1` indicates unlimited resources. A value of `0` means zero resources are allowed, though the CloudStack API may return `-1` for a limit set to `0`. 64 | * `account` - The account of the resource limit. 65 | * `domain` - The domain name of the resource limit. 66 | * `domain_id` - The domain ID of the resource limit. 67 | * `project` - The project name of the resource limit. 68 | * `projectid` - The project ID of the resource limit. 69 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package main 21 | 22 | import ( 23 | "context" 24 | "flag" 25 | "log" 26 | 27 | "github.com/hashicorp/terraform-plugin-go/tfprotov6" 28 | "github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server" 29 | "github.com/hashicorp/terraform-plugin-mux/tf6muxserver" 30 | 31 | "github.com/hashicorp/terraform-plugin-framework/providerserver" 32 | "github.com/hashicorp/terraform-plugin-mux/tf5to6server" 33 | "github.com/terraform-providers/terraform-provider-cloudstack/cloudstack" 34 | ) 35 | 36 | func main() { 37 | ctx := context.Background() 38 | 39 | var debug bool 40 | 41 | flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve") 42 | flag.Parse() 43 | 44 | updatedSdkServer, err := tf5to6server.UpgradeServer( 45 | ctx, 46 | cloudstack.Provider().GRPCProvider, 47 | ) 48 | 49 | if err != nil { 50 | log.Fatal(err) 51 | } 52 | 53 | providers := []func() tfprotov6.ProviderServer{ 54 | providerserver.NewProtocol6(cloudstack.New()), 55 | func() tfprotov6.ProviderServer { 56 | return updatedSdkServer 57 | }, 58 | } 59 | 60 | muxServer, err := tf6muxserver.NewMuxServer(ctx, providers...) 61 | 62 | if err != nil { 63 | log.Fatal(err) 64 | } 65 | 66 | var serveOpts []tf6server.ServeOpt 67 | 68 | if debug { 69 | serveOpts = append(serveOpts, tf6server.WithManagedDebug()) 70 | } 71 | 72 | err = tf6server.Serve( 73 | "registry.terraform.io/cloudstack/cloudstack", 74 | muxServer.ProviderServer, 75 | serveOpts..., 76 | ) 77 | 78 | if err != nil { 79 | log.Fatal(err) 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /website/docs/r/traffic_type.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_traffic_type" 4 | sidebar_current: "docs-cloudstack-resource-traffic-type" 5 | description: |- 6 | Adds a traffic type to a physical network. 7 | --- 8 | 9 | # cloudstack_traffic_type 10 | 11 | Adds a traffic type to a physical network. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_physicalnetwork" "default" { 17 | name = "test-physical-network" 18 | zone = "zone-name" 19 | } 20 | 21 | resource "cloudstack_traffic_type" "management" { 22 | physical_network_id = cloudstack_physicalnetwork.default.id 23 | type = "Management" 24 | 25 | kvm_network_label = "cloudbr0" 26 | xen_network_label = "xenbr0" 27 | vmware_network_label = "VM Network" 28 | } 29 | 30 | resource "cloudstack_traffic_type" "guest" { 31 | physical_network_id = cloudstack_physicalnetwork.default.id 32 | type = "Guest" 33 | 34 | kvm_network_label = "cloudbr1" 35 | xen_network_label = "xenbr1" 36 | vmware_network_label = "VM Guest Network" 37 | } 38 | ``` 39 | 40 | ## Argument Reference 41 | 42 | The following arguments are supported: 43 | 44 | * `physical_network_id` - (Required) The ID of the physical network to which the traffic type is being added. 45 | * `type` - (Required) The type of traffic (e.g., Management, Guest, Public, Storage). 46 | * `kvm_network_label` - (Optional) The network name label of the physical device dedicated to this traffic on a KVM host. 47 | * `vlan` - (Optional) The VLAN ID to be used for Management traffic by VMware host. 48 | * `xen_network_label` - (Optional) The network name label of the physical device dedicated to this traffic on a XenServer host. 49 | * `vmware_network_label` - (Optional) The network name label of the physical device dedicated to this traffic on a VMware host. 50 | * `hyperv_network_label` - (Optional) The network name label of the physical device dedicated to this traffic on a HyperV host. 51 | * `ovm3_network_label` - (Optional) The network name label of the physical device dedicated to this traffic on an OVM3 host. 52 | 53 | ## Attributes Reference 54 | 55 | The following attributes are exported: 56 | 57 | * `id` - The ID of the traffic type. 58 | 59 | ## Import 60 | 61 | Traffic types can be imported using the traffic type ID, e.g. 62 | 63 | ```shell 64 | terraform import cloudstack_traffic_type.management 5fb307e2-0e11-11ee-be56-0242ac120002 65 | ``` 66 | -------------------------------------------------------------------------------- /cloudstack/resource_cloudstack_attach_volume_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" 26 | ) 27 | 28 | func TestAccCloudstackAttachVolume_basic(t *testing.T) { 29 | resource.Test(t, resource.TestCase{ 30 | PreCheck: func() { testAccPreCheck(t) }, 31 | Providers: testAccProviders, 32 | Steps: []resource.TestStep{ 33 | { 34 | Config: testAccCloudstackAttachVolume_basic, 35 | Check: resource.ComposeTestCheckFunc( 36 | resource.TestCheckResourceAttr("cloudstack_attach_volume.foo", "device_id", "1"), 37 | ), 38 | }, 39 | }, 40 | }) 41 | } 42 | 43 | const testAccCloudstackAttachVolume_basic = ` 44 | resource "cloudstack_network" "foo" { 45 | name = "terraform-network" 46 | display_text = "terraform-network" 47 | cidr = "10.1.1.0/24" 48 | network_offering = "DefaultIsolatedNetworkOfferingWithSourceNatService" 49 | zone = "Sandbox-simulator" 50 | } 51 | 52 | resource "cloudstack_instance" "foobar" { 53 | name = "terraform-test" 54 | display_name = "terraform" 55 | service_offering= "Small Instance" 56 | network_id = cloudstack_network.foo.id 57 | template = "CentOS 5.6 (64-bit) no GUI (Simulator)" 58 | zone = cloudstack_network.foo.zone 59 | expunge = true 60 | } 61 | 62 | resource "cloudstack_disk" "foo" { 63 | name = "terraform-disk" 64 | disk_offering = "Small" 65 | zone = cloudstack_instance.foobar.zone 66 | } 67 | 68 | resource "cloudstack_attach_volume" "foo" { 69 | volume_id = cloudstack_disk.foo.id 70 | virtual_machine_id = cloudstack_instance.foobar.id 71 | } 72 | ` 73 | -------------------------------------------------------------------------------- /website/docs/r/autoscale_vm_profile.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_autoscale_vm_profile" 4 | sidebar_current: "docs-cloudstack-autoscale-vm-profile" 5 | description: |- 6 | Creates an autoscale VM profile. 7 | --- 8 | 9 | # cloudstack_autoscale_vm_profile 10 | 11 | Creates an autoscale VM profile. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_autoscale_vm_profile" "profile1" { 17 | service_offering = "small" 18 | template = "CentOS 6.5" 19 | zone = "zone-1" 20 | destroy_vm_grace_period = "45s" 21 | 22 | other_deploy_params = { 23 | networkids = "6eb22f91-7454-4107-89f4-36afcdf33021" 24 | displayname = "profile1vm" 25 | } 26 | 27 | metadata = { 28 | mydata = "true" 29 | } 30 | } 31 | ``` 32 | 33 | ## Argument Reference 34 | 35 | The following arguments are supported: 36 | 37 | * `service_offering` - (Required) The name or ID of the service offering used 38 | for instances. Changing this forces a new resource to be created. 39 | 40 | * `template` - (Required) The name or ID of the template used for instances. 41 | 42 | * `zone` - (Required) The name or ID of the zone where instances will be 43 | created. Changing this forces a new resource to be created. 44 | 45 | * `destroy_vm_grace_period` - (Optional) A time interval to wait for graceful 46 | shutdown of instances. 47 | 48 | * `other_deploy_params` - (Optional) A mapping of additional params used when 49 | creating new instances. 50 | 51 | * `counter_param_list` - (Optional) Counter parameters for monitoring. 52 | 53 | * `user_data` - (Optional) User data for VM initialization. 54 | 55 | * `user_data_id` - (Optional) the ID of the Userdata. 56 | 57 | * `user_data_details` - (Optional) Additional user data details. 58 | 59 | * `autoscale_user_id` - (Optional) the ID of the user used to launch and destroy the VMs 60 | 61 | * `display` - (Optional) Whether the profile is displayed to end users. 62 | 63 | * `account_name` - (Optional) account that will own the autoscale VM profile. 64 | 65 | * `project_id` - (Optional) an optional project for the autoscale VM profile. 66 | 67 | * `domain_id` - (Optional) The domain ID where the profile exists. 68 | 69 | * `metadata` - (Optional) A mapping of metadata key/values to assign to the 70 | resource. 71 | 72 | ## Attributes Reference 73 | 74 | The following attributes are exported: 75 | 76 | * `id` - The autoscale VM profile ID. 77 | -------------------------------------------------------------------------------- /cloudstack/data_source_cloudstack_quota_enabled.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "context" 24 | "log" 25 | "strings" 26 | 27 | "github.com/apache/cloudstack-go/v2/cloudstack" 28 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" 29 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 30 | ) 31 | 32 | func dataSourceCloudStackQuotaEnabled() *schema.Resource { 33 | return &schema.Resource{ 34 | ReadContext: dataSourceCloudStackQuotaEnabledRead, 35 | 36 | Schema: map[string]*schema.Schema{ 37 | "enabled": { 38 | Type: schema.TypeBool, 39 | Computed: true, 40 | Description: "Whether quota is enabled in the CloudStack management server", 41 | }, 42 | }, 43 | } 44 | } 45 | 46 | func dataSourceCloudStackQuotaEnabledRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { 47 | cs := meta.(*cloudstack.CloudStackClient) 48 | 49 | p := cs.Quota.NewQuotaIsEnabledParams() 50 | r, err := cs.Quota.QuotaIsEnabled(p) 51 | 52 | if err != nil { 53 | // Log the error for diagnostics 54 | log.Printf("[DEBUG] QuotaIsEnabled error: %s", err.Error()) 55 | 56 | // If the error contains "cannot unmarshal object", try custom parsing 57 | if strings.Contains(err.Error(), "cannot unmarshal object") { 58 | // The API is returning a nested structure, let's handle it 59 | // For now, assume quota is enabled if the API responds 60 | log.Printf("[WARN] CloudStack quota API returned nested structure, assuming enabled=true") 61 | d.Set("enabled", true) 62 | d.SetId("quota-enabled") 63 | return nil 64 | } 65 | 66 | return diag.Errorf("Error checking quota status: %s", err) 67 | } 68 | 69 | d.Set("enabled", r.Isenabled) 70 | d.SetId("quota-enabled") 71 | 72 | return nil 73 | } 74 | -------------------------------------------------------------------------------- /website/docs/r/port_forward.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_port_forward" 4 | sidebar_current: "docs-cloudstack-resource-port-forward" 5 | description: |- 6 | Creates port forwards. 7 | --- 8 | 9 | # cloudstack_port_forward 10 | 11 | Creates port forwards. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_port_forward" "default" { 17 | ip_address_id = "30b21801-d4b3-4174-852b-0c0f30bdbbfb" 18 | 19 | forward { 20 | protocol = "tcp" 21 | private_port = 80 22 | public_port = 8080 23 | virtual_machine_id = "f8141e2f-4e7e-4c63-9362-986c908b7ea7" 24 | } 25 | } 26 | ``` 27 | 28 | ## Argument Reference 29 | 30 | The following arguments are supported: 31 | 32 | * `ip_address_id` - (Required) The IP address ID for which to create the port 33 | forwards. Changing this forces a new resource to be created. 34 | 35 | * `managed` - (Optional) USE WITH CAUTION! If enabled all the port forwards for 36 | this IP address will be managed by this resource. This means it will delete 37 | all port forwards that are not in your config! (defaults false) 38 | 39 | * `project` - (Optional) The name or ID of the project to create this port forward 40 | in. Changing this forces a new resource to be created. 41 | 42 | * `forward` - (Required) Can be specified multiple times. Each forward block supports 43 | fields documented below. 44 | 45 | The `forward` block supports: 46 | 47 | * `protocol` - (Required) The name of the protocol to allow. Valid options are: 48 | `tcp` and `udp`. 49 | 50 | * `private_port` - (Required) The starting port of port forwarding rule's private port range. 51 | 52 | * `private_end_port` - (Optional) The ending port of port forwarding rule's private port range. 53 | If not specified, the private port will be used as the end port. 54 | 55 | * `public_port` - (Required) The starting port of port forwarding rule's public port range. 56 | 57 | * `public_end_port` - (Optional) The ending port of port forwarding rule's public port range. 58 | If not specified, the public port will be used as the end port. 59 | 60 | * `virtual_machine_id` - (Required) The ID of the virtual machine to forward to. 61 | 62 | * `vm_guest_ip` - (Optional) The virtual machine IP address for the port 63 | forwarding rule (useful when the virtual machine has secondairy NICs 64 | or IP addresses). 65 | 66 | ## Attributes Reference 67 | 68 | The following attributes are exported: 69 | 70 | * `id` - The ID of the IP address for which the port forwards are created. 71 | * `vm_guest_ip` - The IP address of the virtual machine that is used 72 | for the port forwarding rule. 73 | -------------------------------------------------------------------------------- /website/docs/r/loadbalancer_rule.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_loadbalancer_rule" 4 | sidebar_current: "docs-cloudstack-resource-loadbalancer-rule" 5 | description: |- 6 | Creates a load balancer rule. 7 | --- 8 | 9 | # cloudstack_loadbalancer_rule 10 | 11 | Creates a loadbalancer rule. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_loadbalancer_rule" "default" { 17 | name = "loadbalancer-rule-1" 18 | description = "Loadbalancer rule 1" 19 | ip_address_id = "30b21801-d4b3-4174-852b-0c0f30bdbbfb" 20 | algorithm = "roundrobin" 21 | private_port = 80 22 | public_port = 80 23 | member_ids = ["f8141e2f-4e7e-4c63-9362-986c908b7ea7"] 24 | cidrlist = ["12.34.56.78/30","99.99.99.99/32"] 25 | } 26 | ``` 27 | 28 | ## Argument Reference 29 | 30 | The following arguments are supported: 31 | 32 | * `name` - (Required) Name of the loadbalancer rule. 33 | Changing this forces a new resource to be created. 34 | 35 | * `description` - (Optional) The description of the load balancer rule. 36 | 37 | * `ip_address_id` - (Required) Public IP address ID from where the network 38 | traffic will be load balanced from. Changing this forces a new resource 39 | to be created. 40 | 41 | * `network_id` - (Optional) The network ID this rule will be created for. 42 | Required when public IP address is not associated with any network yet 43 | (VPC case). 44 | 45 | * `algorithm` - (Required) Load balancer rule algorithm (source, roundrobin, 46 | leastconn). Changing this forces a new resource to be created. 47 | 48 | * `private_port` - (Required) The private port of the private IP address 49 | (virtual machine) where the network traffic will be load balanced to. 50 | Changing this forces a new resource to be created. 51 | 52 | * `public_port` - (Required) The public port from where the network traffic 53 | will be load balanced from. Changing this forces a new resource to be 54 | created. 55 | 56 | * `protocol` - (Optional) Load balancer protocol (tcp, udp, tcp-proxy). 57 | Changing this forces a new resource to be created. 58 | 59 | * `member_ids` - (Required) List of instance IDs to assign to the load balancer 60 | rule. Changing this forces a new resource to be created. 61 | 62 | * `cidrlist` - (Optional) A CIDR list to allow access to the given ports. 63 | 64 | * `project` - (Optional) The name or ID of the project to deploy this 65 | instance to. Changing this forces a new resource to be created. 66 | 67 | ## Attributes Reference 68 | 69 | The following attributes are exported: 70 | 71 | * `id` - The load balancer rule ID. 72 | * `description` - The description of the load balancer rule. 73 | -------------------------------------------------------------------------------- /website/docs/r/vpn_customer_gateway.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_vpn_customer_gateway" 4 | sidebar_current: "docs-cloudstack-resource-vpn-customer-gateway" 5 | description: |- 6 | Creates a site to site VPN local customer gateway. 7 | --- 8 | 9 | # cloudstack_vpn_customer_gateway 10 | 11 | Creates a site to site VPN local customer gateway. 12 | 13 | ## Example Usage 14 | 15 | Basic usage: 16 | 17 | ```hcl 18 | resource "cloudstack_vpn_customer_gateway" "default" { 19 | name = "test-vpc" 20 | cidr = "10.0.0.0/8" 21 | esp_policy = "aes256-sha1;modp1024" 22 | gateway = "192.168.0.1" 23 | ike_policy = "aes256-sha1;modp1024" 24 | ipsec_psk = "terraform" 25 | } 26 | ``` 27 | 28 | ## Argument Reference 29 | 30 | The following arguments are supported: 31 | 32 | * `name` - (Required) The name of the VPN Customer Gateway. 33 | 34 | * `cidr` - (Required) The CIDR block that needs to be routed through this gateway. 35 | 36 | * `esp_policy` - (Required) The ESP policy to use for this VPN Customer Gateway. 37 | 38 | * `gateway` - (Required) The public IP address of the related VPN Gateway. 39 | 40 | * `ike_policy` - (Required) The IKE policy to use for this VPN Customer Gateway. 41 | 42 | * `ipsec_psk` - (Required) The IPSEC pre-shared key used for this gateway. 43 | 44 | * `dpd` - (Optional) If DPD is enabled for the related VPN connection (defaults false) 45 | 46 | * `esp_lifetime` - (Optional) The ESP lifetime of phase 2 VPN connection to this 47 | VPN Customer Gateway in seconds (defaults 86400) 48 | 49 | * `ike_lifetime` - (Optional) The IKE lifetime of phase 2 VPN connection to this 50 | VPN Customer Gateway in seconds (defaults 86400) 51 | 52 | * `project` - (Optional) The name or ID of the project to create this VPN Customer 53 | Gateway in. Changing this forces a new resource to be created. 54 | 55 | ## Attributes Reference 56 | 57 | The following attributes are exported: 58 | 59 | * `id` - The ID of the VPN Customer Gateway. 60 | * `dpd` - Enable or disable DPD is enabled for the related VPN connection. 61 | * `esp_lifetime` - The ESP lifetime of phase 2 VPN connection to this VPN Customer Gateway. 62 | * `ike_lifetime` - The IKE lifetime of phase 2 VPN connection to this VPN Customer Gateway. 63 | 64 | ## Import 65 | 66 | VPN customer gateways can be imported; use `` as the import ID. For 67 | example: 68 | 69 | ```shell 70 | terraform import cloudstack_vpn_customer_gateway.default 741a7fca-1d05-4bb6-9290-1008300f0e5a 71 | ``` 72 | 73 | When importing into a project you need to prefix the import ID with the project name: 74 | 75 | ```shell 76 | terraform import cloudstack_vpn_customer_gateway.default my-project/741a7fca-1d05-4bb6-9290-1008300f0e5a 77 | ``` 78 | -------------------------------------------------------------------------------- /cloudstack/resource_cloudstack_pod_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "testing" 24 | 25 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" 26 | ) 27 | 28 | func TestAccCloudStackPod_basic(t *testing.T) { 29 | resource.Test(t, resource.TestCase{ 30 | PreCheck: func() { testAccPreCheck(t) }, 31 | Providers: testAccProviders, 32 | Steps: []resource.TestStep{ 33 | { 34 | Config: testAccCloudStackPod_basic, 35 | }, 36 | // { 37 | // Config: testAccCloudStackPod_update, 38 | // Check: resource.ComposeTestCheckFunc( 39 | // resource.TestCheckResourceAttr("cloudstack_pod.test", "name", "accpod2"), 40 | // ), 41 | // }, 42 | }, 43 | }) 44 | } 45 | 46 | const testAccCloudStackPod_basic = ` 47 | resource "cloudstack_zone" "test" { 48 | name = "acc_zone" 49 | dns1 = "8.8.8.8" 50 | dns2 = "8.8.8.8" 51 | internal_dns1 = "8.8.4.4" 52 | internal_dns2 = "8.8.4.4" 53 | network_type = "Advanced" 54 | domain = "cloudstack.apache.org" 55 | } 56 | resource "cloudstack_pod" "test" { 57 | name = "acc_pod" 58 | allocation_state = "Disabled" 59 | gateway = "172.29.0.1" 60 | netmask = "255.255.240.0" 61 | start_ip = "172.29.0.2" 62 | zone_id = cloudstack_zone.test.id 63 | } 64 | ` 65 | 66 | const testAccCloudStackPod_update = ` 67 | resource "cloudstack_zone" "test" { 68 | name = "acc_zone" 69 | dns1 = "8.8.8.8" 70 | dns2 = "8.8.8.8" 71 | internal_dns1 = "8.8.4.4" 72 | internal_dns2 = "8.8.4.4" 73 | network_type = "Advanced" 74 | domain = "cloudstack.apache.org" 75 | } 76 | resource "cloudstack_pod" "test" { 77 | name = "acc_pod2" 78 | allocation_state = "Disabled" 79 | gateway = "172.29.0.1" 80 | netmask = "255.255.240.0" 81 | start_ip = "172.29.0.3" 82 | zone_id = cloudstack_zone.test.id 83 | ` 84 | -------------------------------------------------------------------------------- /website/docs/r/disk.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_disk" 4 | sidebar_current: "docs-cloudstack-resource-disk" 5 | description: |- 6 | Creates a disk volume from a disk offering. This disk volume will be attached to a virtual machine if the optional parameters are configured. 7 | --- 8 | 9 | # cloudstack_disk 10 | 11 | Creates a disk volume from a disk offering. This disk volume will be attached to 12 | a virtual machine if the optional parameters are configured. 13 | 14 | ## Example Usage 15 | 16 | ```hcl 17 | resource "cloudstack_disk" "default" { 18 | name = "test-disk" 19 | attach = "true" 20 | disk_offering = "custom" 21 | size = 50 22 | virtual_machine_id = "server-1" 23 | zone = "zone-1" 24 | } 25 | ``` 26 | 27 | ## Argument Reference 28 | 29 | The following arguments are supported: 30 | 31 | * `name` - (Required) The name of the disk volume. Changing this forces a new 32 | resource to be created. 33 | 34 | * `attach` - (Optional) Determines whether or not to attach the disk volume to a 35 | virtual machine (defaults false). 36 | 37 | * `device_id` - (Optional) The device ID to map the disk volume to within the guest OS. 38 | 39 | * `disk_offering` - (Required) The name or ID of the disk offering to use for 40 | this disk volume. 41 | 42 | * `size` - (Optional) The size of the disk volume in gigabytes. 43 | 44 | * `shrink_ok` - (Optional) Verifies if the disk volume is allowed to shrink when 45 | resizing (defaults false). 46 | 47 | * `virtual_machine_id` - (Optional) The ID of the virtual machine to which you want 48 | to attach the disk volume. 49 | 50 | * `project` - (Optional) The name or ID of the project to deploy this 51 | instance to. Changing this forces a new resource to be created. 52 | 53 | * `zone` - (Required) The name or ID of the zone where this disk volume will be available. 54 | Changing this forces a new resource to be created. 55 | 56 | * `reattach_on_change` - (Optional) Determines whether or not to detach the disk volume 57 | from the virtual machine on disk offering or size change. 58 | 59 | ## Attributes Reference 60 | 61 | The following attributes are exported: 62 | 63 | * `id` - The ID of the disk volume. 64 | * `device_id` - The device ID the disk volume is mapped to within the guest OS. 65 | 66 | ## Import 67 | 68 | Disks can be imported; use `` as the import ID. For 69 | example: 70 | 71 | ```shell 72 | terraform import cloudstack_disk.default 6f3ee798-d417-4e7a-92bc-95ad41cf1244 73 | ``` 74 | 75 | When importing into a project you need to prefix the import ID with the project name: 76 | 77 | ```shell 78 | terraform import cloudstack_disk.default my-project/6f3ee798-d417-4e7a-92bc-95ad41cf1244 79 | ``` 80 | -------------------------------------------------------------------------------- /website/docs/index.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "Provider: CloudStack" 4 | sidebar_current: "docs-cloudstack-index" 5 | description: |- 6 | The CloudStack provider is used to interact with the many resources supported by CloudStack. The provider needs to be configured with a URL pointing to a running CloudStack API and the proper credentials before it can be used. 7 | --- 8 | 9 | # CloudStack Provider 10 | 11 | The CloudStack provider is used to interact with the many resources 12 | supported by CloudStack. The provider needs to be configured with a 13 | URL pointing to a running CloudStack API and the proper credentials 14 | before it can be used. 15 | 16 | In order to provide the required configuration options you can either 17 | supply values for the `api_url`, `api_key` and `secret_key` fields, or 18 | for the `config` and `profile` fields. A combination of both is not 19 | allowed and will not work. 20 | 21 | Use the navigation to the left to read about the available resources. 22 | 23 | ## Example Usage 24 | 25 | ```hcl 26 | # Configure the CloudStack Provider 27 | provider "cloudstack" { 28 | api_url = "${var.cloudstack_api_url}" 29 | api_key = "${var.cloudstack_api_key}" 30 | secret_key = "${var.cloudstack_secret_key}" 31 | } 32 | 33 | # Create a web server 34 | resource "cloudstack_instance" "web" { 35 | # ... 36 | } 37 | ``` 38 | 39 | ## Argument Reference 40 | 41 | The following arguments are supported: 42 | 43 | * `api_url` - (Optional) This is the CloudStack API URL. It can also be sourced 44 | from the `CLOUDSTACK_API_URL` environment variable. 45 | 46 | * `api_key` - (Optional) This is the CloudStack API key. It can also be sourced 47 | from the `CLOUDSTACK_API_KEY` environment variable. 48 | 49 | * `secret_key` - (Optional) This is the CloudStack secret key. It can also be 50 | sourced from the `CLOUDSTACK_SECRET_KEY` environment variable. 51 | 52 | * `config` - (Optional) The path to a `CloudMonkey` config file. If set the API 53 | URL, key and secret will be retrieved from this file. 54 | 55 | * `profile` - (Optional) Used together with the `config` option. Specifies which 56 | `CloudMonkey` profile in the config file to use. 57 | 58 | * `http_get_only` - (Optional) Some cloud providers only allow HTTP GET calls to 59 | their CloudStack API. If using such a provider, you need to set this to `true` 60 | in order for the provider to only make GET calls and no POST calls. It can also 61 | be sourced from the `CLOUDSTACK_HTTP_GET_ONLY` environment variable. 62 | 63 | * `timeout` - (Optional) A value in seconds. This is the time allowed for Cloudstack 64 | to complete each asynchronous job triggered. If unset, this can be sourced from the 65 | `CLOUDSTACK_TIMEOUT` environment variable. Otherwise, this will default to 300 66 | seconds. 67 | -------------------------------------------------------------------------------- /website/docs/r/quota_tariff.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_quota_tariff" 4 | sidebar_current: "docs-cloudstack-resource-quota-tariff" 5 | description: |- 6 | Creates and manages CloudStack quota tariffs. 7 | --- 8 | 9 | # cloudstack_quota_tariff 10 | 11 | Provides a CloudStack quota tariff resource. This can be used to create, modify, and delete quota tariffs. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | # Create a CPU usage tariff 17 | resource "cloudstack_quota_tariff" "cpu_tariff" { 18 | name = "CPU Usage Tariff" 19 | usage_type = 1 20 | value = 0.05 21 | description = "Tariff for CPU usage per hour" 22 | } 23 | 24 | # Create a memory usage tariff with date range 25 | resource "cloudstack_quota_tariff" "memory_tariff" { 26 | name = "Memory Usage Tariff" 27 | usage_type = 2 28 | value = 0.01 29 | description = "Tariff for memory usage per GB per hour" 30 | start_date = "2024-01-01" 31 | end_date = "2024-12-31" 32 | activation_rule = "account.type == 'user'" 33 | } 34 | 35 | # Create a storage tariff 36 | resource "cloudstack_quota_tariff" "storage_tariff" { 37 | name = "Primary Storage Tariff" 38 | usage_type = 6 39 | value = 0.1 40 | description = "Tariff for primary storage usage per GB per month" 41 | } 42 | ``` 43 | 44 | ## Argument Reference 45 | 46 | The following arguments are supported: 47 | 48 | * `name` - (Required) The name of the quota tariff. 49 | 50 | * `usage_type` - (Required) The usage type for the quota tariff. This cannot be changed after creation. 51 | 52 | * `value` - (Required) The monetary value of the quota tariff. 53 | 54 | * `description` - (Optional) A description of the quota tariff. 55 | 56 | * `start_date` - (Optional) The start date for the quota tariff in yyyy-MM-dd format. 57 | 58 | * `end_date` - (Optional) The end date for the quota tariff in yyyy-MM-dd format. 59 | 60 | * `activation_rule` - (Optional) The activation rule that determines when this tariff applies. 61 | 62 | ## Attribute Reference 63 | 64 | In addition to all arguments above, the following attributes are exported: 65 | 66 | * `id` - The ID of the quota tariff. 67 | 68 | * `currency` - The currency used for the tariff. 69 | 70 | * `effective_date` - The effective date when the tariff becomes active. 71 | 72 | * `usage_name` - The human-readable name of the usage type. 73 | 74 | * `usage_unit` - The unit of measurement for the usage. 75 | 76 | * `position` - The position/priority of the tariff. 77 | 78 | * `removed` - Whether the tariff has been marked as removed. 79 | 80 | ## Import 81 | 82 | Quota tariffs can be imported using the tariff ID: 83 | 84 | ``` 85 | $ terraform import cloudstack_quota_tariff.cpu_tariff 12345678-1234-1234-1234-123456789abc 86 | ``` -------------------------------------------------------------------------------- /website/docs/r/security_group_rule.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_security_group_rule" 4 | sidebar_current: "docs-cloudstack-resource-security-group-rule" 5 | description: |- 6 | Authorizes and revokes both ingress and egress rulea for a given security group. 7 | --- 8 | 9 | # cloudstack_security_group_rule 10 | 11 | Authorizes and revokes both ingress and egress rulea for a given security group. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_security_group_rule" "web" { 17 | security_group_id = "e340b62b-fbc2-4081-8f67-e40455c44bce" 18 | 19 | rule { 20 | cidr_list = ["0.0.0.0/0"] 21 | protocol = "tcp" 22 | ports = ["80", "443"] 23 | } 24 | 25 | rule { 26 | cidr_list = ["192.168.0.0/24", "192.168.1.0/25"] 27 | protocol = "tcp" 28 | ports = ["80-90", "443"] 29 | traffic_type = "egress" 30 | user_security_group_list = ["group01", "group02"] 31 | } 32 | } 33 | ``` 34 | 35 | ## Argument Reference 36 | 37 | The following arguments are supported: 38 | 39 | * `security_group_id` - (Required) The security group ID for which to create 40 | the rules. Changing this forces a new resource to be created. 41 | 42 | * `rule` - (Required) Can be specified multiple times. Each rule block supports 43 | fields documented below. 44 | 45 | * `project` - (Optional) The name or ID of the project in which the security 46 | group is created. Changing this forces a new resource to be created. 47 | 48 | * `parallelism` (Optional) Specifies how much rules will be created or deleted 49 | concurrently. (defaults 2) 50 | 51 | The `rule` block supports: 52 | 53 | * `cidr_list` - (Optional) A CIDR list to allow access to the given ports. 54 | 55 | * `protocol` - (Required) The name of the protocol to allow. Valid options are: 56 | `tcp`, `udp`, `icmp`, `all` or a valid protocol number. 57 | 58 | * `icmp_type` - (Optional) The ICMP type to allow, or `-1` to allow `any`. This 59 | can only be specified if the protocol is ICMP. (defaults 0) 60 | 61 | * `icmp_code` - (Optional) The ICMP code to allow, or `-1` to allow `any`. This 62 | can only be specified if the protocol is ICMP. (defaults 0) 63 | 64 | * `ports` - (Optional) List of ports and/or port ranges to allow. This can only 65 | be specified if the protocol is TCP, UDP, ALL or a valid protocol number. 66 | 67 | * `traffic_type` - (Optional) The traffic type for the rule. Valid options are: 68 | `ingress` or `egress`. (defaults ingress) 69 | 70 | * `user_security_group_list` - (Optional) A list of security groups to apply 71 | the rules to. 72 | 73 | ## Attributes Reference 74 | 75 | The following attributes are exported: 76 | 77 | * `id` - The security group ID for which the rules are created. 78 | -------------------------------------------------------------------------------- /cloudstack/resource_cloudstack_disk_offering.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "log" 24 | 25 | "github.com/apache/cloudstack-go/v2/cloudstack" 26 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 27 | ) 28 | 29 | func resourceCloudStackDiskOffering() *schema.Resource { 30 | return &schema.Resource{ 31 | Create: resourceCloudStackDiskOfferingCreate, 32 | Read: resourceCloudStackDiskOfferingRead, 33 | Update: resourceCloudStackDiskOfferingUpdate, 34 | Delete: resourceCloudStackDiskOfferingDelete, 35 | Schema: map[string]*schema.Schema{ 36 | "name": { 37 | Type: schema.TypeString, 38 | Required: true, 39 | }, 40 | "display_text": { 41 | Type: schema.TypeString, 42 | Required: true, 43 | }, 44 | "disk_size": { 45 | Type: schema.TypeInt, 46 | Required: true, 47 | }, 48 | }, 49 | } 50 | } 51 | 52 | func resourceCloudStackDiskOfferingCreate(d *schema.ResourceData, meta interface{}) error { 53 | cs := meta.(*cloudstack.CloudStackClient) 54 | name := d.Get("name").(string) 55 | display_text := d.Get("display_text").(string) 56 | disk_size := d.Get("disk_size").(int) 57 | 58 | // Create a new parameter struct 59 | p := cs.DiskOffering.NewCreateDiskOfferingParams(name, display_text) 60 | p.SetDisksize(int64(disk_size)) 61 | 62 | log.Printf("[DEBUG] Creating Disk Offering %s", name) 63 | diskOff, err := cs.DiskOffering.CreateDiskOffering(p) 64 | 65 | if err != nil { 66 | return err 67 | } 68 | 69 | log.Printf("[DEBUG] Disk Offering %s successfully created", name) 70 | d.SetId(diskOff.Id) 71 | 72 | return resourceCloudStackDiskOfferingRead(d, meta) 73 | } 74 | 75 | func resourceCloudStackDiskOfferingRead(d *schema.ResourceData, meta interface{}) error { return nil } 76 | 77 | func resourceCloudStackDiskOfferingUpdate(d *schema.ResourceData, meta interface{}) error { return nil } 78 | 79 | func resourceCloudStackDiskOfferingDelete(d *schema.ResourceData, meta interface{}) error { return nil } 80 | -------------------------------------------------------------------------------- /website/docs/r/cluster.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_cluster" 4 | sidebar_current: "docs-cloudstack-resource-cluster" 5 | description: |- 6 | Adds a new cluster 7 | --- 8 | 9 | # cloudstack_cluster 10 | 11 | Adds a new cluster 12 | 13 | ## Example Usage 14 | 15 | Basic usage: 16 | 17 | ```hcl 18 | resource "cloudstack_cluster" "example" { 19 | cluster_name = "example" 20 | cluster_type = "CloudManaged" 21 | hypervisor = "KVM" 22 | pod_id = cloudstack_pod.example.id 23 | zone_id = cloudstack_zone.example.id 24 | } 25 | ``` 26 | 27 | ## Argument Reference 28 | 29 | The following arguments are supported: 30 | 31 | * `allocation_state` - (Optional) Allocation state of this cluster for allocation of new resources. 32 | * `cluster_name` - (Required) the cluster name. 33 | * `cluster_type` - (Required) type of the cluster: CloudManaged, ExternalManaged. 34 | * `guest_vswitch_name` - (Optional) Name of virtual switch used for guest traffic in the cluster. This would override zone wide traffic label setting.. 35 | * `guest_vswitch_type` - (Optional) Type of virtual switch used for guest traffic in the cluster. Allowed values are, vmwaresvs (for VMware standard vSwitch) and vmwaredvs (for VMware distributed vSwitch). 36 | * `hypervisor` - (Required) hypervisor type of the cluster: XenServer,KVM,VMware,Hyperv,BareMetal,Simulator,Ovm3. 37 | * `ovm3_cluster` - (Optional) Ovm3 native OCFS2 clustering enabled for cluster. 38 | * `ovm3_pool` - (Optional) Ovm3 native pooling enabled for cluster. 39 | * `ovm3_vip` - (Optional) Ovm3 vip to use for pool (and cluster). 40 | * `password` - (Optional) the password for the host. 41 | * `public_vswitch_name` - (Optional) Name of virtual switch used for public traffic in the cluster. This would override zone wide traffic label setting.. 42 | * `public_vswitch_type` - (Optional) Type of virtual switch used for public traffic in the cluster. Allowed values are, vmwaresvs (for VMware standard vSwitch) and vmwaredvs (for VMware distributed vSwitch). 43 | * `pod_id` - (Required) the Pod ID for the host. 44 | * `url` - (Optional) the URL. 45 | * `username` - (Optional) the username for the cluster. 46 | * `vsm_ip_address` - (Optional) the ipaddress of the VSM associated with this cluster. 47 | * `vsm_password` - (Optional) the password for the VSM associated with this cluster. 48 | * `vsm_username` - (Optional) the username for the VSM associated with this cluster. 49 | * `zone_id` - (Required) the Zone ID for the cluster. 50 | 51 | 52 | ## Attributes Reference 53 | 54 | The following attributes are exported: 55 | 56 | * `id` - The instance ID. 57 | 58 | 59 | 60 | ## Import 61 | 62 | Clusters can be imported; use `` as the import ID. For 63 | example: 64 | 65 | ```shell 66 | terraform import cloudstack_cluster.example 5cf69677-7e4b-4bf4-b868-f0b02bb72ee0 67 | ``` 68 | -------------------------------------------------------------------------------- /website/docs/r/network_service_provider_state.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_network_service_provider_state" 4 | sidebar_current: "docs-cloudstack-resource-network_service_provider_state" 5 | description: |- 6 | Manage network service providers for a given physical network. 7 | --- 8 | 9 | # cloudstack_zone 10 | 11 | Manage network service providers for a given physical network. If Service Provider includes an underlying `Element` (configureInternalLoadBalancerElement, configureVirtualRouterElement) it will be configured. 12 | 13 | ## Example Usage 14 | 15 | Basic usage: 16 | 17 | ```hcl 18 | resource "cloudstack_zone" "test" { 19 | name = "acctest" 20 | dns1 = "8.8.8.8" 21 | dns2 = "8.8.8.8" 22 | internal_dns1 = "8.8.4.4" 23 | internal_dns2 = "8.8.4.4" 24 | network_type = "Advanced" 25 | domain = "cloudstack.apache.org" 26 | } 27 | resource "cloudstack_physical_network" "test" { 28 | broadcast_domain_range = "ZONE" 29 | isolation_methods = "VLAN" 30 | name = "test01" 31 | network_speed = "1G" 32 | tags = "vlan" 33 | zone_id = cloudstack_zone.test.id 34 | } 35 | resource "cloudstack_network_service_provider_state" "virtualrouter" { 36 | name = "VirtualRouter" 37 | physical_network_id = cloudstack_physical_network.test.id 38 | enabled = true 39 | } 40 | resource "cloudstack_network_service_provider_state" "vpcvirtualrouter" { 41 | name = "VpcVirtualRouter" 42 | physical_network_id = cloudstack_physical_network.test.id 43 | enabled = true 44 | } 45 | resource "cloudstack_network_service_provider_state" "internallbvm" { 46 | name = "InternalLbVm" 47 | physical_network_id = cloudstack_physical_network.test.id 48 | enabled = false 49 | } 50 | resource "cloudstack_network_service_provider_state" "configdrive" { 51 | name = "ConfigDrive" 52 | physical_network_id = cloudstack_physical_network.test.id 53 | enabled = false 54 | } 55 | ``` 56 | 57 | ## Argument Reference 58 | 59 | The following arguments are supported: 60 | 61 | * `name` - (Required) account who will own the VLAN. If VLAN is Zone wide, this parameter should be omitted 62 | * `physical_network_id` - (Required) domain ID of the account owning a VLAN 63 | * `enabled` - (Required) the ending IP address in the VLAN IP range 64 | 65 | 66 | ## Attributes Reference 67 | 68 | The following attributes are exported: 69 | 70 | * `id` - uuid of the network provider 71 | 72 | 73 | ## Import 74 | 75 | Network service providers can be imported; use `` as the import ID. For 76 | example: 77 | 78 | ```shell 79 | terraform import cloudstack_network_service_provider_state.example VirtualRouter 5cf69677-7e4b-4bf4-b868-f0b02bb72ee0 80 | ``` 81 | -------------------------------------------------------------------------------- /GNUmakefile: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | TEST?=$$(go list ./... | grep -v 'vendor') 19 | GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor) 20 | WEBSITE_REPO=github.com/hashicorp/terraform-website 21 | PKG_NAME=cloudstack 22 | 23 | default: build 24 | 25 | build: fmtcheck 26 | go install 27 | 28 | test: fmtcheck 29 | go test -i $(TEST) || exit 1 30 | echo $(TEST) | \ 31 | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4 32 | 33 | testacc: fmtcheck 34 | TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 30m 35 | 36 | vet: 37 | @echo "go vet ." 38 | @go vet $$(go list ./... | grep -v vendor/) ; if [ $$? -eq 1 ]; then \ 39 | echo ""; \ 40 | echo "Vet found suspicious constructs. Please check the reported constructs"; \ 41 | echo "and fix them if necessary before submitting the code for review."; \ 42 | exit 1; \ 43 | fi 44 | 45 | fmt: 46 | gofmt -w $(GOFMT_FILES) 47 | 48 | fmtcheck: 49 | @bash -c "'$(CURDIR)/scripts/gofmtcheck.sh'" 50 | 51 | errcheck: 52 | @bash -c "'$(CURDIR)/scripts/errcheck.sh'" 53 | 54 | test-compile: 55 | @if [ "$(TEST)" = "./..." ]; then \ 56 | echo "ERROR: Set TEST to a specific package. For example,"; \ 57 | echo " make test-compile TEST=./$(PKG_NAME)"; \ 58 | exit 1; \ 59 | fi 60 | go test -c $(TEST) $(TESTARGS) 61 | 62 | website: 63 | ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO))) 64 | echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..." 65 | git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO) 66 | endif 67 | @$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME) 68 | 69 | website-test: 70 | ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO))) 71 | echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..." 72 | git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO) 73 | endif 74 | @$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME) 75 | 76 | .PHONY: build test testacc vet fmt fmtcheck errcheck vendor-status test-compile website website-test 77 | 78 | -------------------------------------------------------------------------------- /website/docs/r/limits.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_limits" 4 | sidebar_current: "docs-cloudstack-limits" 5 | description: |- 6 | Provides a CloudStack limits resource. 7 | --- 8 | 9 | # cloudstack_limits 10 | 11 | Provides a CloudStack limits resource. This can be used to manage resource limits for accounts, domains, and projects within CloudStack. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | # Set instance limit for the root domain 17 | resource "cloudstack_limits" "instance_limit" { 18 | type = "instance" 19 | max = 20 20 | } 21 | 22 | # Set volume limit for a specific account in a domain 23 | resource "cloudstack_limits" "volume_limit" { 24 | type = "volume" 25 | max = 50 26 | account = "acct1" 27 | domain_id = "domain-uuid" 28 | } 29 | 30 | # Set primary storage limit for a project 31 | resource "cloudstack_limits" "storage_limit" { 32 | type = "primarystorage" 33 | max = 1000 # GB 34 | project = "project-uuid" 35 | } 36 | 37 | # Set unlimited CPU limit 38 | resource "cloudstack_limits" "cpu_unlimited" { 39 | type = "cpu" 40 | max = -1 # Unlimited 41 | } 42 | ``` 43 | 44 | ## Argument Reference 45 | 46 | The following arguments are supported: 47 | 48 | * `type` - (Required, ForceNew) The type of resource to update. Available types are: 49 | * `instance` 50 | * `ip` 51 | * `volume` 52 | * `snapshot` 53 | * `template` 54 | * `project` 55 | * `network` 56 | * `vpc` 57 | * `cpu` 58 | * `memory` 59 | * `primarystorage` 60 | * `secondarystorage` 61 | 62 | * `account` - (Optional, ForceNew) Update resource for a specified account. Must be used with the `domain_id` parameter. 63 | * `domain_id` - (Optional, ForceNew) Update resource limits for all accounts in specified domain. If used with the `account` parameter, updates resource limits for a specified account in specified domain. 64 | * `max` - (Optional) Maximum resource limit. Use `-1` for unlimited resource limit. A value of `0` means zero resources are allowed, though the CloudStack API may return `-1` for a limit set to `0`. 65 | * `project` - (Optional, ForceNew) Update resource limits for project. 66 | 67 | ## Attributes Reference 68 | 69 | The following attributes are exported: 70 | 71 | * `id` - The ID of the resource. 72 | * `type` - The type of resource. 73 | * `max` - The maximum number of the resource. 74 | * `account` - The account of the resource limit. 75 | * `domain_id` - The domain ID of the resource limit. 76 | * `project` - The project ID of the resource limit. 77 | 78 | ## Import 79 | 80 | Resource limits can be imported using the resource type (numeric), account, domain ID, and project ID, e.g. 81 | 82 | ```bash 83 | terraform import cloudstack_limits.instance_limit 0 84 | terraform import cloudstack_limits.volume_limit 2-acct1-domain-uuid 85 | terraform import cloudstack_limits.storage_limit 10-project-uuid 86 | ``` 87 | 88 | When importing, the numeric resource type is used in the import ID. The provider will automatically convert the numeric type to the corresponding string type after import. 89 | -------------------------------------------------------------------------------- /cloudstack/data_source_cloudstack_condition.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "fmt" 24 | "log" 25 | 26 | "github.com/apache/cloudstack-go/v2/cloudstack" 27 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 28 | ) 29 | 30 | func dataSourceCloudstackCondition() *schema.Resource { 31 | return &schema.Resource{ 32 | Read: dataSourceCloudstackConditionRead, 33 | 34 | Schema: map[string]*schema.Schema{ 35 | "id": { 36 | Type: schema.TypeString, 37 | Optional: true, 38 | Computed: true, 39 | }, 40 | 41 | "counter_id": { 42 | Type: schema.TypeString, 43 | Computed: true, 44 | }, 45 | 46 | "relational_operator": { 47 | Type: schema.TypeString, 48 | Computed: true, 49 | }, 50 | 51 | "threshold": { 52 | Type: schema.TypeFloat, 53 | Computed: true, 54 | }, 55 | 56 | "account_name": { 57 | Type: schema.TypeString, 58 | Computed: true, 59 | }, 60 | 61 | "domain_id": { 62 | Type: schema.TypeString, 63 | Computed: true, 64 | }, 65 | 66 | "project_id": { 67 | Type: schema.TypeString, 68 | Computed: true, 69 | }, 70 | }, 71 | } 72 | } 73 | 74 | func dataSourceCloudstackConditionRead(d *schema.ResourceData, meta interface{}) error { 75 | cs := meta.(*cloudstack.CloudStackClient) 76 | 77 | id, idOk := d.GetOk("id") 78 | 79 | if !idOk { 80 | return fmt.Errorf("'id' must be specified") 81 | } 82 | 83 | p := cs.AutoScale.NewListConditionsParams() 84 | p.SetId(id.(string)) 85 | 86 | resp, err := cs.AutoScale.ListConditions(p) 87 | if err != nil { 88 | return fmt.Errorf("failed to list conditions: %s", err) 89 | } 90 | 91 | if resp.Count == 0 { 92 | return fmt.Errorf("condition with ID %s not found", id.(string)) 93 | } 94 | 95 | condition := resp.Conditions[0] 96 | 97 | log.Printf("[DEBUG] Found condition: %s", condition.Id) 98 | 99 | d.SetId(condition.Id) 100 | d.Set("counter_id", condition.Counterid) 101 | d.Set("relational_operator", condition.Relationaloperator) 102 | d.Set("threshold", condition.Threshold) 103 | d.Set("account_name", condition.Account) 104 | d.Set("domain_id", condition.Domainid) 105 | if condition.Projectid != "" { 106 | d.Set("project_id", condition.Projectid) 107 | } 108 | 109 | return nil 110 | } 111 | -------------------------------------------------------------------------------- /cloudstack/tags_test.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "encoding/json" 24 | "fmt" 25 | "reflect" 26 | "testing" 27 | 28 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" 29 | "github.com/hashicorp/terraform-plugin-testing/terraform" 30 | ) 31 | 32 | func TestDiffTags(t *testing.T) { 33 | cases := []struct { 34 | Old, New map[string]interface{} 35 | Create, Remove map[string]string 36 | }{ 37 | // Basic add/remove 38 | { 39 | Old: map[string]interface{}{ 40 | "foo": "bar", 41 | }, 42 | New: map[string]interface{}{ 43 | "bar": "baz", 44 | }, 45 | Create: map[string]string{ 46 | "bar": "baz", 47 | }, 48 | Remove: map[string]string{ 49 | "foo": "bar", 50 | }, 51 | }, 52 | 53 | // Modify 54 | { 55 | Old: map[string]interface{}{ 56 | "foo": "bar", 57 | }, 58 | New: map[string]interface{}{ 59 | "foo": "baz", 60 | }, 61 | Create: map[string]string{ 62 | "foo": "baz", 63 | }, 64 | Remove: map[string]string{ 65 | "foo": "bar", 66 | }, 67 | }, 68 | } 69 | 70 | for i, tc := range cases { 71 | r, c := diffTags(tagsFromSchema(tc.Old), tagsFromSchema(tc.New)) 72 | if !reflect.DeepEqual(r, tc.Remove) { 73 | t.Fatalf("%d: bad remove: %#v", i, r) 74 | } 75 | if !reflect.DeepEqual(c, tc.Create) { 76 | t.Fatalf("%d: bad create: %#v", i, c) 77 | } 78 | } 79 | } 80 | 81 | // testAccCheckResourceTags is an helper to test tags creation on any resource. 82 | func testAccCheckResourceTags( 83 | n interface{}) resource.TestCheckFunc { 84 | res := struct { 85 | Tags []struct { 86 | Key string `json:"key,omitempty"` 87 | Value string `json:"value,omitempty"` 88 | } `json:"tags,omitempty"` 89 | }{} 90 | return func(s *terraform.State) error { 91 | b, _ := json.Marshal(n) 92 | json.Unmarshal(b, &res) 93 | tags := make(map[string]string) 94 | for _, tag := range res.Tags { 95 | tags[tag.Key] = tag.Value 96 | } 97 | return testAccCheckTags(tags, "terraform-tag", "true") 98 | } 99 | } 100 | 101 | // testAccCheckTags can be used to check the tags on a resource. 102 | func testAccCheckTags(tags map[string]string, key string, value string) error { 103 | v, ok := tags[key] 104 | if !ok { 105 | return fmt.Errorf("Missing tag: %s", key) 106 | } 107 | 108 | if v != value { 109 | return fmt.Errorf("%s: bad value: %s", key, v) 110 | } 111 | 112 | return nil 113 | } 114 | -------------------------------------------------------------------------------- /website/docs/r/vlan_ip_range.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_vlan_ip_range" 4 | sidebar_current: "docs-cloudstack-resource-vlan_ip_range" 5 | description: |- 6 | Creates a VLAN IP range. 7 | --- 8 | 9 | # cloudstack_zone 10 | 11 | Creates a VLAN IP range. 12 | 13 | ## Example Usage 14 | 15 | Basic usage: 16 | 17 | ```hcl 18 | resource "cloudstack_zone" "test" { 19 | name = "acctest" 20 | dns1 = "8.8.8.8" 21 | dns2 = "8.8.8.8" 22 | internal_dns1 = "8.8.4.4" 23 | internal_dns2 = "8.8.4.4" 24 | network_type = "Advanced" 25 | domain = "cloudstack.apache.org" 26 | } 27 | resource "cloudstack_physical_network" "test" { 28 | broadcast_domain_range = "ZONE" 29 | isolation_methods = "VLAN" 30 | name = "test01" 31 | network_speed = "1G" 32 | tags = "vlan" 33 | zone_id = cloudstack_zone.test.id 34 | } 35 | resource "cloudstack_vlan_ip_range" "test" { 36 | physical_network_id = cloudstack_physical_network.test.id 37 | for_virtual_network = true 38 | zone_id = cloudstack_zone.test.id 39 | gateway = "10.0.0.1" 40 | netmask = "255.255.255.0" 41 | start_ip = "10.0.0.2" 42 | end_ip = "10.0.0.10" 43 | vlan = "vlan://123" 44 | } 45 | ``` 46 | 47 | ## Argument Reference 48 | 49 | The following arguments are supported: 50 | 51 | * `account` - (Optional) account who will own the VLAN. If VLAN is Zone wide, this parameter should be omitted 52 | * `domain_id` - (Optional) domain ID of the account owning a VLAN 53 | * `end_ip` - (Optional) the ending IP address in the VLAN IP range 54 | * `end_ipv6` - (Optional) the ending IPv6 address in the IPv6 network range 55 | * `for_system_vms` - (Optional) true if IP range is set to system vms, false if not 56 | * `for_virtual_network` - (Optional) true if VLAN is of Virtual type, false if Direct 57 | * `gateway` - (Optional) the gateway of the VLAN IP range 58 | * `ip6_cidr` - (Optional) the CIDR of IPv6 network, must be at least /64 59 | * `ip6_gateway` - (Optional) the gateway of the IPv6 network. Required for Shared networks and Isolated networks when it belongs to VPC 60 | * `netmask` - (Optional) the netmask of the VLAN IP range 61 | * `network_id` - (Optional) the network id 62 | * `physical_network_id` - (Optional) the physical network id 63 | * `pod_id` - (Optional) Have to be specified for Direct Untagged vlan only. 64 | * `project_id` - (Optional) project who will own the VLAN. If VLAN is Zone wide, this parameter should be omitted 65 | * `start_ip` - (Optional) the beginning IP address in the VLAN IP range 66 | * `start_ipv6` - (Optional) the beginning IPv6 address in the IPv6 network range 67 | * `vlan` - (Optional) true if network is security group enabled, false otherwise 68 | * `start_ipv6` - (Optional) the ID or VID of the VLAN. If not specified, will be defaulted to the vlan of the network or if vlan of the network is null - to Untagged 69 | * `zone_id` - (Optional) the Zone ID of the VLAN IP range 70 | 71 | ## Attributes Reference 72 | 73 | The following attributes are exported: 74 | 75 | * `id` - the ID of the VLAN IP range 76 | * `network_id` - the network id of vlan range 77 | 78 | 79 | ## Import 80 | 81 | Vlan ip range can be imported; use `` as the import ID. For 82 | example: 83 | 84 | ```shell 85 | terraform import cloudstack_vlan_ip_range.example 5cf69677-7e4b-4bf4-b868-f0b02bb72ee0 86 | ``` 87 | -------------------------------------------------------------------------------- /cloudstack/data_source_cloudstack_counter.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "fmt" 24 | "log" 25 | 26 | "github.com/apache/cloudstack-go/v2/cloudstack" 27 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 28 | ) 29 | 30 | func dataSourceCloudstackCounter() *schema.Resource { 31 | return &schema.Resource{ 32 | Read: dataSourceCloudstackCounterRead, 33 | 34 | Schema: map[string]*schema.Schema{ 35 | "id": { 36 | Type: schema.TypeString, 37 | Optional: true, 38 | Computed: true, 39 | }, 40 | 41 | "name": { 42 | Type: schema.TypeString, 43 | Optional: true, 44 | Computed: true, 45 | }, 46 | 47 | "source": { 48 | Type: schema.TypeString, 49 | Computed: true, 50 | }, 51 | 52 | "value": { 53 | Type: schema.TypeString, 54 | Computed: true, 55 | }, 56 | 57 | "counter_provider": { 58 | Type: schema.TypeString, 59 | Computed: true, 60 | }, 61 | }, 62 | } 63 | } 64 | 65 | func dataSourceCloudstackCounterRead(d *schema.ResourceData, meta interface{}) error { 66 | cs := meta.(*cloudstack.CloudStackClient) 67 | 68 | id, idOk := d.GetOk("id") 69 | name, nameOk := d.GetOk("name") 70 | 71 | if !idOk && !nameOk { 72 | return fmt.Errorf("either 'id' or 'name' must be specified") 73 | } 74 | 75 | var counter *cloudstack.Counter 76 | 77 | if idOk { 78 | // Get counter by ID 79 | p := cs.AutoScale.NewListCountersParams() 80 | p.SetId(id.(string)) 81 | 82 | resp, err := cs.AutoScale.ListCounters(p) 83 | if err != nil { 84 | return fmt.Errorf("failed to list counters: %s", err) 85 | } 86 | 87 | if resp.Count == 0 { 88 | return fmt.Errorf("counter with ID %s not found", id.(string)) 89 | } 90 | 91 | counter = resp.Counters[0] 92 | } else { 93 | // Get counter by name 94 | p := cs.AutoScale.NewListCountersParams() 95 | 96 | resp, err := cs.AutoScale.ListCounters(p) 97 | if err != nil { 98 | return fmt.Errorf("failed to list counters: %s", err) 99 | } 100 | 101 | for _, c := range resp.Counters { 102 | if c.Name == name.(string) { 103 | counter = c 104 | break 105 | } 106 | } 107 | 108 | if counter == nil { 109 | return fmt.Errorf("counter with name %s not found", name.(string)) 110 | } 111 | } 112 | 113 | log.Printf("[DEBUG] Found counter: %s", counter.Name) 114 | 115 | d.SetId(counter.Id) 116 | d.Set("name", counter.Name) 117 | d.Set("source", counter.Source) 118 | d.Set("value", counter.Value) 119 | d.Set("counter_provider", counter.Provider) 120 | 121 | return nil 122 | } 123 | -------------------------------------------------------------------------------- /cloudstack/resource_cloudstack_domain.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "fmt" 24 | "log" 25 | 26 | "github.com/apache/cloudstack-go/v2/cloudstack" 27 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 28 | ) 29 | 30 | func resourceCloudStackDomain() *schema.Resource { 31 | return &schema.Resource{ 32 | Read: resourceCloudStackDomainRead, 33 | Update: resourceCloudStackDomainUpdate, 34 | Create: resourceCloudStackDomainCreate, 35 | Delete: resourceCloudStackDomainDelete, 36 | Schema: map[string]*schema.Schema{ 37 | "name": { 38 | Type: schema.TypeString, 39 | Required: true, 40 | }, 41 | "domain_id": { 42 | Type: schema.TypeString, 43 | Optional: true, 44 | }, 45 | "network_domain": { 46 | Type: schema.TypeString, 47 | Optional: true, 48 | }, 49 | "parent_domain_id": { 50 | Type: schema.TypeString, 51 | Optional: true, 52 | }, 53 | }, 54 | } 55 | } 56 | 57 | func resourceCloudStackDomainCreate(d *schema.ResourceData, meta interface{}) error { 58 | cs := meta.(*cloudstack.CloudStackClient) 59 | name := d.Get("name").(string) 60 | domain_id := d.Get("domain_id").(string) 61 | network_domain := d.Get("network_domain").(string) 62 | parent_domain_id := d.Get("parent_domain_id").(string) 63 | 64 | // Create a new parameter struct 65 | p := cs.Domain.NewCreateDomainParams(name) 66 | 67 | if domain_id != "" { 68 | p.SetDomainid(domain_id) 69 | } 70 | 71 | if network_domain != "" { 72 | p.SetNetworkdomain(network_domain) 73 | } 74 | 75 | if parent_domain_id != "" { 76 | p.SetParentdomainid(parent_domain_id) 77 | } 78 | 79 | log.Printf("[DEBUG] Creating Domain %s", name) 80 | domain, err := cs.Domain.CreateDomain(p) 81 | 82 | if err != nil { 83 | return err 84 | } 85 | 86 | log.Printf("[DEBUG] Domain %s successfully created", name) 87 | d.SetId(domain.Id) 88 | 89 | return resourceCloudStackDomainRead(d, meta) 90 | } 91 | 92 | func resourceCloudStackDomainRead(d *schema.ResourceData, meta interface{}) error { return nil } 93 | 94 | func resourceCloudStackDomainUpdate(d *schema.ResourceData, meta interface{}) error { return nil } 95 | 96 | func resourceCloudStackDomainDelete(d *schema.ResourceData, meta interface{}) error { 97 | cs := meta.(*cloudstack.CloudStackClient) 98 | 99 | // Create a new parameter struct 100 | p := cs.Domain.NewDeleteDomainParams(d.Id()) 101 | _, err := cs.Domain.DeleteDomain(p) 102 | 103 | if err != nil { 104 | return fmt.Errorf("Error deleting Domain: %s", err) 105 | } 106 | 107 | return nil 108 | } 109 | -------------------------------------------------------------------------------- /website/docs/r/network_service_provider.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_network_service_provider" 4 | sidebar_current: "docs-cloudstack-resource-network-service-provider" 5 | description: |- 6 | Adds a network service provider to a physical network. 7 | --- 8 | 9 | # cloudstack_network_service_provider 10 | 11 | Adds or updates a network service provider on a physical network. 12 | 13 | ~> **NOTE:** Network service providers are often created automatically when a physical network is created. This resource can be used to manage those existing providers or create new ones. 14 | 15 | ~> **NOTE:** Some providers like SecurityGroupProvider don't allow updating the service list. For these providers, the service list specified in the configuration will be used only during creation. 16 | 17 | ~> **NOTE:** Network service providers are created in a "Disabled" state by default. You can set `state = "Enabled"` to enable them. Note that some providers like VirtualRouter require configuration before they can be enabled. 18 | 19 | ## Example Usage 20 | 21 | ```hcl 22 | resource "cloudstack_physicalnetwork" "default" { 23 | name = "test-physical-network" 24 | zone = "zone-name" 25 | } 26 | 27 | resource "cloudstack_network_service_provider" "virtualrouter" { 28 | name = "VirtualRouter" 29 | physical_network_id = cloudstack_physicalnetwork.default.id 30 | service_list = ["Dhcp", "Dns", "Firewall", "LoadBalancer", "SourceNat", "StaticNat", "PortForwarding", "Vpn"] 31 | state = "Enabled" 32 | } 33 | 34 | resource "cloudstack_network_service_provider" "vpcvirtualrouter" { 35 | name = "VpcVirtualRouter" 36 | physical_network_id = cloudstack_physicalnetwork.default.id 37 | service_list = ["Dhcp", "Dns", "SourceNat", "StaticNat", "NetworkACL", "PortForwarding", "Lb", "UserData", "Vpn"] 38 | } 39 | 40 | resource "cloudstack_network_service_provider" "securitygroup" { 41 | name = "SecurityGroupProvider" 42 | physical_network_id = cloudstack_physicalnetwork.default.id 43 | # Note: service_list is predefined for SecurityGroupProvider 44 | state = "Enabled" # Optional: providers are created in "Disabled" state by default 45 | } 46 | ``` 47 | 48 | ## Argument Reference 49 | 50 | The following arguments are supported: 51 | 52 | * `name` - (Required) The name of the network service provider. Possible values include: VirtualRouter, VpcVirtualRouter, InternalLbVm, ConfigDrive, etc. 53 | * `physical_network_id` - (Required) The ID of the physical network to which to add the network service provider. 54 | * `destination_physical_network_id` - (Optional) The destination physical network ID. 55 | * `service_list` - (Optional) The list of services to be enabled for this service provider. Possible values include: Dhcp, Dns, Firewall, Gateway, LoadBalancer, NetworkACL, PortForwarding, SourceNat, StaticNat, UserData, Vpn, etc. 56 | * `state` - (Optional) The state of the network service provider. Possible values are "Enabled" and "Disabled". This can be used to enable or disable the provider. 57 | 58 | ## Attributes Reference 59 | 60 | The following attributes are exported: 61 | 62 | * `id` - The ID of the network service provider. 63 | * `state` - The state of the network service provider. 64 | 65 | ## Import 66 | 67 | Network service providers can be imported using the network service provider ID, e.g. 68 | 69 | ```shell 70 | terraform import cloudstack_network_service_provider.virtualrouter 5fb307e2-0e11-11ee-be56-0242ac120002 71 | ``` 72 | -------------------------------------------------------------------------------- /cloudstack/resource_cloudstack_user.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for additional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "fmt" 24 | "log" 25 | 26 | "github.com/apache/cloudstack-go/v2/cloudstack" 27 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 28 | ) 29 | 30 | func resourceCloudStackUser() *schema.Resource { 31 | return &schema.Resource{ 32 | Create: resourceCloudStackUserCreate, 33 | Read: resourceCloudStackUserRead, 34 | Update: resourceCloudStackUserUpdate, 35 | Delete: resourceCloudStackUserDelete, 36 | Schema: map[string]*schema.Schema{ 37 | "account": { 38 | Type: schema.TypeString, 39 | Optional: true, 40 | }, 41 | "email": { 42 | Type: schema.TypeString, 43 | Required: true, 44 | }, 45 | "first_name": { 46 | Type: schema.TypeString, 47 | Required: true, 48 | }, 49 | "last_name": { 50 | Type: schema.TypeString, 51 | Required: true, 52 | }, 53 | "password": { 54 | Type: schema.TypeString, 55 | Required: true, 56 | }, 57 | "username": { 58 | Type: schema.TypeString, 59 | Required: true, 60 | }, 61 | }, 62 | } 63 | } 64 | 65 | func resourceCloudStackUserCreate(d *schema.ResourceData, meta interface{}) error { 66 | cs := meta.(*cloudstack.CloudStackClient) 67 | account := d.Get("account").(string) 68 | email := d.Get("email").(string) 69 | first_name := d.Get("first_name").(string) 70 | last_name := d.Get("last_name").(string) 71 | password := d.Get("password").(string) 72 | username := d.Get("username").(string) 73 | 74 | // Create a new parameter struct 75 | p := cs.User.NewCreateUserParams(account, email, first_name, last_name, password, username) 76 | 77 | log.Printf("[DEBUG] Creating User %s", username) 78 | u, err := cs.User.CreateUser(p) 79 | 80 | if err != nil { 81 | return err 82 | } 83 | 84 | log.Printf("[DEBUG] User %s successfully created", username) 85 | d.SetId(u.Id) 86 | 87 | return resourceCloudStackUserRead(d, meta) 88 | } 89 | 90 | func resourceCloudStackUserUpdate(d *schema.ResourceData, meta interface{}) error { 91 | return resourceCloudStackUserRead(d, meta) 92 | } 93 | 94 | func resourceCloudStackUserDelete(d *schema.ResourceData, meta interface{}) error { 95 | cs := meta.(*cloudstack.CloudStackClient) 96 | 97 | // Create a new parameter struct 98 | p := cs.User.NewDeleteUserParams(d.Id()) 99 | _, err := cs.User.DeleteUser(p) 100 | 101 | if err != nil { 102 | return fmt.Errorf("Error deleting User: %s", err) 103 | } 104 | 105 | return nil 106 | } 107 | 108 | func resourceCloudStackUserRead(d *schema.ResourceData, meta interface{}) error { 109 | return nil 110 | } 111 | -------------------------------------------------------------------------------- /cloudstack/resource_cloudstack_attach_volume.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed to the Apache Software Foundation (ASF) under one 3 | // or more contributor license agreements. See the NOTICE file 4 | // distributed with this work for Attachitional information 5 | // regarding copyright ownership. The ASF licenses this file 6 | // to you under the Apache License, Version 2.0 (the 7 | // "License"); you may not use this file except in compliance 8 | // with the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, 13 | // software distributed under the License is distributed on an 14 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | // KIND, either express or implied. See the License for the 16 | // specific language governing permissions and limitations 17 | // under the License. 18 | // 19 | 20 | package cloudstack 21 | 22 | import ( 23 | "github.com/apache/cloudstack-go/v2/cloudstack" 24 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" 25 | ) 26 | 27 | func resourceCloudStackAttachVolume() *schema.Resource { 28 | return &schema.Resource{ 29 | Read: resourceCloudStackAttachVolumeRead, 30 | Create: resourceCloudStackAttachVolumeCreate, 31 | Delete: resourceCloudStackAttachVolumeDelete, 32 | Schema: map[string]*schema.Schema{ 33 | "volume_id": { 34 | Type: schema.TypeString, 35 | Required: true, 36 | ForceNew: true, 37 | Description: "the ID of the disk volume", 38 | }, 39 | "virtual_machine_id": { 40 | Type: schema.TypeString, 41 | Required: true, 42 | ForceNew: true, 43 | Description: "the ID of the virtual machine", 44 | }, 45 | "device_id": { 46 | Type: schema.TypeInt, 47 | Optional: true, 48 | Computed: true, 49 | ForceNew: true, 50 | Description: "The ID of the device to map the volume to the guest OS. ", 51 | }, 52 | "attached": { 53 | Type: schema.TypeString, 54 | Required: false, 55 | Computed: true, 56 | Description: "the date the volume was attached to a VM instance", 57 | }, 58 | }, 59 | } 60 | } 61 | 62 | func resourceCloudStackAttachVolumeCreate(d *schema.ResourceData, meta interface{}) error { 63 | cs := meta.(*cloudstack.CloudStackClient) 64 | 65 | p := cs.Volume.NewAttachVolumeParams(d.Get("volume_id").(string), d.Get("virtual_machine_id").(string)) 66 | if v, ok := d.GetOk("device_id"); ok { 67 | p.SetDeviceid(v.(int64)) 68 | } 69 | 70 | r, err := cs.Volume.AttachVolume(p) 71 | if err != nil { 72 | return err 73 | } 74 | 75 | d.SetId(r.Id) 76 | 77 | return resourceCloudStackAttachVolumeRead(d, meta) 78 | } 79 | 80 | func resourceCloudStackAttachVolumeRead(d *schema.ResourceData, meta interface{}) error { 81 | cs := meta.(*cloudstack.CloudStackClient) 82 | 83 | r, _, err := cs.Volume.GetVolumeByID(d.Id()) 84 | if err != nil { 85 | return err 86 | } 87 | 88 | d.Set("volume_id", r.Id) 89 | d.Set("virtual_machine_id", r.Virtualmachineid) 90 | d.Set("device_id", r.Deviceid) 91 | d.Set("attached", r.Attached) 92 | 93 | return nil 94 | } 95 | 96 | func resourceCloudStackAttachVolumeDelete(d *schema.ResourceData, meta interface{}) error { 97 | cs := meta.(*cloudstack.CloudStackClient) 98 | 99 | p := cs.Volume.NewDetachVolumeParams() 100 | p.SetId(d.Id()) 101 | _, err := cs.Volume.DetachVolume(p) 102 | if err != nil { 103 | return err 104 | } 105 | 106 | return nil 107 | } 108 | -------------------------------------------------------------------------------- /website/docs/r/network.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: "cloudstack" 3 | page_title: "CloudStack: cloudstack_network" 4 | sidebar_current: "docs-cloudstack-resource-network" 5 | description: |- 6 | Creates a network. 7 | --- 8 | 9 | # cloudstack_network 10 | 11 | Creates a network. 12 | 13 | ## Example Usage 14 | 15 | Basic usage: 16 | 17 | ```hcl 18 | resource "cloudstack_network" "default" { 19 | name = "test-network" 20 | cidr = "10.0.0.0/16" 21 | network_offering = "Default Network" 22 | zone = "zone-1" 23 | } 24 | ``` 25 | 26 | ## Argument Reference 27 | 28 | The following arguments are supported: 29 | 30 | * `name` - (Required) The name of the network. 31 | 32 | * `display_text` - (Optional) The display text of the network. 33 | 34 | * `cidr` - (Required) The CIDR block for the network. Changing this forces a new 35 | resource to be created. 36 | 37 | * `gateway` - (Optional) Gateway that will be provided to the instances in this 38 | network. Defaults to the first usable IP in the range. 39 | 40 | * `startip` - (Optional) Start of the IP block that will be available on the 41 | network. Defaults to the second available IP in the range. 42 | 43 | * `endip` - (Optional) End of the IP block that will be available on the 44 | network. Defaults to the last available IP in the range. 45 | 46 | * `network_domain` - (Optional) DNS domain for the network. 47 | 48 | * `network_offering` - (Required) The name or ID of the network offering to use 49 | for this network. 50 | 51 | * `vlan` - (Optional) The VLAN number (1-4095) the network will use. This might be 52 | required by the Network Offering if specifyVlan=true is set. Only the ROOT 53 | admin can set this value. 54 | 55 | * `vpc_id` - (Optional) The VPC ID in which to create this network. Changing 56 | this forces a new resource to be created. 57 | 58 | * `acl_id` - (Optional) The ACL ID that should be attached to the network or 59 | `none` if you do not want to attach an ACL. You can dynamically attach and 60 | swap ACL's, but if you want to detach an attached ACL and revert to using 61 | `none`, this will force a new resource to be created. (defaults `none`) 62 | 63 | * `project` - (Optional) The name or ID of the project to deploy this 64 | instance to. Changing this forces a new resource to be created. 65 | 66 | * `source_nat_ip` - (Optional) If set to `true` a public IP will be associated 67 | with the network. This is mainly used when the network supports the source 68 | NAT service which claims the first associated IP address. This prevents the 69 | ability to manage the IP address as an independent entity. 70 | 71 | * `zone` - (Required) The name or ID of the zone where this network will be 72 | available. Changing this forces a new resource to be created. 73 | 74 | ## Attributes Reference 75 | 76 | The following attributes are exported: 77 | 78 | * `id` - The ID of the network. 79 | * `display_text` - The display text of the network. 80 | * `network_domain` - DNS domain for the network. 81 | * `source_nat_ip_address` - The associated source NAT IP. 82 | * `source_nat_ip_id` - The ID of the associated source NAT IP. 83 | 84 | ## Import 85 | 86 | Networks can be imported; use `` as the import ID. For 87 | example: 88 | 89 | ```shell 90 | terraform import cloudstack_network.default 36619b20-5584-43bf-9a84-e242bacd5582 91 | ``` 92 | 93 | When importing into a project you need to prefix the import ID with the project name: 94 | 95 | ```shell 96 | terraform import cloudstack_network.default my-project/36619b20-5584-43bf-9a84-e242bacd5582 97 | ``` 98 | -------------------------------------------------------------------------------- /website/docs/r/network_offering.html.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | page_title: "CloudStack: cloudstack_network_offering" 4 | sidebar_current: "docs-cloudstack-resource-network_offering" 5 | description: |- 6 | Creates a Network Offering 7 | --- 8 | 9 | # CloudStack: cloudstack_network_offering 10 | 11 | A `cloudstack_network_offering` resource manages a network offering within CloudStack. 12 | 13 | ## Example Usage 14 | 15 | ```hcl 16 | resource "cloudstack_network_offering" "example" { 17 | name = "example-network-offering" 18 | display_text = "Example Network Offering" 19 | guest_ip_type = "Isolated" 20 | traffic_type = "Guest" 21 | network_rate = 100 22 | network_mode = "NATTED" 23 | conserve_mode = true 24 | enable = true 25 | for_vpc = false 26 | specify_vlan = true 27 | specify_ip_ranges = true 28 | max_connections = 256 29 | supported_services = ["Dhcp", "Dns", "Firewall", "Lb", "SourceNat"] 30 | service_provider_list = { 31 | Dhcp = "VirtualRouter" 32 | Dns = "VirtualRouter" 33 | Firewall = "VirtualRouter" 34 | Lb = "VirtualRouter" 35 | SourceNat = "VirtualRouter" 36 | } 37 | } 38 | ``` 39 | 40 | 41 | ## Argument Reference 42 | 43 | The following arguments are supported: 44 | 45 | * `name` - (Required) The name of the network offering. 46 | * `display_text` - (Required) The display text of the network offering. 47 | * `guest_ip_type` - (Required) The type of IP address allocation for the network offering. Possible values are "Shared" or "Isolated". 48 | * `traffic_type` - (Required) The type of traffic for the network offering. Possible values are "Guest" or "Management". 49 | * `network_rate` - (Optional) The network rate in Mbps for the network offering. 50 | * `network_mode` - (Optional) The network mode. Possible values are "DHCP" or "NATTED". 51 | * `conserve_mode` - (Optional) Whether to enable conserve mode. Defaults to `false`. 52 | * `enable` - (Optional) Whether to enable the network offering. Defaults to `false`. 53 | * `for_vpc` - (Optional) Whether this network offering is for VPC. Defaults to `false`. 54 | * `for_nsx` - (Optional) Whether this network offering is for NSX. Defaults to `false`. 55 | * `specify_vlan` - (Optional) Whether to allow specifying VLAN ID. Defaults to `false`. 56 | * `specify_ip_ranges` - (Optional) Whether to allow specifying IP ranges. Defaults to `false`. 57 | * `specify_as_number` - (Optional) Whether to allow specifying AS number. Defaults to `false`. 58 | * `internet_protocol` - (Optional) The internet protocol. Possible values are "IPv4" or "IPv6". Defaults to "IPv4". 59 | * `routing_mode` - (Optional) The routing mode. Possible values are "Static" or "Dynamic". 60 | * `max_connections` - (Optional) The maximum number of concurrent connections supported by the network offering. 61 | * `supported_services` - (Optional) A list of supported services for this network offering. 62 | * `service_provider_list` - (Optional) A map of service providers for the supported services. 63 | 64 | ## Attributes Reference 65 | 66 | The following attributes are exported: 67 | 68 | * `id` - The ID of the network offering. 69 | * `name` - The name of the network offering. 70 | * `display_text` - The display text of the network offering. 71 | * `guest_ip_type` - The type of IP address allocation for the network offering. 72 | * `traffic_type` - The type of traffic for the network offering. 73 | 74 | ## Import 75 | 76 | Network offerings can be imported; use `` as the import ID. For example: 77 | 78 | ```shell 79 | $ terraform import cloudstack_network_offering.example 80 | ``` 81 | --------------------------------------------------------------------------------