Skip to content

Commit

Permalink
gcore_instancev2 and gcore_lbmember docs updated (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexk53 authored Sep 18, 2024
1 parent 16d57fc commit 6513910
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 64 deletions.
58 changes: 26 additions & 32 deletions docs/resources/instancev2.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,20 @@ data "gcore_securitygroup" "default" {
project_id = data.gcore_project.project.id
region_id = data.gcore_region.region.id
}
data "gcore_image" "windows" {
name = "windows-server-2022"
region_id = data.gcore_region.region.id
project_id = data.gcore_project.project.id
}
```

### Basic example

#### Creating instance with one public interface

```terraform
resource "gcore_instancev2" "instance-with-one-interface" {
resource "gcore_instancev2" "instance_with_one_interface" {
flavor_id = "g1-standard-2-4"
name = "my-instance"
keypair_name = "my-keypair"
Expand All @@ -94,7 +100,7 @@ resource "gcore_instancev2" "instance-with-one-interface" {
interface {
type = "external"
name = "my-external-interface"
security_groups = [gcore_securitygroup.default.id]
security_groups = [data.gcore_securitygroup.default.id]
}
project_id = data.gcore_project.project.id
Expand All @@ -107,7 +113,7 @@ resource "gcore_instancev2" "instance-with-one-interface" {
This example demonstrates how to create an instance with two network interfaces: one public and one private.

```terraform
resource "gcore_instancev2" "instance-with-two-interface" {
resource "gcore_instancev2" "instance_with_two_interface" {
flavor_id = "g1-standard-2-4"
name = "my-instance"
keypair_name = "my-keypair"
Expand All @@ -120,13 +126,13 @@ resource "gcore_instancev2" "instance-with-two-interface" {
interface {
type = "external"
name = "my-external-interface"
security_groups = [gcore_securitygroup.default.id]
security_groups = [data.gcore_securitygroup.default.id]
}
interface {
type = "subnet"
name = "my-private-interface"
security_groups = [gcore_securitygroup.default.id]
security_groups = [data.gcore_securitygroup.default.id]
network_id = gcore_network.network.id
subnet_id = gcore_subnet.subnet.id
Expand All @@ -139,12 +145,6 @@ resource "gcore_instancev2" "instance-with-two-interface" {
#### Creating Windows instance with one public interface

```terraform
data "gcore_image" "windows" {
name = "windows-server-2022"
region_id = data.gcore_region.region.id
project_id = data.gcore_project.project.id
}
resource "gcore_volume" "boot_volume_windows" {
name = "my-windows-boot-volume"
type_name = "ssd_hiiops"
Expand All @@ -154,7 +154,7 @@ resource "gcore_volume" "boot_volume_windows" {
region_id = data.gcore_region.region.id
}
resource "gcore_instancev2" "windows-instance" {
resource "gcore_instancev2" "windows_instance" {
flavor_id = "g1w-standard-4-8"
name = "my-windows-instance"
password = "my-s3cR3tP@ssw0rd"
Expand All @@ -167,7 +167,7 @@ resource "gcore_instancev2" "windows-instance" {
interface {
type = "external"
name = "my-external-interface"
security_groups = [gcore_securitygroup.default.id]
security_groups = [data.gcore_securitygroup.default.id]
}
project_id = data.gcore_project.project.id
Expand All @@ -184,7 +184,7 @@ This example demonstrates how to create an instance with a dual-stack public int
The instance has both an IPv4 and an IPv6 address.

```terraform
resource "gcore_instancev2" "instance-with-dualstack" {
resource "gcore_instancev2" "instance_with_dualstack" {
flavor_id = "g1-standard-2-4"
name = "my-instance"
keypair_name = "my-keypair"
Expand All @@ -198,15 +198,15 @@ resource "gcore_instancev2" "instance-with-dualstack" {
type = "external"
ip_family = "dual"
name = "my-external-interface"
security_groups = [gcore_securitygroup.default.id]
security_groups = [data.gcore_securitygroup.default.id]
}
project_id = data.gcore_project.project.id
region_id = data.gcore_region.region.id
}
output "addresses" {
value = gcore_instancev2.instance.addresses
value = gcore_instancev2.instance_with_dualstack.addresses
}
```

Expand All @@ -228,7 +228,7 @@ resource "gcore_floatingip" "floating_ip" {
port_id = gcore_reservedfixedip.fixed_ip.port_id
}
resource "gcore_instancev2" "instance-with-floating-ip" {
resource "gcore_instancev2" "instance_with_floating_ip" {
flavor_id = "g1-standard-2-4"
name = "my-instance"
keypair_name = "my-keypair"
Expand All @@ -255,13 +255,13 @@ resource "gcore_instancev2" "instance-with-floating-ip" {
#### Creating instance with a reserved public interface

```terraform
resource "gcore_reservedfixedip" "fixed_ip" {
resource "gcore_reservedfixedip" "external_fixed_ip" {
project_id = data.gcore_project.project.id
region_id = data.gcore_region.region.id
type = "external"
}
resource "gcore_instancev2" "instance-with-reserved-address" {
resource "gcore_instancev2" "instance_with_reserved_address" {
flavor_id = "g1-standard-2-4"
name = "my-instance"
keypair_name = "my-keypair"
Expand All @@ -274,8 +274,8 @@ resource "gcore_instancev2" "instance-with-reserved-address" {
interface {
type = "reserved_fixed_ip"
name = "my-reserved-public-interface"
port_id = gcore_reservedfixedip.fixed_ip.port_id
security_groups = [gcore_securitygroup.default.id]
port_id = gcore_reservedfixedip.external_fixed_ip.port_id
security_groups = [data.gcore_securitygroup.default.id]
}
project_id = data.gcore_project.project.id
Expand Down Expand Up @@ -338,7 +338,7 @@ resource "gcore_securitygroup" "web_server_security_group" {
}
resource "gcore_instancev2" "instance-with-custom-security-group" {
resource "gcore_instancev2" "instance_with_custom_security_group" {
flavor_id = "g1-standard-2-4"
name = "my-instance"
keypair_name = "my-keypair"
Expand Down Expand Up @@ -384,13 +384,7 @@ Add-LocalGroupMember -Group "Administrators" -Member $User
EOF
}
data "gcore_image" "windows" {
name = "windows-server-2022"
region_id = data.gcore_region.region.id
project_id = data.gcore_project.project.id
}
resource "gcore_volume" "boot_volume_windows" {
resource "gcore_volume" "boot_volume_windows_with_userdata" {
name = "my-windows-boot-volume"
type_name = "ssd_hiiops"
size = 50
Expand All @@ -399,21 +393,21 @@ resource "gcore_volume" "boot_volume_windows" {
region_id = data.gcore_region.region.id
}
resource "gcore_instancev2" "instance-windows-with-userdata" {
resource "gcore_instancev2" "instance_windows_with_userdata" {
flavor_id = "g1w-standard-4-8"
name = "my-windows-instance"
password = "my-s3cR3tP@ssw0rd"
user_data = base64encode(var.second_user_userdata)
volume {
volume_id = gcore_volume.boot_volume_windows.id
volume_id = gcore_volume.boot_volume_windows_with_userdata.id
boot_index = 0
}
interface {
type = "external"
name = "my-external-interface"
security_groups = [gcore_securitygroup.default.id]
security_groups = [data.gcore_securitygroup.default.id]
}
project_id = data.gcore_project.project.id
Expand Down
7 changes: 7 additions & 0 deletions docs/resources/lbmember.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ data "gcore_image" "ubuntu" {
name = "ubuntu-22.04"
}
data "gcore_securitygroup" "default" {
name = "default"
project_id = data.gcore_project.project.id
region_id = data.gcore_region.region.id
}
resource "gcore_volume" "instance_member_volume" {
project_id = data.gcore_project.project.id
region_id = data.gcore_region.region.id
Expand Down Expand Up @@ -190,6 +196,7 @@ resource "gcore_instancev2" "instance_member" {
type = "reserved_fixed_ip"
name = "my-private-network-interface"
port_id = gcore_reservedfixedip.instance_member_fixed_ip.port_id
security_groups = [gcore_securitygroup.default.id]
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/gcore_instancev2/custom-sg.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ resource "gcore_securitygroup" "web_server_security_group" {

}

resource "gcore_instancev2" "instance-with-custom-security-group" {
resource "gcore_instancev2" "instance_with_custom_security_group" {
flavor_id = "g1-standard-2-4"
name = "my-instance"
keypair_name = "my-keypair"
Expand Down
6 changes: 3 additions & 3 deletions examples/resources/gcore_instancev2/dualstack-interface.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resource "gcore_instancev2" "instance-with-dualstack" {
resource "gcore_instancev2" "instance_with_dualstack" {
flavor_id = "g1-standard-2-4"
name = "my-instance"
keypair_name = "my-keypair"
Expand All @@ -12,13 +12,13 @@ resource "gcore_instancev2" "instance-with-dualstack" {
type = "external"
ip_family = "dual"
name = "my-external-interface"
security_groups = [gcore_securitygroup.default.id]
security_groups = [data.gcore_securitygroup.default.id]
}

project_id = data.gcore_project.project.id
region_id = data.gcore_region.region.id
}

output "addresses" {
value = gcore_instancev2.instance.addresses
value = gcore_instancev2.instance_with_dualstack.addresses
}
2 changes: 1 addition & 1 deletion examples/resources/gcore_instancev2/fip.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ resource "gcore_floatingip" "floating_ip" {
port_id = gcore_reservedfixedip.fixed_ip.port_id
}

resource "gcore_instancev2" "instance-with-floating-ip" {
resource "gcore_instancev2" "instance_with_floating_ip" {
flavor_id = "g1-standard-2-4"
name = "my-instance"
keypair_name = "my-keypair"
Expand Down
7 changes: 7 additions & 0 deletions examples/resources/gcore_instancev2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,10 @@ data "gcore_securitygroup" "default" {
project_id = data.gcore_project.project.id
region_id = data.gcore_region.region.id
}

data "gcore_image" "windows" {
name = "windows-server-2022"
region_id = data.gcore_region.region.id
project_id = data.gcore_project.project.id
}

10 changes: 2 additions & 8 deletions examples/resources/gcore_instancev2/one-interface-windows.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
data "gcore_image" "windows" {
name = "windows-server-2022"
region_id = data.gcore_region.region.id
project_id = data.gcore_project.project.id
}

resource "gcore_volume" "boot_volume_windows" {
name = "my-windows-boot-volume"
type_name = "ssd_hiiops"
Expand All @@ -13,7 +7,7 @@ resource "gcore_volume" "boot_volume_windows" {
region_id = data.gcore_region.region.id
}

resource "gcore_instancev2" "windows-instance" {
resource "gcore_instancev2" "windows_instance" {
flavor_id = "g1w-standard-4-8"
name = "my-windows-instance"
password = "my-s3cR3tP@ssw0rd"
Expand All @@ -26,7 +20,7 @@ resource "gcore_instancev2" "windows-instance" {
interface {
type = "external"
name = "my-external-interface"
security_groups = [gcore_securitygroup.default.id]
security_groups = [data.gcore_securitygroup.default.id]
}

project_id = data.gcore_project.project.id
Expand Down
4 changes: 2 additions & 2 deletions examples/resources/gcore_instancev2/one-interface.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resource "gcore_instancev2" "instance-with-one-interface" {
resource "gcore_instancev2" "instance_with_one_interface" {
flavor_id = "g1-standard-2-4"
name = "my-instance"
keypair_name = "my-keypair"
Expand All @@ -11,7 +11,7 @@ resource "gcore_instancev2" "instance-with-one-interface" {
interface {
type = "external"
name = "my-external-interface"
security_groups = [gcore_securitygroup.default.id]
security_groups = [data.gcore_securitygroup.default.id]
}

project_id = data.gcore_project.project.id
Expand Down
8 changes: 4 additions & 4 deletions examples/resources/gcore_instancev2/reserved-address.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
resource "gcore_reservedfixedip" "fixed_ip" {
resource "gcore_reservedfixedip" "external_fixed_ip" {
project_id = data.gcore_project.project.id
region_id = data.gcore_region.region.id
type = "external"
}

resource "gcore_instancev2" "instance-with-reserved-address" {
resource "gcore_instancev2" "instance_with_reserved_address" {
flavor_id = "g1-standard-2-4"
name = "my-instance"
keypair_name = "my-keypair"
Expand All @@ -17,8 +17,8 @@ resource "gcore_instancev2" "instance-with-reserved-address" {
interface {
type = "reserved_fixed_ip"
name = "my-reserved-public-interface"
port_id = gcore_reservedfixedip.fixed_ip.port_id
security_groups = [gcore_securitygroup.default.id]
port_id = gcore_reservedfixedip.external_fixed_ip.port_id
security_groups = [data.gcore_securitygroup.default.id]
}

project_id = data.gcore_project.project.id
Expand Down
6 changes: 3 additions & 3 deletions examples/resources/gcore_instancev2/two-interface.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resource "gcore_instancev2" "instance-with-two-interface" {
resource "gcore_instancev2" "instance_with_two_interface" {
flavor_id = "g1-standard-2-4"
name = "my-instance"
keypair_name = "my-keypair"
Expand All @@ -11,13 +11,13 @@ resource "gcore_instancev2" "instance-with-two-interface" {
interface {
type = "external"
name = "my-external-interface"
security_groups = [gcore_securitygroup.default.id]
security_groups = [data.gcore_securitygroup.default.id]
}

interface {
type = "subnet"
name = "my-private-interface"
security_groups = [gcore_securitygroup.default.id]
security_groups = [data.gcore_securitygroup.default.id]

network_id = gcore_network.network.id
subnet_id = gcore_subnet.subnet.id
Expand Down
Loading

0 comments on commit 6513910

Please sign in to comment.