Skip to content

Commit d609d53

Browse files
committed
Add fabric_compute example
Signed-off-by: Ferran Rodenas <[email protected]>
1 parent eba778a commit d609d53

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed

examples/fabric_compute/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# fabric compute example
2+
3+
**__NOTE: THIS RESOURCE TYPE MUST BE IMPORTED. ATTEMPTING TO CREATE IT WILL ERROR__ **
4+
5+
These resources (fabric computes) are discovered in vRA(C) as part of creating a Cloud Account and can not therefore be "created" or "destroyed" in a traditional sense.
6+
7+
This is an example on how to import a fabric compute resource into terraform and then manage settings on it.
8+
9+
## Getting Started
10+
11+
There are variables which need to be added to a `terraform.tfvars` file:
12+
13+
* `url` - The base url for API operations
14+
* `refresh_token` - The refresh token for API operations
15+
* `insecure` - Specify whether to validate TLS certificates
16+
17+
To facilitate adding these variables, a sample tfvars file can be copied first:
18+
19+
```shell
20+
cp terraform.tfvars.sample terraform.tfvars
21+
```
22+
23+
This examples assumes a cloud account is already set up.
24+
25+
To import the resource you must find the ID of the fabric compute. There are a couple of way this ID can be aquired:
26+
27+
1. Via API calls
28+
2. Viewing the object in a browser and pulling the ID from the url (ex value: `e2a959f4-7ec5-4941-b532-32b798309feb`)
29+
30+
Once the information is added to `terraform.tfvars` the resource can be imported and the manage via:
31+
32+
```shell
33+
terraform import vra_fabric_compute.this <computeID>
34+
```
35+
36+
If the import is successful output from the command should resemble
37+
38+
```shell
39+
vra_fabric_compute.this: Importing from ID "<computeID>"...
40+
vra_fabric_compute.this: Import prepared!
41+
Prepared vra_fabric_compute for import
42+
vra_fabric_compute.this: Refreshing state... [id=<computeID>]
43+
44+
Import successful!
45+
46+
The resources that were imported are shown above. These resources are now in
47+
your Terraform state and will henceforth be managed by Terraform
48+
```
49+
50+
To apply your settings you can now perform an apply comand:
51+
52+
```shell
53+
terraform apply
54+
```

examples/fabric_compute/main.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
provider "vra" {
2+
url = var.url
3+
refresh_token = var.refresh_token
4+
insecure = var.insecure
5+
}
6+
7+
resource "vra_fabric_compute" "this" {
8+
tags {
9+
key = "foo"
10+
value = "bar"
11+
}
12+
}
13+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
url = ""
2+
refresh_token = ""
3+
insecure = ""

examples/fabric_compute/variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
variable "url" {
2+
description = "The base url for API operations"
3+
}
4+
5+
variable "refresh_token" {
6+
description = "The refresh token for API operations"
7+
}
8+
9+
variable "insecure" {
10+
description = "Specify whether to validate TLS certificates"
11+
}

0 commit comments

Comments
 (0)