From dd83e085e5b13d763f38bbfa832ebb15edcd156a Mon Sep 17 00:00:00 2001 From: Hugh Hamill Date: Thu, 8 Aug 2024 15:01:09 +0100 Subject: [PATCH] Support internal and public NAT rules --- .github/workflows/release.yml | 17 ++- .vscode/launch.json | 62 +++++------ CONTRIBUTING.md | 29 +++-- docs/data-sources/external_dns.md | 16 +-- docs/data-sources/inbound_proxy_rules.md | 17 +-- docs/data-sources/inventory_dns_assets.md | 4 +- docs/data-sources/inventory_srv_protocols.md | 5 +- docs/data-sources/inventory_telephony.md | 6 +- docs/data-sources/ip_nat_rules.md | 8 +- docs/data-sources/mail_servers.md | 13 +-- docs/data-sources/telephony.md | 20 ++-- docs/data-sources/vm_nat_rules.md | 9 +- docs/index.md | 100 +++++++++++++++++- docs/resources/documentation.md | 7 +- docs/resources/external_dns.md | 29 +++-- docs/resources/inbound_proxy_rule.md | 21 ++-- docs/resources/ip_nat_rule.md | 10 +- docs/resources/mail_server.md | 11 +- docs/resources/telephony.md | 8 +- docs/resources/vm_nat_rule.md | 12 ++- examples/README.md | 7 +- .../external_dns_data_source/data-source.tf | 24 ++--- .../data-source.tf | 30 +++--- .../ip_nat_rule_data_source/data-source.tf | 13 +-- .../mail_server_data_source/data-source.tf | 22 ++-- .../telephony_data_source/data-source.tf | 2 +- .../vm_nat_rule_data_source/data-source.tf | 25 ++--- examples/provider/provider.tf | 68 ++++++------ .../documentation_resource/resource.tf | 2 +- .../external_dns_resource/resource.tf | 32 +++--- .../inbound_proxy_rule_resource/resource.tf | 26 ++--- .../ip_nat_rule_resource/resource.tf | 9 +- .../mail_server_resource/resource.tf | 18 ++-- .../resources/telephony_resource/resource.tf | 2 +- .../vm_nat_rule_resource/resource.tf | 21 ++-- go.mod | 2 +- go.sum | 7 +- internal/dcloud/data_source_ip_nat.go | 5 + internal/dcloud/data_source_vm_nat.go | 5 + internal/dcloud/resource_ip_nat.go | 15 +++ internal/dcloud/resource_vm_nat.go | 15 +++ terraform-registry-manifest.json | 10 +- 42 files changed, 477 insertions(+), 287 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6dfa7b5..d2b5ba0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,29 +17,24 @@ on: jobs: goreleaser: permissions: - contents: write + contents: write runs-on: ubuntu-latest steps: - - - name: Checkout + - name: Checkout uses: actions/checkout@v3 - - - name: Unshallow + - name: Unshallow run: git fetch --prune --unshallow - - - name: Set up Go + - name: Set up Go uses: actions/setup-go@v2 with: go-version: 1.18 - - - name: Import GPG key + - name: Import GPG key id: import_gpg uses: crazy-max/ghaction-import-gpg@v5.0.0 with: gpg_private_key: ${{ secrets.TERRAFORM_GPG_PRIVATE_KEY }} passphrase: ${{ secrets.TERRAFORM_GPG_PASSPHRASE }} - - - name: Run GoReleaser + - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2.5.0 with: version: latest diff --git a/.vscode/launch.json b/.vscode/launch.json index da54ddb..a996fa4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,33 +1,33 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Acceptance Tests", - "type": "go", - "request": "launch", - "mode": "test", - // this assumes your workspace is the root of the repo - "program": "${fileDirname}", - "env": { - "TF_ACC": "1", - }, - "args": [], - }, - { - "name": "Debug - Attach External CLI", - "type": "go", - "request": "launch", - "mode": "debug", - // this assumes your workspace is the root of the repo - "program": "${workspaceFolder}", - "env": {}, - "args": [ - // pass the debug flag for reattaching - "-debug", - ], - } - ] + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Acceptance Tests", + "type": "go", + "request": "launch", + "mode": "test", + // this assumes your workspace is the root of the repo + "program": "${fileDirname}", + "env": { + "TF_ACC": "1" + }, + "args": [] + }, + { + "name": "Debug - Attach External CLI", + "type": "go", + "request": "launch", + "mode": "debug", + // this assumes your workspace is the root of the repo + "program": "${workspaceFolder}", + "env": {}, + "args": [ + // pass the debug flag for reattaching + "-debug" + ] + } + ] } \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 42737fc..8abacb8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,8 +1,14 @@ # How to Contribute -Thank you for your interest in contributing to the dCloud Terraform Provider project! To ensure smooth collaboration and effective development, please review the following guidelines. By following these guidelines, you demonstrate respect for the time and efforts of the project's contributors. In return, they will reciprocate by addressing your issues, evaluating changes, and assisting with your pull requests. We strive to review incoming issues and pull requests within 10 days. Any lingering issues or pull requests inactive for 60 days will be closed. +Thank you for your interest in contributing to the dCloud Terraform Provider project! To ensure smooth collaboration and +effective development, please review the following guidelines. By following these guidelines, you demonstrate respect +for the time and efforts of the project's contributors. In return, they will reciprocate by addressing your issues, +evaluating changes, and assisting with your pull requests. We strive to review incoming issues and pull requests within +10 days. Any lingering issues or pull requests inactive for 60 days will be closed. -Please note that all interactions within the project are subject to our [Code of Conduct](/CODE_OF_CONDUCT.md). This applies to creating issues or pull requests, commenting on them, as well as any real-time discussions in platforms like Slack, Discord, etc. +Please note that all interactions within the project are subject to our [Code of Conduct](/CODE_OF_CONDUCT.md). This +applies to creating issues or pull requests, commenting on them, as well as any real-time discussions in platforms like +Slack, Discord, etc. ## Table Of Contents @@ -17,11 +23,15 @@ Please note that all interactions within the project are subject to our [Code of ## Reporting Issues -Before reporting a new issue, please search our [issues list](https://github.com/cisco-open/terraform-provider-dcloud/issues) to ensure that it hasn't already been reported or fixed. +Before reporting a new issue, please search +our [issues list](https://github.com/cisco-open/terraform-provider-dcloud/issues) to ensure that it hasn't already been +reported or fixed. -When creating a new issue, include a clear title, a detailed description, relevant information, and if possible, a test case. +When creating a new issue, include a clear title, a detailed description, relevant information, and if possible, a test +case. -**If you discover a security vulnerability, please refrain from reporting it through GitHub. Instead, follow the security procedures outlined in [SECURITY.md](/SECURITY.md).** +**If you discover a security vulnerability, please refrain from reporting it through GitHub. Instead, follow the +security procedures outlined in [SECURITY.md](/SECURITY.md).** ## Development @@ -46,14 +56,17 @@ To run the example terraform definitions for the dCloud Terraform Provider, do t 1. Navigate to each example directory under `/examples` 2. Execute `terraform init` -3. Create an environment variable to hold your Cisco Authentication Token (use a valid token) `export TB_AUTH_TOKEN=abc123` +3. Create an environment variable to hold your Cisco Authentication Token (use a valid + token) `export TB_AUTH_TOKEN=abc123` 4. Execute `terraform apply` ## Sending Pull Requests -Before submitting a new pull request, please check existing pull requests and issues to ensure that your proposed changes or fixes haven't been discussed in the past or already implemented but not released. +Before submitting a new pull request, please check existing pull requests and issues to ensure that your proposed +changes or fixes haven't been discussed in the past or already implemented but not released. -When submitting a pull request, include tests for any affected behavior. As we follow semantic versioning, breaking changes may be reserved for the next major version release. +When submitting a pull request, include tests for any affected behavior. As we follow semantic versioning, breaking +changes may be reserved for the next major version release. ## Other Ways to Contribute diff --git a/docs/data-sources/external_dns.md b/docs/data-sources/external_dns.md index 28a035d..69f4893 100644 --- a/docs/data-sources/external_dns.md +++ b/docs/data-sources/external_dns.md @@ -3,12 +3,13 @@ page_title: "dcloud_external_dns Data Source - terraform-provider-dcloud" subcategory: "" description: |- - All the dns records currently in a given topology + All the External DNS rules in a given topology --- # dcloud_external_dns (Data Source) -All the dns records currently in a given topology +All the External DNS rules in a given topology + @@ -20,30 +21,29 @@ All the dns records currently in a given topology ### Read-Only -- `id` (String) The ID of this resource. - `external_dns` (List of Object) (see [below for nested schema](#nestedatt--external_dns)) +- `id` (String) The ID of this resource. ### Nested Schema for `external_dns` Read-Only: -- `uid` (String) -- `topology_uid` (String) +- `a_record` (String) - `hostname` (String) - `nat_rule_id` (String) -- `a_record` (String) - `srv_records` (List of Object) (see [below for nested schema](#nestedobjatt--external_dns--srv_records)) - +- `topology_uid` (String) +- `uid` (String) ### Nested Schema for `external_dns.srv_records` Read-Only: +- `port` (Number) - `protocol` (String) - `service` (String) -- `port` (Int) - `uid` (String) diff --git a/docs/data-sources/inbound_proxy_rules.md b/docs/data-sources/inbound_proxy_rules.md index 1d61b36..199c98c 100644 --- a/docs/data-sources/inbound_proxy_rules.md +++ b/docs/data-sources/inbound_proxy_rules.md @@ -3,12 +3,13 @@ page_title: "dcloud_inbound_proxy_rules Data Source - terraform-provider-dcloud" subcategory: "" description: |- - All the Inbound Proxy rules currently in a given topology + All the Inbound Proxy rules in a given topology --- # dcloud_inbound_proxy_rules (Data Source) -All the Inbound Proxy rules currently in a given topology +All the Inbound Proxy rules in a given topology + @@ -28,15 +29,15 @@ All the Inbound Proxy rules currently in a given topology Read-Only: -- `nic_uid` (String) +- `hyperlink` (String) - `nic_ip_address` (String) +- `nic_uid` (String) +- `show_hyperlink` (Boolean) +- `ssl` (Boolean) - `target_vm_name` (String) -- `show_hypperlink` (Bool) -- `ssl` (Bool) -- `url_path` (String) -- `hyperlink` (String) -- `tcp_port` (Integer) +- `tcp_port` (Number) - `topology_uid` (String) - `uid` (String) +- `url_path` (String) diff --git a/docs/data-sources/inventory_dns_assets.md b/docs/data-sources/inventory_dns_assets.md index 811db1a..76924a0 100644 --- a/docs/data-sources/inventory_dns_assets.md +++ b/docs/data-sources/inventory_dns_assets.md @@ -3,12 +3,12 @@ page_title: "dcloud_inventory_dns_assets Data Source - terraform-provider-dcloud" subcategory: "" description: |- - All the inventory dns assets available to be used in a topology + All the Inventory DNS assets in a given topology --- # dcloud_inventory_dns_assets (Data Source) -All the inventory dns assets available to be used in a topology +All the Inventory DNS assets in a given topology diff --git a/docs/data-sources/inventory_srv_protocols.md b/docs/data-sources/inventory_srv_protocols.md index eed0acd..e1f6d35 100644 --- a/docs/data-sources/inventory_srv_protocols.md +++ b/docs/data-sources/inventory_srv_protocols.md @@ -3,19 +3,18 @@ page_title: "dcloud_inventory_srv_protocols Data Source - terraform-provider-dcloud" subcategory: "" description: |- - All the inventory srv protocols available to be used in a topology + All the Inventory SRV protocols in a given topology --- # dcloud_inventory_srv_protocols (Data Source) -All the inventory srv protocols available to be used in a topology +All the Inventory SRV protocols in a given topology ## Schema - ### Read-Only - `id` (String) The ID of this resource. diff --git a/docs/data-sources/inventory_telephony.md b/docs/data-sources/inventory_telephony.md index ee152b7..d8c1356 100644 --- a/docs/data-sources/inventory_telephony.md +++ b/docs/data-sources/inventory_telephony.md @@ -3,12 +3,12 @@ page_title: "dcloud_inventory_telephony Data Source - terraform-provider-dcloud" subcategory: "" description: |- - All the inventory telephony available to be used in a topology + All the inventory Telephony Items available to be used in a topology --- # dcloud_inventory_telephony (Data Source) -All the inventory telephony available to be used in a topology +All the inventory Telephony Items available to be used in a topology @@ -29,8 +29,8 @@ All the inventory telephony available to be used in a topology Read-Only: +- `description` (String) - `id` (String) - `name` (String) -- `description` (String) diff --git a/docs/data-sources/ip_nat_rules.md b/docs/data-sources/ip_nat_rules.md index 7acfea5..44ebaf3 100644 --- a/docs/data-sources/ip_nat_rules.md +++ b/docs/data-sources/ip_nat_rules.md @@ -3,12 +3,13 @@ page_title: "dcloud_ip_nat_rules Data Source - terraform-provider-dcloud" subcategory: "" description: |- - All the IP Nat rules currently in a given topology + All the IP Nat rules in a given topology --- # dcloud_ip_nat_rules (Data Source) -All the IP Nat rules currently in a given topology +All the IP Nat rules in a given topology + @@ -28,9 +29,10 @@ All the IP Nat rules currently in a given topology Read-Only: +- `east_west` (Boolean) +- `scope` (String) - `target_ip_address` (String) - `target_name` (String) -- `east_west` (Bool) - `topology_uid` (String) - `uid` (String) diff --git a/docs/data-sources/mail_servers.md b/docs/data-sources/mail_servers.md index f1b8468..07079dc 100644 --- a/docs/data-sources/mail_servers.md +++ b/docs/data-sources/mail_servers.md @@ -3,12 +3,13 @@ page_title: "dcloud_mail_servers Data Source - terraform-provider-dcloud" subcategory: "" description: |- - All the Mail servers currently in a given topology + All the Mail Servers in a given topology --- # dcloud_mail_servers (Data Source) -All the Mail servers currently in a given topology +All the Mail Servers in a given topology + @@ -21,16 +22,16 @@ All the Mail servers currently in a given topology ### Read-Only - `id` (String) The ID of this resource. -- `mail-servers` (List of Object) (see [below for nested schema](#nestedatt--mail-servers)) +- `mail_servers` (List of Object) (see [below for nested schema](#nestedatt--mail_servers)) - -### Nested Schema for `mail-servers` + +### Nested Schema for `mail_servers` Read-Only: -- `nic_uid` (String) - `dns_asset_id` (String) - `dns_asset_name` (String) +- `nic_uid` (String) - `topology_uid` (String) - `uid` (String) diff --git a/docs/data-sources/telephony.md b/docs/data-sources/telephony.md index 115f677..e5970a3 100644 --- a/docs/data-sources/telephony.md +++ b/docs/data-sources/telephony.md @@ -3,12 +3,12 @@ page_title: "dcloud_telephony Data Source - terraform-provider-dcloud" subcategory: "" description: |- - All the telephony items currently in a given topology + All the Telephony Items currently in a given topology --- # dcloud_telephony (Data Source) -All the telephony items currently in a given topology +All the Telephony Items currently in a given topology @@ -22,16 +22,18 @@ All the telephony items currently in a given topology ### Read-Only - `id` (String) The ID of this resource. -- `telephony-items` (List of Object) (see [below for nested schema](#nestedatt--telephonyItems)) +- `telephony_items` (List of Object) (see [below for nested schema](#nestedatt--telephony_items)) - -### Nested Schema for `telephonyItems` + +### Nested Schema for `telephony_items` Read-Only: -- `topology_uid` (String) -- `uid` (String) -- `name` (String) +- `inventory_telephony_description` (String) - `inventory_telephony_id` (String) - `inventory_telephony_name` (String) -- `inventory_description_name` (String) \ No newline at end of file +- `name` (String) +- `topology_uid` (String) +- `uid` (String) + + diff --git a/docs/data-sources/vm_nat_rules.md b/docs/data-sources/vm_nat_rules.md index d134a52..fd3fb5e 100644 --- a/docs/data-sources/vm_nat_rules.md +++ b/docs/data-sources/vm_nat_rules.md @@ -3,12 +3,12 @@ page_title: "dcloud_vm_nat_rules Data Source - terraform-provider-dcloud" subcategory: "" description: |- - All the VM Nat rules currently in a given topology + All the VM Nat rules in a given topology --- # dcloud_vm_nat_rules (Data Source) -All the VM Nat rules currently in a given topology +All the VM Nat rules in a given topology @@ -29,10 +29,11 @@ All the VM Nat rules currently in a given topology Read-Only: +- `east_west` (Boolean) +- `nic_uid` (String) +- `scope` (String) - `target_ip_address` (String) - `target_name` (String) -- `nic_uid` (String) -- `east_west` (Bool) - `topology_uid` (String) - `uid` (String) diff --git a/docs/index.md b/docs/index.md index 7f67fa6..cf77a03 100644 --- a/docs/index.md +++ b/docs/index.md @@ -123,11 +123,56 @@ resource "dcloud_vm" "vm2" { network_interfaces { network_uid = dcloud_network.routed_network.id name = "Network adapter 0" - mac_address = "00:50:56:00:01:AF" + mac_address = "00:50:56:00:02:AF" type = "VIRTUAL_E1000" } + + network_interfaces { + network_uid = dcloud_network.unrouted_network.id + name = "Network adapter 1" + mac_address = "00:50:56:00:02:AB" + type = "VIRTUAL_E1000" + ip_address = "127.0.0.3" + ssh_enabled = true + rdp_enabled = true + rdp_auto_login = true + } } +resource "dcloud_vm" "vm3" { + inventory_vm_id = "7668085" + topology_uid = dcloud_topology.test_topology.id + name = "Ubuntu Desktop 3" + description = "A standard Ubuntu Desktop VM" + cpu_qty = 1 + memory_mb = 1024 + + network_interfaces { + network_uid = dcloud_network.unrouted_network.id + name = "Network adapter 1" + mac_address = "00:50:56:00:03:AA" + type = "VIRTUAL_E1000" + ip_address = "127.0.0.4" + ssh_enabled = true + rdp_enabled = true + rdp_auto_login = true + } + + advanced_settings { + all_disks_non_persistent = false + bios_uuid = "42 3a 5f 9d f1 a8 7c 0e-7d c2 44 27 2e d6 67 aa" + name_in_hypervisor = "ubuntu" + not_started = false + } + + remote_access { + vm_console_enabled = true + display_credentials { + username = "displayuser" + password = "displaypassword" + } + } +} resource "dcloud_hw" "hw1" { topology_uid = dcloud_topology.test_topology.id @@ -151,7 +196,6 @@ resource "dcloud_hw" "hw2" { name = "UCS Hardware Pod" } - resource "dcloud_license" "mc_license" { quantity = 3 inventory_license_id = "340" @@ -228,6 +272,58 @@ resource "dcloud_scenario" "scenario" { display_name = "Launch Demo Context2" } } + +resource "dcloud_documentation" "documentation" { + topology_uid = dcloud_topology.test_topology.id + doc_url = "https://johndoe.com" +} + +resource "dcloud_telephony" "telephony" { + topology_uid = dcloud_topology.test_topology.id + inventory_telephony_id = "1" +} + +resource "dcloud_ip_nat_rule" "ip_nat_rule" { + topology_uid = dcloud_topology.test_topology.id + target_ip_address = "192.168.1.1" + target_name = "Sample Device" + east_west = false + scope = "PUBLIC" +} + +resource "dcloud_vm_nat_rule" "vm_nat_rule" { + topology_uid = dcloud_topology.test_topology.id + nic_uid = dcloud_vm.vm1.network_interfaces[1].uid + east_west = true + scope = "INTERNAL" +} + +resource "dcloud_inbound_proxy_rule" "inbound_proxy_rule" { + topology_uid = dcloud_topology.test_topology.id + nic_uid = dcloud_vm.vm2.network_interfaces[1].uid + tcp_port = 443 + url_path = "/testing/url/" + hyperlink = "Test Hyperlink" + ssl = true + show_hyperlink = true +} + +resource "dcloud_external_dns" "external_dns" { + topology_uid = dcloud_topology.test_topology.id + nat_rule_id = dcloud_ip_nat_rule.ip_nat_rule.id + hostname = "localhost" + srv_records { + service = "_test" + protocol = "TCP" + port = 8081 + } +} + +resource "dcloud_mail_server" "mail_server" { + topology_uid = dcloud_topology.test_topology.id + nic_uid = dcloud_vm.vm3.network_interfaces[0].uid + dns_asset_id = "3" +} ``` diff --git a/docs/resources/documentation.md b/docs/resources/documentation.md index 61b79bf..82196a8 100644 --- a/docs/resources/documentation.md +++ b/docs/resources/documentation.md @@ -1,6 +1,6 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "dcloud_topology Resource - terraform-provider-dcloud" +page_title: "dcloud_documentation Resource - terraform-provider-dcloud" subcategory: "" description: |- @@ -10,17 +10,18 @@ description: |- + + ## Schema ### Required -- `topology_uid` (String) - `doc_url` (String) +- `topology_uid` (String) ### Read-Only - `id` (String) The ID of this resource. -- `uid` (String) diff --git a/docs/resources/external_dns.md b/docs/resources/external_dns.md index 43445a3..dffae2d 100644 --- a/docs/resources/external_dns.md +++ b/docs/resources/external_dns.md @@ -1,12 +1,15 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "dcloud_mail_server Resource - terraform-provider-dcloud" +page_title: "dcloud_external_dns Resource - terraform-provider-dcloud" subcategory: "" description: |- --- -# dcloud_mail_server (Resource) +# dcloud_external_dns (Resource) + + + @@ -14,25 +17,31 @@ description: |- ### Required -- `nat_rule_id` (String) - `hostname` (String) +- `nat_rule_id` (String) - `topology_uid` (String) ### Optional -- `srv_records` (Block List, Min: 1) (see [below for nested schema](#nestedblock--srv_records)) +- `srv_records` (Block List) (see [below for nested schema](#nestedblock--srv_records)) + +### Read-Only + +- `a_record` (String) +- `id` (String) The ID of this resource. +- `uid` (String) ### Nested Schema for `srv_records` Required: -- `protocol` (Boolean) +- `port` (Number) +- `protocol` (String) - `service` (String) -- `port` (Int) -### Read-Only +Read-Only: + +- `uid` (String) + -- `id` (String) The ID of this resource. -- `a_record` (String) -- `uid` (String) \ No newline at end of file diff --git a/docs/resources/inbound_proxy_rule.md b/docs/resources/inbound_proxy_rule.md index d6658bc..f8d4b5f 100644 --- a/docs/resources/inbound_proxy_rule.md +++ b/docs/resources/inbound_proxy_rule.md @@ -1,12 +1,15 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "dcloud_inbound_proxy_rules Resource - terraform-provider-dcloud" +page_title: "dcloud_inbound_proxy_rule Resource - terraform-provider-dcloud" subcategory: "" description: |- --- -# dcloud_inbound_proxy_rules (Resource) +# dcloud_inbound_proxy_rule (Resource) + + + @@ -14,22 +17,22 @@ description: |- ### Required -- `nic_uid` (String) -- `url_path` (String) - `hyperlink` (String) -- `tcp_port` (Integer) +- `nic_uid` (String) +- `tcp_port` (Number) - `topology_uid` (String) +- `url_path` (String) ### Optional -- `ssl` (Bool) -- `show_hyperlink` (String) +- `show_hyperlink` (Boolean) +- `ssl` (Boolean) ### Read-Only - `id` (String) The ID of this resource. -- `uid` (String) +- `nic_ip_address` (String) - `target_vm_name` (String) - +- `uid` (String) diff --git a/docs/resources/ip_nat_rule.md b/docs/resources/ip_nat_rule.md index aeae0f3..6c28545 100644 --- a/docs/resources/ip_nat_rule.md +++ b/docs/resources/ip_nat_rule.md @@ -9,20 +9,26 @@ description: |- # dcloud_ip_nat_rule (Resource) + + + ## Schema ### Required +- `east_west` (Boolean) - `target_ip_address` (String) - `target_name` (String) -- `east_west` (Bool) - `topology_uid` (String) +### Optional + +- `scope` (String) The scope of the NAT rule, PUBLIC (default) or INTERNAL + ### Read-Only - `id` (String) The ID of this resource. - `uid` (String) - diff --git a/docs/resources/mail_server.md b/docs/resources/mail_server.md index f585456..913cd96 100644 --- a/docs/resources/mail_server.md +++ b/docs/resources/mail_server.md @@ -9,17 +9,22 @@ description: |- # dcloud_mail_server (Resource) + + + ## Schema ### Required -- `nic_uid` (String) - `dns_asset_id` (String) +- `nic_uid` (String) - `topology_uid` (String) ### Read-Only -- `id` (String) The ID of this resource. - `dns_asset_name` (String) -- `uid` (String) \ No newline at end of file +- `id` (String) The ID of this resource. +- `uid` (String) + + diff --git a/docs/resources/telephony.md b/docs/resources/telephony.md index 4c04097..8740d69 100644 --- a/docs/resources/telephony.md +++ b/docs/resources/telephony.md @@ -17,15 +17,15 @@ description: |- ### Required -- `topology_uid` (String) - `inventory_telephony_id` (String) +- `topology_uid` (String) ### Read-Only - `id` (String) The ID of this resource. -- `uid` (String) -- `name` (String) -- `inventory_telephony_name` (String) - `inventory_telephony_description` (String) +- `inventory_telephony_name` (String) +- `name` (String) +- `uid` (String) diff --git a/docs/resources/vm_nat_rule.md b/docs/resources/vm_nat_rule.md index c7ce86a..7968569 100644 --- a/docs/resources/vm_nat_rule.md +++ b/docs/resources/vm_nat_rule.md @@ -9,21 +9,27 @@ description: |- # dcloud_vm_nat_rule (Resource) + + + ## Schema ### Required +- `east_west` (Boolean) - `nic_uid` (String) -- `east_west` (Bool) - `topology_uid` (String) +### Optional + +- `scope` (String) The scope of the NAT rule, PUBLIC (default) or INTERNAL + ### Read-Only - `id` (String) The ID of this resource. -- `uid` (String) - `target_ip_address` (String) - `target_name` (String) - +- `uid` (String) diff --git a/examples/README.md b/examples/README.md index 39aed72..bad79ad 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,8 +1,11 @@ # Examples -This directory contains examples that are mostly used for documentation, but can also be run/tested manually via the Terraform CLI. +This directory contains examples that are mostly used for documentation, but can also be run/tested manually via the +Terraform CLI. -The document generation tool looks for files in the following locations by default. All other *.tf files besides the ones mentioned below are ignored by the documentation tool. This is useful for creating examples that can run and/or ar testable even if some parts are not relevant for the documentation. +The document generation tool looks for files in the following locations by default. All other *.tf files besides the +ones mentioned below are ignored by the documentation tool. This is useful for creating examples that can run and/or ar +testable even if some parts are not relevant for the documentation. * **provider/provider.tf** example file for the provider index page * **data-sources//data-source.tf** example file for the named data source page diff --git a/examples/data-sources/external_dns_data_source/data-source.tf b/examples/data-sources/external_dns_data_source/data-source.tf index e4a784d..01f0938 100644 --- a/examples/data-sources/external_dns_data_source/data-source.tf +++ b/examples/data-sources/external_dns_data_source/data-source.tf @@ -18,26 +18,26 @@ resource "dcloud_topology" "test_topology" { datacenter = "LON" } -resource "dcloud_ip_nat_rule" "test_topology_ip_nat_rule"{ - topology_uid = dcloud_topology.test_topology.id +resource "dcloud_ip_nat_rule" "test_topology_ip_nat_rule" { + topology_uid = dcloud_topology.test_topology.id target_ip_address = "192.168.1.1" - target_name = "Sample Device" - east_west = false + target_name = "Sample Device" + east_west = false } -resource "dcloud_external_dns" "test_topology_external_dns"{ +resource "dcloud_external_dns" "test_topology_external_dns" { topology_uid = dcloud_topology.test_topology.id - nat_rule_id = dcloud_ip_nat_rule.test_topology_ip_nat_rule.id - hostname = "localhost" - srv_records{ - service = "_test" + nat_rule_id = dcloud_ip_nat_rule.test_topology_ip_nat_rule.id + hostname = "localhost" + srv_records { + service = "_test" protocol = "TCP" - port = 8081 + port = 8081 } } -data "dcloud_external_dns" "external_dns_test"{ - depends_on = [dcloud_external_dns.test_topology_external_dns] +data "dcloud_external_dns" "external_dns_test" { + depends_on = [dcloud_external_dns.test_topology_external_dns] topology_uid = dcloud_topology.test_topology.id } diff --git a/examples/data-sources/inbound_proxy_rule_data_source/data-source.tf b/examples/data-sources/inbound_proxy_rule_data_source/data-source.tf index 5ed350f..4d3ea66 100644 --- a/examples/data-sources/inbound_proxy_rule_data_source/data-source.tf +++ b/examples/data-sources/inbound_proxy_rule_data_source/data-source.tf @@ -26,14 +26,14 @@ resource "dcloud_network" "unrouted_network" { } resource "dcloud_vm" "vm1" { - inventory_vm_id = "7668085" - topology_uid = dcloud_topology.test_topology.id - name = "Ubuntu Desktop 1" - description = "A standard Ubuntu Desktop VM" - cpu_qty = 1 - memory_mb = 1024 + inventory_vm_id = "7668085" + topology_uid = dcloud_topology.test_topology.id + name = "Ubuntu Desktop 1" + description = "A standard Ubuntu Desktop VM" + cpu_qty = 1 + memory_mb = 1024 - network_interfaces{ + network_interfaces { network_uid = dcloud_network.unrouted_network.id name = "Network adapter 1" mac_address = "00:50:56:00:03:AA" @@ -61,19 +61,19 @@ resource "dcloud_vm" "vm1" { } -resource "dcloud_inbound_proxy_rule" "test_topology_inbound_proxy_rule"{ - topology_uid = dcloud_topology.test_topology.id - nic_uid = dcloud_vm.vm1.network_interfaces[0].uid - tcp_port = 443 - url_path = "/testing/url/" - hyperlink = "Test Hyperlink" - ssl = true +resource "dcloud_inbound_proxy_rule" "test_topology_inbound_proxy_rule" { + topology_uid = dcloud_topology.test_topology.id + nic_uid = dcloud_vm.vm1.network_interfaces[0].uid + tcp_port = 443 + url_path = "/testing/url/" + hyperlink = "Test Hyperlink" + ssl = true show_hyperlink = true } data "dcloud_inbound_proxy_rules" "test_topology_inbound_proxy" { topology_uid = dcloud_topology.test_topology.id - depends_on = [dcloud_inbound_proxy_rule.test_topology_inbound_proxy_rule] + depends_on = [dcloud_inbound_proxy_rule.test_topology_inbound_proxy_rule] } output "inbound_proxy_rules" { diff --git a/examples/data-sources/ip_nat_rule_data_source/data-source.tf b/examples/data-sources/ip_nat_rule_data_source/data-source.tf index 8b38e1a..e8caa6d 100644 --- a/examples/data-sources/ip_nat_rule_data_source/data-source.tf +++ b/examples/data-sources/ip_nat_rule_data_source/data-source.tf @@ -18,16 +18,17 @@ resource "dcloud_topology" "test_topology" { datacenter = "LON" } -resource "dcloud_ip_nat_rule" "ip_nat"{ - topology_uid = dcloud_topology.test_topology.id +resource "dcloud_ip_nat_rule" "ip_nat" { + topology_uid = dcloud_topology.test_topology.id target_ip_address = "192.168.1.1" - target_name = "Sample Device" - east_west = true + target_name = "Sample Device" + east_west = true + scope = "INTERNAL" } -data "dcloud_ip_nat_rules" "test_topology_ip_nat_rules"{ +data "dcloud_ip_nat_rules" "test_topology_ip_nat_rules" { topology_uid = dcloud_topology.test_topology.id - depends_on = [dcloud_ip_nat_rule.ip_nat] + depends_on = [dcloud_ip_nat_rule.ip_nat] } output "ip_nat_rules" { diff --git a/examples/data-sources/mail_server_data_source/data-source.tf b/examples/data-sources/mail_server_data_source/data-source.tf index 1cb7100..64ede00 100644 --- a/examples/data-sources/mail_server_data_source/data-source.tf +++ b/examples/data-sources/mail_server_data_source/data-source.tf @@ -26,14 +26,14 @@ resource "dcloud_network" "unrouted_network" { } resource "dcloud_vm" "vm1" { - inventory_vm_id = "7668085" - topology_uid = dcloud_topology.test_topology.id - name = "Ubuntu Desktop 1" - description = "A standard Ubuntu Desktop VM" - cpu_qty = 1 - memory_mb = 1024 + inventory_vm_id = "7668085" + topology_uid = dcloud_topology.test_topology.id + name = "Ubuntu Desktop 1" + description = "A standard Ubuntu Desktop VM" + cpu_qty = 1 + memory_mb = 1024 - network_interfaces{ + network_interfaces { network_uid = dcloud_network.unrouted_network.id name = "Network adapter 1" mac_address = "00:50:56:00:03:AA" @@ -61,15 +61,15 @@ resource "dcloud_vm" "vm1" { } -resource "dcloud_mail_server" "mail_server"{ +resource "dcloud_mail_server" "mail_server" { topology_uid = dcloud_topology.test_topology.id - nic_uid = dcloud_vm.vm1.network_interfaces[0].uid + nic_uid = dcloud_vm.vm1.network_interfaces[0].uid dns_asset_id = "3" } -data "dcloud_mail_servers" "test_topology_mail_server"{ +data "dcloud_mail_servers" "test_topology_mail_server" { topology_uid = dcloud_topology.test_topology.id - depends_on = [dcloud_mail_server.mail_server] + depends_on = [dcloud_mail_server.mail_server] } output "mail_servers" { diff --git a/examples/data-sources/telephony_data_source/data-source.tf b/examples/data-sources/telephony_data_source/data-source.tf index ba5e76b..0ab435f 100644 --- a/examples/data-sources/telephony_data_source/data-source.tf +++ b/examples/data-sources/telephony_data_source/data-source.tf @@ -19,7 +19,7 @@ resource "dcloud_topology" "test_topology" { } resource "dcloud_telephony" "test_telephony" { - topology_uid = dcloud_topology.test_topology.id + topology_uid = dcloud_topology.test_topology.id inventory_telephony_id = "1" } diff --git a/examples/data-sources/vm_nat_rule_data_source/data-source.tf b/examples/data-sources/vm_nat_rule_data_source/data-source.tf index 1872de4..a73608a 100644 --- a/examples/data-sources/vm_nat_rule_data_source/data-source.tf +++ b/examples/data-sources/vm_nat_rule_data_source/data-source.tf @@ -26,14 +26,14 @@ resource "dcloud_network" "unrouted_network" { } resource "dcloud_vm" "vm1" { - inventory_vm_id = "7668085" - topology_uid = dcloud_topology.test_topology.id - name = "Ubuntu Desktop 1" - description = "A standard Ubuntu Desktop VM" - cpu_qty = 1 - memory_mb = 1024 + inventory_vm_id = "7668085" + topology_uid = dcloud_topology.test_topology.id + name = "Ubuntu Desktop 1" + description = "A standard Ubuntu Desktop VM" + cpu_qty = 1 + memory_mb = 1024 - network_interfaces{ + network_interfaces { network_uid = dcloud_network.unrouted_network.id name = "Network adapter 1" mac_address = "00:50:56:00:03:AA" @@ -61,15 +61,16 @@ resource "dcloud_vm" "vm1" { } -resource "dcloud_vm_nat_rule" "vm_nat_rule"{ +resource "dcloud_vm_nat_rule" "vm_nat_rule" { topology_uid = dcloud_topology.test_topology.id - nic_uid = dcloud_vm.vm1.network_interfaces[0].uid - east_west = true + nic_uid = dcloud_vm.vm1.network_interfaces[0].uid + east_west = true + scope = "PUBLIC" } -data "dcloud_vm_nat_rules" "test_topology_vm_nat_rules"{ +data "dcloud_vm_nat_rules" "test_topology_vm_nat_rules" { topology_uid = dcloud_topology.test_topology.id - depends_on = [dcloud_vm_nat_rule.vm_nat_rule] + depends_on = [dcloud_vm_nat_rule.vm_nat_rule] } output "vm_nat_rules" { diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index d87bc58..cf1d5c5 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -56,7 +56,7 @@ resource "dcloud_vm" "vm1" { type = "VIRTUAL_E1000" } - network_interfaces{ + network_interfaces { network_uid = dcloud_network.unrouted_network.id name = "Network adapter 1" mac_address = "00:50:56:00:01:AB" @@ -112,7 +112,7 @@ resource "dcloud_vm" "vm2" { type = "VIRTUAL_E1000" } - network_interfaces{ + network_interfaces { network_uid = dcloud_network.unrouted_network.id name = "Network adapter 1" mac_address = "00:50:56:00:02:AB" @@ -125,14 +125,14 @@ resource "dcloud_vm" "vm2" { } resource "dcloud_vm" "vm3" { - inventory_vm_id = "7668085" - topology_uid = dcloud_topology.test_topology.id - name = "Ubuntu Desktop 3" - description = "A standard Ubuntu Desktop VM" - cpu_qty = 1 - memory_mb = 1024 + inventory_vm_id = "7668085" + topology_uid = dcloud_topology.test_topology.id + name = "Ubuntu Desktop 3" + description = "A standard Ubuntu Desktop VM" + cpu_qty = 1 + memory_mb = 1024 - network_interfaces{ + network_interfaces { network_uid = dcloud_network.unrouted_network.id name = "Network adapter 1" mac_address = "00:50:56:00:03:AA" @@ -260,50 +260,52 @@ resource "dcloud_scenario" "scenario" { resource "dcloud_documentation" "documentation" { topology_uid = dcloud_topology.test_topology.id - doc_url = "https://johndoe.com" + doc_url = "https://johndoe.com" } resource "dcloud_telephony" "telephony" { - topology_uid = dcloud_topology.test_topology.id + topology_uid = dcloud_topology.test_topology.id inventory_telephony_id = "1" } -resource "dcloud_ip_nat_rule" "ip_nat_rule"{ - topology_uid = dcloud_topology.test_topology.id +resource "dcloud_ip_nat_rule" "ip_nat_rule" { + topology_uid = dcloud_topology.test_topology.id target_ip_address = "192.168.1.1" - target_name = "Sample Device" - east_west = false + target_name = "Sample Device" + east_west = false + scope = "PUBLIC" } -resource "dcloud_vm_nat_rule" "vm_nat_rule"{ +resource "dcloud_vm_nat_rule" "vm_nat_rule" { topology_uid = dcloud_topology.test_topology.id - nic_uid = dcloud_vm.vm1.network_interfaces[1].uid - east_west = true + nic_uid = dcloud_vm.vm1.network_interfaces[1].uid + east_west = true + scope = "INTERNAL" } -resource "dcloud_inbound_proxy_rule" "inbound_proxy_rule"{ - topology_uid = dcloud_topology.test_topology.id - nic_uid = dcloud_vm.vm2.network_interfaces[1].uid - tcp_port = 443 - url_path = "/testing/url/" - hyperlink = "Test Hyperlink" - ssl = true +resource "dcloud_inbound_proxy_rule" "inbound_proxy_rule" { + topology_uid = dcloud_topology.test_topology.id + nic_uid = dcloud_vm.vm2.network_interfaces[1].uid + tcp_port = 443 + url_path = "/testing/url/" + hyperlink = "Test Hyperlink" + ssl = true show_hyperlink = true } -resource "dcloud_external_dns" "external_dns"{ +resource "dcloud_external_dns" "external_dns" { topology_uid = dcloud_topology.test_topology.id - nat_rule_id = dcloud_ip_nat_rule.ip_nat_rule.id - hostname = "localhost" - srv_records{ - service = "_test" + nat_rule_id = dcloud_ip_nat_rule.ip_nat_rule.id + hostname = "localhost" + srv_records { + service = "_test" protocol = "TCP" - port = 8081 + port = 8081 } } -resource "dcloud_mail_server" "mail_server"{ +resource "dcloud_mail_server" "mail_server" { topology_uid = dcloud_topology.test_topology.id - nic_uid = dcloud_vm.vm3.network_interfaces[0].uid + nic_uid = dcloud_vm.vm3.network_interfaces[0].uid dns_asset_id = "3" } diff --git a/examples/resources/documentation_resource/resource.tf b/examples/resources/documentation_resource/resource.tf index 6446069..e36c136 100644 --- a/examples/resources/documentation_resource/resource.tf +++ b/examples/resources/documentation_resource/resource.tf @@ -20,5 +20,5 @@ resource "dcloud_topology" "test_topology" { resource "dcloud_documentation" "test_documentation" { topology_uid = dcloud_topology.test_topology.id - doc_url = "https://johndoe.com" + doc_url = "https://johndoe.com" } \ No newline at end of file diff --git a/examples/resources/external_dns_resource/resource.tf b/examples/resources/external_dns_resource/resource.tf index ce33141..d14fc92 100644 --- a/examples/resources/external_dns_resource/resource.tf +++ b/examples/resources/external_dns_resource/resource.tf @@ -26,14 +26,14 @@ resource "dcloud_network" "unrouted_network" { } resource "dcloud_vm" "vm1" { - inventory_vm_id = "7668085" - topology_uid = dcloud_topology.test_topology.id - name = "Ubuntu Desktop 1" - description = "A standard Ubuntu Desktop VM" - cpu_qty = 1 - memory_mb = 1024 + inventory_vm_id = "7668085" + topology_uid = dcloud_topology.test_topology.id + name = "Ubuntu Desktop 1" + description = "A standard Ubuntu Desktop VM" + cpu_qty = 1 + memory_mb = 1024 - network_interfaces{ + network_interfaces { network_uid = dcloud_network.unrouted_network.id name = "Network adapter 1" mac_address = "00:50:56:00:03:AA" @@ -61,19 +61,19 @@ resource "dcloud_vm" "vm1" { } -resource "dcloud_vm_nat_rule" "test_vm_nat"{ +resource "dcloud_vm_nat_rule" "test_vm_nat" { topology_uid = dcloud_topology.test_topology.id - nic_uid = dcloud_vm.vm1.network_interfaces[0].uid - east_west = true + nic_uid = dcloud_vm.vm1.network_interfaces[0].uid + east_west = true } -resource "dcloud_external_dns" "test_external_dns"{ +resource "dcloud_external_dns" "test_external_dns" { topology_uid = dcloud_topology.test_topology.id - nat_rule_id = dcloud_vm_nat_rule.test_vm_nat.id - hostname = "localhost" - srv_records{ - service = "_test" + nat_rule_id = dcloud_vm_nat_rule.test_vm_nat.id + hostname = "localhost" + srv_records { + service = "_test" protocol = "TCP" - port = 8081 + port = 8081 } } \ No newline at end of file diff --git a/examples/resources/inbound_proxy_rule_resource/resource.tf b/examples/resources/inbound_proxy_rule_resource/resource.tf index cc418fe..967ff97 100644 --- a/examples/resources/inbound_proxy_rule_resource/resource.tf +++ b/examples/resources/inbound_proxy_rule_resource/resource.tf @@ -26,14 +26,14 @@ resource "dcloud_network" "unrouted_network" { } resource "dcloud_vm" "vm1" { - inventory_vm_id = "7668085" - topology_uid = dcloud_topology.test_topology.id - name = "Ubuntu Desktop 1" - description = "A standard Ubuntu Desktop VM" - cpu_qty = 1 - memory_mb = 1024 + inventory_vm_id = "7668085" + topology_uid = dcloud_topology.test_topology.id + name = "Ubuntu Desktop 1" + description = "A standard Ubuntu Desktop VM" + cpu_qty = 1 + memory_mb = 1024 - network_interfaces{ + network_interfaces { network_uid = dcloud_network.unrouted_network.id name = "Network adapter 1" mac_address = "00:50:56:00:03:AA" @@ -61,11 +61,11 @@ resource "dcloud_vm" "vm1" { } -resource "dcloud_inbound_proxy_rule" "inbound_proxy_rule"{ +resource "dcloud_inbound_proxy_rule" "inbound_proxy_rule" { topology_uid = dcloud_topology.test_topology.id - nic_uid = dcloud_vm.vm1.network_interfaces[0].uid - tcp_port = 443 - url_path = "/testing/url/" - hyperlink = "Click Me" - ssl = true + nic_uid = dcloud_vm.vm1.network_interfaces[0].uid + tcp_port = 443 + url_path = "/testing/url/" + hyperlink = "Click Me" + ssl = true } \ No newline at end of file diff --git a/examples/resources/ip_nat_rule_resource/resource.tf b/examples/resources/ip_nat_rule_resource/resource.tf index ca86c8e..42ede13 100644 --- a/examples/resources/ip_nat_rule_resource/resource.tf +++ b/examples/resources/ip_nat_rule_resource/resource.tf @@ -18,9 +18,10 @@ resource "dcloud_topology" "test_topology" { datacenter = "LON" } -resource "dcloud_ip_nat_rule" "test_ip_nat"{ - topology_uid = dcloud_topology.test_topology.id +resource "dcloud_ip_nat_rule" "test_ip_nat" { + topology_uid = dcloud_topology.test_topology.id target_ip_address = "192.168.1.1" - target_name = "Sample Device" - east_west = true + target_name = "Sample Device" + east_west = true + scope = "PUBLIC" } \ No newline at end of file diff --git a/examples/resources/mail_server_resource/resource.tf b/examples/resources/mail_server_resource/resource.tf index e2647fa..b000af3 100644 --- a/examples/resources/mail_server_resource/resource.tf +++ b/examples/resources/mail_server_resource/resource.tf @@ -26,14 +26,14 @@ resource "dcloud_network" "unrouted_network" { } resource "dcloud_vm" "vm1" { - inventory_vm_id = "7668085" - topology_uid = dcloud_topology.test_topology.id - name = "Ubuntu Desktop 1" - description = "A standard Ubuntu Desktop VM" - cpu_qty = 1 - memory_mb = 1024 + inventory_vm_id = "7668085" + topology_uid = dcloud_topology.test_topology.id + name = "Ubuntu Desktop 1" + description = "A standard Ubuntu Desktop VM" + cpu_qty = 1 + memory_mb = 1024 - network_interfaces{ + network_interfaces { network_uid = dcloud_network.unrouted_network.id name = "Network adapter 1" mac_address = "00:50:56:00:03:AA" @@ -61,8 +61,8 @@ resource "dcloud_vm" "vm1" { } -resource "dcloud_mail_server" "mail_server"{ +resource "dcloud_mail_server" "mail_server" { topology_uid = dcloud_topology.test_topology.id - nic_uid = dcloud_vm.vm1.network_interfaces[0].uid + nic_uid = dcloud_vm.vm1.network_interfaces[0].uid dns_asset_id = "3" } \ No newline at end of file diff --git a/examples/resources/telephony_resource/resource.tf b/examples/resources/telephony_resource/resource.tf index dd939aa..c8c208d 100644 --- a/examples/resources/telephony_resource/resource.tf +++ b/examples/resources/telephony_resource/resource.tf @@ -20,5 +20,5 @@ resource "dcloud_topology" "test_topology" { resource "dcloud_telephony" "test_telephony" { inventory_telephony_id = "1" - topology_uid = dcloud_topology.test_topology.id + topology_uid = dcloud_topology.test_topology.id } \ No newline at end of file diff --git a/examples/resources/vm_nat_rule_resource/resource.tf b/examples/resources/vm_nat_rule_resource/resource.tf index c92c654..5539efa 100644 --- a/examples/resources/vm_nat_rule_resource/resource.tf +++ b/examples/resources/vm_nat_rule_resource/resource.tf @@ -26,14 +26,14 @@ resource "dcloud_network" "unrouted_network" { } resource "dcloud_vm" "vm1" { - inventory_vm_id = "7668085" - topology_uid = dcloud_topology.test_topology.id - name = "Ubuntu Desktop 1" - description = "A standard Ubuntu Desktop VM" - cpu_qty = 1 - memory_mb = 1024 + inventory_vm_id = "7668085" + topology_uid = dcloud_topology.test_topology.id + name = "Ubuntu Desktop 1" + description = "A standard Ubuntu Desktop VM" + cpu_qty = 1 + memory_mb = 1024 - network_interfaces{ + network_interfaces { network_uid = dcloud_network.unrouted_network.id name = "Network adapter 1" mac_address = "00:50:56:00:03:AA" @@ -61,8 +61,9 @@ resource "dcloud_vm" "vm1" { } -resource "dcloud_vm_nat_rule" "test_vm_nat"{ +resource "dcloud_vm_nat_rule" "test_vm_nat" { topology_uid = dcloud_topology.test_topology.id - nic_uid = dcloud_vm.vm1.network_interfaces[0].uid - east_west = true + nic_uid = dcloud_vm.vm1.network_interfaces[0].uid + east_west = true + scope = "INTERNAL" } \ No newline at end of file diff --git a/go.mod b/go.mod index 1ba4a96..9b5757a 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/cisco-open/terraform-provider-dcloud go 1.18 require ( - github.com/cisco-open/dcloud-tb-go-client v1.0.3 + github.com/cisco-open/dcloud-tb-go-client v1.0.4 github.com/hashicorp/terraform-plugin-docs v0.13.0 github.com/hashicorp/terraform-plugin-log v0.7.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1 diff --git a/go.sum b/go.sum index 4a87b2c..f0539c4 100644 --- a/go.sum +++ b/go.sum @@ -28,14 +28,14 @@ github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgI github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/cisco-open/dcloud-tb-go-client v1.0.3 h1:hqrZ+Qkwkl1oVc4LbLstlWa3kuEDLMo8glV1zgfT530= -github.com/cisco-open/dcloud-tb-go-client v1.0.3/go.mod h1:Q2eKu/feJhWFmELsPX+g9Z1bwaEIn4TVAfE9WZPgLxs= +github.com/cisco-open/dcloud-tb-go-client v1.0.4 h1:RPi+7DWf7dqaGQYY12ttF7ljCDH4PfpEA1wKC67FRkc= +github.com/cisco-open/dcloud-tb-go-client v1.0.4/go.mod h1:nswounfrrUZqPfRZ4fF1BpmnTXcJIM37RaSGUNbZlpg= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= -github.com/docker/docker v20.10.24+incompatible h1:Ugvxm7a8+Gz6vqQYQQ2W7GYq5EUPaAiuPgIfVyI3dYE= +github.com/docker/docker v24.0.9+incompatible h1:HPGzNmwfLZWdxHqK9/II92pyi1EpYKsAqcl4G0Of9v0= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= @@ -197,7 +197,6 @@ github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFR github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= -github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= diff --git a/internal/dcloud/data_source_ip_nat.go b/internal/dcloud/data_source_ip_nat.go index 168f32b..fe01c0d 100644 --- a/internal/dcloud/data_source_ip_nat.go +++ b/internal/dcloud/data_source_ip_nat.go @@ -41,6 +41,10 @@ func dataSourceIpNatRules() *schema.Resource { Type: schema.TypeBool, Computed: true, }, + "scope": { + Type: schema.TypeString, + Computed: true, + }, "topology_uid": { Type: schema.TypeString, Computed: true, @@ -83,6 +87,7 @@ func convertIpNatRuleDataResource(ipNatRule tbclient.IpNatRule) map[string]inter resource["target_ip_address"] = ipNatRule.Target.IpAddress resource["target_name"] = ipNatRule.Target.Name resource["east_west"] = ipNatRule.EastWest + resource["scope"] = ipNatRule.Scope return resource } diff --git a/internal/dcloud/data_source_vm_nat.go b/internal/dcloud/data_source_vm_nat.go index 266aadc..0696a63 100644 --- a/internal/dcloud/data_source_vm_nat.go +++ b/internal/dcloud/data_source_vm_nat.go @@ -45,6 +45,10 @@ func dataSourceVmNatRules() *schema.Resource { Type: schema.TypeBool, Computed: true, }, + "scope": { + Type: schema.TypeString, + Computed: true, + }, "topology_uid": { Type: schema.TypeString, Computed: true, @@ -87,6 +91,7 @@ func convertVmNatRuleDataResource(vmNatRule tbclient.VmNatRule) map[string]inter resource["target_ip_address"] = vmNatRule.Target.IpAddress resource["target_name"] = vmNatRule.Target.Name resource["east_west"] = vmNatRule.EastWest + resource["scope"] = vmNatRule.Scope resource["nic_uid"] = vmNatRule.Target.VmNic.Uid return resource diff --git a/internal/dcloud/resource_ip_nat.go b/internal/dcloud/resource_ip_nat.go index de70933..8a40781 100644 --- a/internal/dcloud/resource_ip_nat.go +++ b/internal/dcloud/resource_ip_nat.go @@ -37,6 +37,12 @@ func resourceIpNat() *schema.Resource { Required: true, ForceNew: true, }, + "scope": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "The scope of the NAT rule, PUBLIC (default) or INTERNAL", + }, }, } } @@ -46,6 +52,13 @@ func resourceIpNatCreate(ctx context.Context, data *schema.ResourceData, i inter var diags diag.Diagnostics + var scope *string + + if v, ok := data.GetOk("scope"); ok { + s := v.(string) + scope = &s + } + ipNatRule := tbclient.IpNatRule{ Topology: &tbclient.Topology{ Uid: data.Get("topology_uid").(string), @@ -55,6 +68,7 @@ func resourceIpNatCreate(ctx context.Context, data *schema.ResourceData, i inter Name: data.Get("target_name").(string), }, EastWest: data.Get("east_west").(bool), + Scope: scope, } r, err := c.CreateIpNatRule(ipNatRule) @@ -84,6 +98,7 @@ func resourceIpNatRead(ctx context.Context, data *schema.ResourceData, i interfa data.Set("target_ip_address", r.Target.IpAddress) data.Set("target_name", r.Target.Name) data.Set("east_west", r.EastWest) + data.Set("scope", r.Scope) return diags } diff --git a/internal/dcloud/resource_vm_nat.go b/internal/dcloud/resource_vm_nat.go index b2d1a40..dffd08d 100644 --- a/internal/dcloud/resource_vm_nat.go +++ b/internal/dcloud/resource_vm_nat.go @@ -40,6 +40,12 @@ func resourceVmNat() *schema.Resource { Required: true, ForceNew: true, }, + "scope": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Description: "The scope of the NAT rule, PUBLIC (default) or INTERNAL", + }, }, } } @@ -49,6 +55,13 @@ func resourceVmNatCreate(ctx context.Context, data *schema.ResourceData, i inter var diags diag.Diagnostics + var scope *string + + if v, ok := data.GetOk("scope"); ok { + s := v.(string) + scope = &s + } + vmNatRule := tbclient.VmNatRule{ Topology: &tbclient.Topology{ Uid: data.Get("topology_uid").(string), @@ -59,6 +72,7 @@ func resourceVmNatCreate(ctx context.Context, data *schema.ResourceData, i inter }, }, EastWest: data.Get("east_west").(bool), + Scope: scope, } r, err := c.CreateVmNatRule(vmNatRule) @@ -89,6 +103,7 @@ func resourceVmNatRead(ctx context.Context, data *schema.ResourceData, i interfa data.Set("target_name", r.Target.Name) data.Set("east_west", r.EastWest) data.Set("nic_uid", r.Target.VmNic.Uid) + data.Set("scope", r.Scope) return diags } diff --git a/terraform-registry-manifest.json b/terraform-registry-manifest.json index 1931b0e..54250af 100644 --- a/terraform-registry-manifest.json +++ b/terraform-registry-manifest.json @@ -1,6 +1,8 @@ { - "version": 1, - "metadata": { - "protocol_versions": ["5.0"] - } + "version": 1, + "metadata": { + "protocol_versions": [ + "5.0" + ] + } }