Skip to content

Commit

Permalink
GCLOUD2-11797 security group management updated
Browse files Browse the repository at this point in the history
GCLOUD2-11417 - some fix in documentations, dual-stack public interface example added to gcore_instancev2
  • Loading branch information
alexk53 committed Sep 13, 2024
1 parent 8e6488b commit fcb6d9c
Show file tree
Hide file tree
Showing 9 changed files with 310 additions and 132 deletions.
4 changes: 2 additions & 2 deletions docs/resources/instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
page_title: "gcore_instance Resource - terraform-provider-gcore"
subcategory: ""
description: |-
Represent instance
Represent instance. WARNING: This resource is deprecated, please use 'gcore_instancev2' instead
---

# gcore_instance (Resource)

Represent instance
Represent instance. **WARNING: This resource is deprecated, please use 'gcore_instancev2' instead**

## Example Usage

Expand Down
98 changes: 63 additions & 35 deletions docs/resources/instancev2.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,38 @@ resource "gcore_instancev2" "instance" {

### Advanced examples


#### Creating instance with a dual-stack public interface

This example demonstrates how to create an instance with a dual-stack public interface.
The instance has both an IPv4 and an IPv6 address.

```terraform
resource "gcore_instancev2" "instance" {
flavor_id = "g1-standard-2-4"
name = "my-instance"
keypair_name = "my-keypair"
volume {
volume_id = gcore_volume.boot_volume.id
boot_index = 0
}
interface {
type = "external"
ip_family = "dual"
name = "my-external-interface"
}
project_id = data.gcore_project.project.id
region_id = data.gcore_region.region.id
}
output "addresses" {
value = gcore_instancev2.instance.addresses
}
```

#### Creating instance with floating ip

```terraform
Expand Down Expand Up @@ -385,14 +417,16 @@ resource "gcore_instancev2" "instance" {
- `interface` (Block Set, Min: 1) List of interfaces for the instance. You can detach the interface from the instance by removing the
interface from the instance resource and attach the interface by adding the interface resource
inside an instance resource. (see [below for nested schema](#nestedblock--interface))
- `volume` (Block Set, Min: 1) List of volumes for the instance. You can detach the volume from the instance by removing the
volume from the instance resource. You cannot detach the boot volume. You can attach a data volume
by adding the volume resource inside an instance resource. (see [below for nested schema](#nestedblock--volume))

### Optional

- `allow_app_ports` (Boolean) If true, application ports will be allowed in the security group for instances created
from the marketplace application template
- `configuration` (Block List) Parameters for the application template from the marketplace (see [below for nested schema](#nestedblock--configuration))
- `keypair_name` (String) Name of the keypair to use for the instance
- `last_updated` (String)
- `metadata_map` (Map of String) Create one or more metadata items for the instance
- `name` (String) Name of the instance.
- `name_template` (String) Instance name template. You can use forms 'ip_octets', 'two_ip_octets', 'one_ip_octet'
Expand All @@ -401,26 +435,23 @@ When only 'password' is provided, it is set as the password for the default user
when 'password' is specified. For Windows instances, 'username' cannot be specified. Use the 'password' field to set
the password for the 'Admin' user on Windows. Use the 'user_data' field to provide a script to create new users
on Windows. The password of the Admin user cannot be updated via 'user_data'
- `project_id` (Number)
- `project_name` (String)
- `region_id` (Number)
- `region_name` (String)
- `project_id` (Number) Project ID, only one of project_id or project_name should be set
- `project_name` (String) Project name, only one of project_id or project_name should be set
- `region_id` (Number) Region ID, only one of region_id or region_name should be set
- `region_name` (String) Region name, only one of region_id or region_name should be set
- `server_group` (String) ID of the server group to use for the instance
- `user_data` (String) String in base64 format. For Linux instances, 'user_data' is ignored when 'password' field is provided.
For Windows instances, Admin user password is set by 'password' field and cannot be updated via 'user_data'
- `username` (String) For Linux instances, 'username' and 'password' are used to create a new user. For Windows
instances, 'username' cannot be specified. Use 'password' field to set the password for the 'Admin' user on Windows.
- `vm_state` (String) Current vm state, use stopped to stop vm and active to start
- `volume` (Block Set) List of volumes for the instance. You can detach the volume from the instance by removing the
volume from the instance resource. You cannot detach the boot volume. You can attach a data volume
by adding the volume resource inside an instance resource. (see [below for nested schema](#nestedblock--volume))

### Read-Only

- `addresses` (List of Object) List of instance addresses (see [below for nested schema](#nestedatt--addresses))
- `flavor` (Map of String) Flavor details, RAM, vCPU, etc.
- `id` (String) The ID of this resource.
- `security_group` (List of Object) Firewalls list, they will be attached globally on all instance's interfaces (see [below for nested schema](#nestedatt--security_group))
- `last_updated` (String)
- `status` (String) Status of the instance

<a id="nestedblock--interface"></a>
Expand All @@ -432,8 +463,8 @@ Required:

Optional:

- `existing_fip_id` (String)
- `ip_address` (String)
- `existing_fip_id` (String) The id of the existing floating IP that will be attached to the interface
- `ip_address` (String) IP address for the interface.
- `ip_family` (String) IP family for the interface, available values are 'dual', 'ipv4' and 'ipv6'
- `network_id` (String) required if type is 'subnet' or 'any_subnet'
- `order` (Number) Order of attaching interface
Expand All @@ -443,29 +474,35 @@ Optional:
- `type` (String) Available value is 'subnet', 'any_subnet', 'external', 'reserved_fixed_ip'


<a id="nestedblock--configuration"></a>
### Nested Schema for `configuration`
<a id="nestedblock--volume"></a>
### Nested Schema for `volume`

Required:

- `key` (String)
- `value` (String)


<a id="nestedblock--volume"></a>
### Nested Schema for `volume`
- `volume_id` (String)

Optional:

- `attachment_tag` (String)
- `boot_index` (Number) If boot_index==0 volumes can not detached
- `delete_on_termination` (Boolean)

Read-Only:

- `attachment_tag` (String) Tag for the volume attachment
- `delete_on_termination` (Boolean) Delete volume on termination
- `id` (String)
- `image_id` (String)
- `name` (String)
- `size` (Number)
- `type_name` (String)
- `volume_id` (String)
- `image_id` (String) Image ID for the volume
- `name` (String) Name of the volume
- `size` (Number) Size of the volume in GiB
- `type_name` (String) Volume type name


<a id="nestedblock--configuration"></a>
### Nested Schema for `configuration`

Required:

- `key` (String)
- `value` (String)


<a id="nestedatt--addresses"></a>
Expand All @@ -485,15 +522,6 @@ Read-Only:



<a id="nestedatt--security_group"></a>
### Nested Schema for `security_group`

Read-Only:

- `id` (String)
- `name` (String)





Expand Down
23 changes: 23 additions & 0 deletions examples/resources/gcore_instancev2/dualstack-interface.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
resource "gcore_instancev2" "instance" {
flavor_id = "g1-standard-2-4"
name = "my-instance"
keypair_name = "my-keypair"

volume {
volume_id = gcore_volume.boot_volume.id
boot_index = 0
}

interface {
type = "external"
ip_family = "dual"
name = "my-external-interface"
}

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

output "addresses" {
value = gcore_instancev2.instance.addresses
}
2 changes: 1 addition & 1 deletion gcore/resource_gcore_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func resourceInstance() *schema.Resource {
ReadContext: resourceInstanceRead,
UpdateContext: resourceInstanceUpdate,
DeleteContext: resourceInstanceDelete,
Description: "Represent instance",
Description: "Represent instance. **WARNING: This resource is deprecated, please use 'gcore_instancev2' instead**",
DeprecationMessage: "!> **WARNING:** This resource is deprecated, please use 'gcore_instancev2' instead",
Importer: &schema.ResourceImporter{
StateContext: func(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
Expand Down
Loading

0 comments on commit fcb6d9c

Please sign in to comment.