Skip to content

docs: apply example formatting #314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 75 additions & 67 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,84 +1,92 @@
# Example: Creation of SDDC, public IP, cluster, site recovery and SRM node.

This is an example that demonstrates the creation of VMC resources like SDDC, cluster, public IP, site recovery and SRM node.

For site recovery activation, a 10-minute delay must be added after SDDC is created and before site recovery can be activated.

To add delay after SDDC has been created, update SDDC resource in [main.tf](https://github.com/vmware/terraform-provider-vmc/blob/master/examples/main.tf) with local-exec provisioner:

```sh
resource "vmc_sddc" "sddc_1" {
sddc_name = var.sddc_name
vpc_cidr = var.vpc_cidr
num_host = var.num_hosts
provider_type = var.provider_type
region = data.vmc_customer_subnets.my_subnets.region
vxlan_subnet = var.vxlan_subnet
delay_account_link = false
skip_creating_vxlan = false
sso_domain = "vmc.local"
sddc_type = var.sddc_type
deployment_type = "SingleAZ"

host_instance_type = var.host_instance_type

account_link_sddc_config {
customer_subnet_ids = [data.vmc_customer_subnets.my_subnets.ids[0]]
connected_account_id = data.vmc_connected_accounts.my_accounts.id
}

timeouts {
create = "300m"
update = "300m"
delete = "180m"
}

# provisioner defined to add 10 minute delay after SDDC creation to enable site recovery activation.
provisioner "local-exec" {
command = "sleep 600"
}
}

# Example

## Creation of SDDC, Public IP, Cluster, Site Recovery, and SRM Node

This is an example that demonstrates the creation of VMC resources like SDDC,
cluster, public IP, Site Recovery and SRM node.

For Site Recovery activation, a 10-minute delay must be added after SDDC is
created and before Site Recovery can be activated.

To add delay after SDDC has been created, update SDDC resource in the
[`main.tf`](https://github.com/vmware/terraform-provider-vmc/blob/main/examples/main.tf)
with `local-exec` provisioner:

```hcl
resource "vmc_sddc" "sddc_1" {
sddc_name = var.sddc_name
vpc_cidr = var.vpc_cidr
num_host = var.num_hosts
provider_type = var.provider_type
region = data.vmc_customer_subnets.my_subnets.region
vxlan_subnet = var.vxlan_subnet
delay_account_link = false
skip_creating_vxlan = false
sso_domain = "vmc.local"
sddc_type = var.sddc_type
deployment_type = "SingleAZ"

host_instance_type = var.host_instance_type

account_link_sddc_config {
customer_subnet_ids = [data.vmc_customer_subnets.my_subnets.ids[0]]
connected_account_id = data.vmc_connected_accounts.my_accounts.id
}

timeouts {
create = "300m"
update = "300m"
delete = "180m"
}

# provisioner defined to add 10 minute delay after SDDC creation to enable site recovery activation.
provisioner "local-exec" {
command = "sleep 600"
}
}
```

To run the example:

* Generate an API token using [VMware Cloud on AWS console] (https://vmc.vmware.com/console/)
* Generate an API token using [VMware Cloud on AWS console]
(<https://vmc.vmware.com/console/>)

* Update the required parameters api_token and org_id in [variables.tf](https://github.com/vmware/terraform-provider-vmc/blob/master/examples/variables.tf) with your infrastructure settings.

* Load the provider
* Update the required parameters `api_token` and `org_id` in the
[`variables.tf`](https://github.com/vmware/terraform-provider-vmc/blob/main/examples/variables.tf)
with your infrastructure settings.

```sh
terraform init
```
* Load the provider:

* Execute the plan
```sh
terraform init
```

```sh
terraform apply
```
* Run the plan:

or
```sh
terraform apply
```

```sh
terraform apply -var="api_token=xxxx" -var="org_id=xxxx"
```
or

* Check the terraform state
```sh
terraform apply -var="api_token=xxxx" -var="org_id=xxxx"
```

```sh
terraform show
```
* Check the state:

```sh
terraform show
```

* Delete VMC resources created during apply.

```sh
terraform destroy
```
```sh
terraform destroy
```

or
or

```sh
terraform destroy -var="api_token=xxxx" -var="org_id=xxxx"
```
```sh
terraform destroy -var="api_token=xxxx" -var="org_id=xxxx"
```
62 changes: 34 additions & 28 deletions examples/cluster/README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,53 @@
# Example: Cluster management for SDDC
# Example

This is an example that demonstrates cluster management actions like creating, updating and deleting a cluster for an SDDC.
## Cluster Management for SDDC

This is an example that demonstrates cluster management actions like creating,
updating, and deleting a cluster for an SDDC.

To run the example:

* Generate an API token using [VMware Cloud on AWS console] (https://vmc.vmware.com/console/)
* Generate an API token using
[VMware Cloud on AWS console](https://vmc.vmware.com/console/).

* Update the required parameters api_token and org_id in [variables.tf](https://github.com/vmware/terraform-provider-vmc/blob/master/examples/cluster/variables.tf) with your infrastructure settings.
* Update the required parameters `api_token` and `org_id` in the
[`variables.tf`](https://github.com/vmware/terraform-provider-vmc/blob/main/examples/cluster/variables.tf)
with your infrastructure settings.

* Load the provider
* Load the provider:

```sh
terraform init
```
```sh
terraform init
```

* Execute the plan
* Run the plan:

```sh
terraform apply
```
```sh
terraform apply
```

or
or

```sh
terraform apply -var="api_token=xxxx" -var="org_id=xxxx"
```
```sh
terraform apply -var="api_token=xxxx" -var="org_id=xxxx"
```

Verify cluster has been created successfully.
Verify cluster has been created successfully.

* Check the terraform state
* Check the state:

```sh
terraform show
```
```sh
terraform show
```

* Delete the cluster

```sh
terraform destroy
```
```sh
terraform destroy
```

or
or

```sh
terraform destroy -var="api_token=xxxx" -var="org_id=xxxx"
```
```sh
terraform destroy -var="api_token=xxxx" -var="org_id=xxxx"
```
12 changes: 6 additions & 6 deletions examples/cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ terraform {
}
provider "vmc" {
refresh_token = var.api_token
org_id = var.org_id
org_id = var.org_id
}

# Empty data source defined in order to store the org display name and name in terraform state
Expand All @@ -33,7 +33,7 @@ resource "vmc_sddc" "sddc_1" {
delay_account_link = false
skip_creating_vxlan = false
sso_domain = "vmc.local"
deployment_type = "SingleAZ"
deployment_type = "SingleAZ"

host_instance_type = var.host_instance_type

Expand All @@ -49,10 +49,10 @@ resource "vmc_sddc" "sddc_1" {
}

resource "vmc_cluster" "cluster_1" {
sddc_id = vmc_sddc.sddc_1.id
sddc_id = vmc_sddc.sddc_1.id
num_hosts = var.cluster_num_hosts
microsoft_licensing_config {
mssql_licensing = "DISABLED"
windows_licensing = "ENABLED"
}
mssql_licensing = "DISABLED"
windows_licensing = "ENABLED"
}
}
22 changes: 11 additions & 11 deletions examples/cluster/variables.tf
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
variable "api_token" {
description = "API token used to authenticate when calling the VMware Cloud Services API."
default = ""
default = ""
}

variable "org_id" {
description = "Organization Identifier."
default = ""
default = ""
}

variable "aws_account_number" {
description = "The AWS account number."
default = ""
}

variable "sddc_name"{
variable "sddc_name" {
description = "Name of SDDC."
default = "sddc-test"
default = "sddc-test"
}

variable "sddc_region" {
description = "The AWS or VMC specific region."
description = "The AWS or VMC specific region."
default = "us-west-2"
}

Expand All @@ -33,22 +33,22 @@ variable "vxlan_subnet" {
default = ""
}

variable provider_type {
variable "provider_type" {
description = "Determines what additional properties are available based on cloud provider. Default value : AWS"
default = "AWS"
}

variable host_instance_type {
variable "host_instance_type" {
description = "The instance type for the ESX hosts in the primary cluster of the SDDC. Possible values: I3_METAL, I4I_METAL"
default = ""
}

variable cluster_num_hosts {
variable "cluster_num_hosts" {
description = "The number of hosts in the (secondary) cluster."
default = 3
default = 3
}

variable sddc_primary_cluster_num_hosts {
variable "sddc_primary_cluster_num_hosts" {
description = "The number of hosts in the primary cluster of the SDDC."
default = 3
}
}
20 changes: 10 additions & 10 deletions examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ terraform {
}
}
provider "vmc" {
client_id = var.client_id
client_id = var.client_id
client_secret = var.client_secret
org_id = var.org_id
org_id = var.org_id
}
# Empty data source defined in order to store the org display name and name in terraform state
data "vmc_org" "my_org" {
Expand All @@ -33,8 +33,8 @@ resource "vmc_sddc" "sddc_1" {
delay_account_link = false
skip_creating_vxlan = false
sso_domain = "vmc.local"
sddc_type = var.sddc_type
deployment_type = "SingleAZ"
sddc_type = var.sddc_type
deployment_type = "SingleAZ"

host_instance_type = var.host_instance_type

Expand All @@ -50,22 +50,22 @@ resource "vmc_sddc" "sddc_1" {
}

resource "vmc_cluster" "cluster_1" {
sddc_id = vmc_sddc.sddc_1.id
sddc_id = vmc_sddc.sddc_1.id
num_hosts = var.cluster_num_hosts
}

resource "vmc_public_ip" "public_ip_1" {
nsxt_reverse_proxy_url = vmc_sddc.sddc_1.nsxt_reverse_proxy_url
display_name = var.public_ip_displayname
display_name = var.public_ip_displayname
}

resource "vmc_site_recovery" "site_recovery_1" {
sddc_id = vmc_sddc.sddc_1.id
sddc_id = vmc_sddc.sddc_1.id
srm_extension_key_suffix = var.site_recovery_srm_extension_key_suffix
}

resource "vmc_srm_node" "srm_node_1"{
sddc_id = vmc_sddc.sddc_1.id
resource "vmc_srm_node" "srm_node_1" {
sddc_id = vmc_sddc.sddc_1.id
srm_node_extension_key_suffix = var.srm_node_srm_extension_key_suffix
depends_on = [vmc_site_recovery.site_recovery_1]
depends_on = [vmc_site_recovery.site_recovery_1]
}
Loading
Loading