Skip to content

Commit 98c7284

Browse files
committed
docs: fix datasource: backupstorages, hosts and images example
1 parent 075a9df commit 98c7284

File tree

10 files changed

+60
-72
lines changed

10 files changed

+60
-72
lines changed

docs/data-sources/backupstorages.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ data "zstack_backupstorages" "example" {
3333
}
3434
3535
output "zstack_imagestorages" {
36-
value = data.zstack_backupstorage.example
36+
value = data.zstack_backupstorages.example
3737
}
3838
```
3939

docs/data-sources/hosts.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ Fetches a list of hosts and their associated attributes from the ZStack environm
1212
## Example Usage
1313

1414
```terraform
15-
# Copyright (c) ZStack.io, Inc.
15+
# Copyright (c) ZStack.io, Inc.
1616
17-
data "zstack_images" "example" {
18-
# name = "imageName"
17+
data "zstack_hosts" "example" {
18+
# name = "hostname"
1919
# name_pattern = "hostname%" # Pattern for fuzzy name search, similar to MySQL LIKE. Use % for multiple characters and _ for exactly one character.
2020
filter {
2121
name = "architecture"
@@ -27,16 +27,16 @@ data "zstack_images" "example" {
2727
}
2828
filter {
2929
name = "status"
30-
values = ["Ready", "Deleted"]
30+
values = ["Disconnected"]
3131
}
3232
filter {
33-
name = "guest_os_type"
34-
values = ["Linux"]
33+
name = "cluster_uuid"
34+
values = ["37c25209578c495ca176f60ad0cd97fa"]
3535
}
3636
}
3737
38-
output "zstack_images" {
39-
value = data.zstack_images.example
38+
output "zstack_hosts" {
39+
value = data.zstack_hosts.example
4040
}
4141
```
4242

docs/data-sources/images.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ Fetches a list of images and their associated attributes from the ZStack environ
1212
## Example Usage
1313

1414
```terraform
15-
# Copyright (c) ZStack.io, Inc.
15+
# Copyright (c) ZStack.io, Inc.
1616
17-
data "zstack_hosts" "example" {
18-
# name = "hostname"
17+
data "zstack_images" "example" {
18+
# name = "imageName"
1919
# name_pattern = "hostname%" # Pattern for fuzzy name search, similar to MySQL LIKE. Use % for multiple characters and _ for exactly one character.
2020
filter {
2121
name = "architecture"
@@ -27,16 +27,16 @@ data "zstack_hosts" "example" {
2727
}
2828
filter {
2929
name = "status"
30-
values = ["Disconnected"]
30+
values = ["Ready", "Deleted"]
3131
}
3232
filter {
33-
name = "cluster_uuid"
34-
values = ["37c25209578c495ca176f60ad0cd97fa"]
33+
name = "guest_os_type"
34+
values = ["Linux"]
3535
}
3636
}
3737
38-
output "zstack_hosts" {
39-
value = data.zstack_hosts.example
38+
output "zstack_images" {
39+
value = data.zstack_images.example
4040
}
4141
```
4242

docs/resources/instance.md

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,30 @@ This resource allows you to manage virtual machine (VM) instances in ZStack. A V
1212
## Example Usage
1313

1414
```terraform
15-
# Copyright (c) ZStack.io, Inc.
15+
data "zstack_images" "centos" {
16+
name = "centos8"
17+
}
1618
17-
data "zstack_images" "images" {
18-
name = "image name"
19+
data "zstack_l3networks" "l3networks" {
20+
name = "public-net"
1921
}
2022
21-
data "zstack_l3network" "example" {
22-
name = "network name"
23+
data "zstack_instance_offers" "offer" {
24+
name = "min"
2325
}
2426
25-
resource "zstack_vm" "vm" {
26-
count = 2
27-
name = "disk-test-${count.index + 1}"
28-
description = "test"
29-
image_uuid = data.zstack_images.images.images.0.uuid #"${data.zstack_images.images.images[0].uuid}" #"9b26312501614ec0b6dc731e6977dfb2"
30-
l3_network_uuids = [data.zstack_l3network.example.l3networks.0.uuid]
31-
root_disk = {
32-
offering_uuid = "e002a969bb3041c087e355c77e997be5"
33-
}
34-
memory_size = 1024 # in megabytes, MB
35-
data_disks = [{
36-
size = 100 # in gigabytes (GB)
37-
}]
38-
cpu_num = 1
27+
resource "zstack_instance" "example_vm" {
28+
name = "example-v"
29+
image_uuid = data.zstack_images.centos.images[0].uuid
30+
l3_network_uuids = [data.zstack_l3networks.l3networks.l3networks[0].uuid]
31+
description = "jumper server"
32+
instance_offering_uuid = data.zstack_instance_offers.offer.instance_offers[0].uuid #using Instance offering uuid or custom cpu and memory
33+
memory_size = 4096
34+
cpu_num = 4
3935
}
4036
41-
output "zstack_vm" {
42-
value = zstack_vm.vm
37+
output "zstack_instance" {
38+
value = zstack_instance.example_vm
4339
}
4440
```
4541

docs/resources/subnet_ip_range.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ This resource allows you to manage subnets in ZStack. A subnet is a logical subd
1414
```terraform
1515
# Copyright (c) ZStack.io, Inc.
1616
17-
resource "zstack_subnet" "test" {
18-
17+
resource "zstack_subnet_ip_range" "test" {
1918
l3_network_uuid = "6a7c9dd9d6e449f992a59df8c102b3ba"
2019
name = "net1"
2120
start_ip = "192.168.1.1"
@@ -24,8 +23,8 @@ resource "zstack_subnet" "test" {
2423
gateway = "192.168.100.1"
2524
}
2625
27-
output "zstack_subnet" {
28-
value = zstack_subnet.test
26+
output "zstack_subnet_ip_range" {
27+
value = zstack_subnet_ip_range.test
2928
}
3029
```
3130

examples/data-sources/backupstorages/data-source.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ data "zstack_backupstorages" "example" {
1919
}
2020

2121
output "zstack_imagestorages" {
22-
value = data.zstack_backupstorage.example
22+
value = data.zstack_backupstorages.example
2323
}
2424

2525

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,25 @@
1-
# Copyright (c) ZStack.io, Inc.
2-
3-
data "zstack_images" "images" {
4-
name = "image name"
1+
data "zstack_images" "centos" {
2+
name = "centos8"
53
}
64

7-
data "zstack_l3network" "example" {
8-
name = "network name"
5+
data "zstack_l3networks" "l3networks" {
6+
name = "public-net"
97
}
108

11-
resource "zstack_vm" "vm" {
12-
count = 2
13-
name = "disk-test-${count.index + 1}"
14-
description = "test"
15-
image_uuid = data.zstack_images.images.images.0.uuid #"${data.zstack_images.images.images[0].uuid}" #"9b26312501614ec0b6dc731e6977dfb2"
16-
l3_network_uuids = [data.zstack_l3network.example.l3networks.0.uuid]
17-
root_disk = {
18-
offering_uuid = "e002a969bb3041c087e355c77e997be5"
19-
}
20-
memory_size = 1024 # in megabytes, MB
21-
data_disks = [{
22-
size = 100 # in gigabytes (GB)
23-
}]
24-
cpu_num = 1
9+
data "zstack_instance_offers" "offer" {
10+
name = "min"
2511
}
2612

27-
output "zstack_vm" {
28-
value = zstack_vm.vm
13+
resource "zstack_instance" "example_vm" {
14+
name = "example-v"
15+
image_uuid = data.zstack_images.centos.images[0].uuid
16+
l3_network_uuids = [data.zstack_l3networks.l3networks.l3networks[0].uuid]
17+
description = "jumper server"
18+
instance_offering_uuid = data.zstack_instance_offers.offer.instance_offers[0].uuid #using Instance offering uuid or custom cpu and memory
19+
memory_size = 4096
20+
cpu_num = 4
2921
}
3022

31-
23+
output "zstack_instance" {
24+
value = zstack_instance.example_vm
25+
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Copyright (c) ZStack.io, Inc.
22

3-
resource "zstack_subnet" "test" {
4-
3+
resource "zstack_subnet_ip_range" "test" {
54
l3_network_uuid = "6a7c9dd9d6e449f992a59df8c102b3ba"
65
name = "net1"
76
start_ip = "192.168.1.1"
@@ -10,7 +9,7 @@ resource "zstack_subnet" "test" {
109
gateway = "192.168.100.1"
1110
}
1211

13-
output "zstack_subnet" {
14-
value = zstack_subnet.test
12+
output "zstack_subnet_ip_range" {
13+
value = zstack_subnet_ip_range.test
1514
}
1615

templates/data-sources/hosts.md.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ description: |-
1111

1212
## Example Usage
1313

14-
{{tffile "examples/data-sources/images/data-source.tf"}}
14+
{{tffile "examples/data-sources/hosts/data-source.tf"}}
1515

1616
{{ .SchemaMarkdown }}

templates/data-sources/images.md.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ description: |-
1111

1212
## Example Usage
1313

14-
{{tffile "examples/data-sources/hosts/data-source.tf"}}
14+
{{tffile "examples/data-sources/images/data-source.tf"}}
1515

1616
{{ .SchemaMarkdown }}

0 commit comments

Comments
 (0)