Skip to content

Commit d03850e

Browse files
authored
Merge pull request #8265 from ovh/terraform-quick-start
fix: public-cloud-terraform: remove provider/alias informations from examples
2 parents 40429a5 + 3c8331b commit d03850e

File tree

20 files changed

+255
-507
lines changed

20 files changed

+255
-507
lines changed

pages/public_cloud/public_cloud_cross_functional/how_to_use_terraform/guide.de-de.md

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ required_version = ">= 0.14.0" # Takes into account Terraform versions from 0
7878
source = "terraform-provider-openstack/openstack"
7979
version = ">= 3.0.0"
8080
}
81-
81+
8282
ovh = {
8383
source = "ovh/ovh"
8484
version = ">= 2.1.0"
@@ -90,11 +90,9 @@ required_version = ">= 0.14.0" # Takes into account Terraform versions from 0
9090
provider "openstack" {
9191
auth_url = "https://auth.cloud.ovh.net/v3/" # Authentication URL
9292
domain_name = "default" # Domain name - Always at 'default' for OVHcloud
93-
alias = "ovh" # An alias
9493
}
9594

9695
provider "ovh" {
97-
alias = "ovh"
9896
endpoint = "ovh-eu"
9997
application_key = "<your_access_key>"
10098
application_secret = "<your_application_secret>"
@@ -145,15 +143,13 @@ For example purposes, we will create a simple instance on **Debian 10** with the
145143
```python
146144
# Creating an SSH key pair resource
147145
resource "openstack_compute_keypair_v2" "test_keypair" {
148-
provider = openstack.ovh # Provider name declared in provider.tf
149146
name = "test_keypair" # Name of the SSH key to use for creation
150147
public_key = file("~/.ssh/id_rsa.pub") # Path to your previously generated SSH key
151148
}
152-
149+
153150
# Creating the instance
154151
resource "openstack_compute_instance_v2" "test_terraform_instance" {
155152
name = "terraform_instance" # Instance name
156-
provider = openstack.ovh # Provider name
157153
image_name = "Debian 10" # Image name
158154
flavor_name = "d2-2" # Instance type name
159155
# Name of openstack_compute_keypair_v2 resource named keypair_test
@@ -162,7 +158,7 @@ resource "openstack_compute_instance_v2" "test_terraform_instance" {
162158
name = "Ext-Net" # Adds the network component to reach your instance
163159
}
164160
lifecycle {
165-
# OVHcloud regularly updates the base image of a given OS so that customer has less packages to update after spawning a new instance
161+
# OVHcloud regularly updates the base image of a given OS so that customer has less packages to update after spawning a new instance
166162
# To avoid terraform to have some issue with that, the following ignore_changes is required.
167163
ignore_changes = [
168164
image_name
@@ -281,22 +277,20 @@ To do this, we will create a file named `multiple_instance.tf`. In it, we first
281277
type = list
282278
default = ["GRA11", "SBG5", "BHS5"]
283279
}
284-
280+
285281
# Creating an SSH key pair
286282
resource "openstack_compute_keypair_v2" "test_keypair_all" {
287283
count = length(var.region)
288-
provider = openstack.ovh # Specify provider name
289284
name = "test_keypair_all" # Name of the SSH key
290285
public_key = file("~/.ssh/id_rsa.pub") # Your SSH key path
291286
region = element(var.region, count.index)
292287
}
293-
288+
294289
# Create a resource that is an OpenStack instance in each region
295290
resource "openstack_compute_instance_v2" "instances_on_all_regions" {
296291
# Number of times the resource will be created
297292
# defined by the length of the list named region
298293
count = length(var.region)
299-
provider = openstack.ovh # Provider name
300294
name = "terraform_instances" # Instance name
301295
flavor_name = "d2-2" # Instance flavor
302296
image_name = "Debian 10" # Image name
@@ -334,9 +328,8 @@ In this example we will attach a new storage volume to our first instance. Open
334328
resource "openstack_blockstorage_volume_v2" "volume_to_add" {
335329
name = "simple_volume" # Volume name
336330
size = 10 # Volume size in GB
337-
provider = openstack.ovh # Provider name
338331
}
339-
332+
340333
# Attach the volume created previously to the instance
341334
resource "openstack_compute_volume_attach_v2" "attached" {
342335
# ID of openstack_compute_instance_v2 resource named test_terraform_instance
@@ -381,18 +374,17 @@ variable "region" {
381374
resource "ovh_vrack_cloudproject" "vcp" {
382375
service_name = var.service_name
383376
project_id = var.project_id
384-
}
377+
}
385378

386379
# Creating a private network
387380
resource "ovh_cloud_project_network_private" "network" {
388381
service_name = var.service_name
389382
name = "private_network" # Network name
390383
regions = [var.region]
391-
provider = ovh.ovh # Provider name
392384
vlan_id = 168 # VLAN ID for vRack
393385
depends_on = [ovh_vrack_cloudproject.vcp] # Depends on the vRack's association with the cloud project
394386
}
395-
387+
396388
# Creating a subnet using the previously created private network
397389
resource "ovh_cloud_project_network_private_subnet" "subnet" {
398390
service_name = var.service_name
@@ -403,13 +395,11 @@ variable "region" {
403395
network = "192.168.168.0/24" # Subnet IP address location
404396
dhcp = true # Enables DHCP
405397
region = var.region
406-
provider = ovh.ovh # Provider name
407398
no_gateway = true # No default gateway
408399
}
409-
400+
410401
# Creating an instance with 2 network interfaces
411402
resource "openstack_compute_instance_v2" "proxy_instance" {
412-
provider = openstack.ovh # Provider name
413403
name = "proxy_instance" # Instance name
414404
image_name = "Debian 10" # Image name
415405
flavor_name = "d2-2" # Flavor name
@@ -465,12 +455,11 @@ variable myregion {
465455
resource "ovh_cloud_project_network_private" "private_network" {
466456
service_name = var.service_name
467457
name = "backend" # Network name
468-
regions = [var.myregion]
469-
provider = ovh.ovh # Provider name
458+
regions = [var.myregion]
470459
vlan_id = 42 # vRack vlan ID
471460
depends_on = [ovh_vrack_cloudproject.vcp] # Depends on vRack being associated with the cloud project
472461
}
473-
462+
474463
# Creating a private subnet
475464
resource "ovh_cloud_project_network_private_subnet" "private_subnet" {
476465
# ID for the ovh_cloud_network_private resource named private_network
@@ -481,27 +470,24 @@ resource "ovh_cloud_project_network_private_subnet" "private_subnet" {
481470
start = "192.168.42.2" # First IP of the subnet
482471
end = "192.168.42.200" # Last IP of the subnet
483472
dhcp = false # Disabling DHCP
484-
provider = ovh.ovh # Provider name
485473
no_gateway = true # No default gateway
486474
}
487-
475+
488476
# Search for the latest Archlinux image
489477
data "openstack_images_image_v2" "archlinux" {
490478
name = "Archlinux" # Image name
491479
most_recent = true # Limits search to the most recent
492-
provider = openstack.ovh # Provider name
493480
}
494-
481+
495482
# List of possible private IP addresses for front-ends
496483
variable "front_private_ip" {
497484
type = list(any)
498485
default = ["192.168.42.2", "192.168.42.3"]
499486
}
500-
487+
501488
# Create 2 instances with 2 network interfaces
502489
resource "openstack_compute_instance_v2" "front" {
503490
count = length(var.front_private_ip) # Number of instances to create
504-
provider = openstack.ovh # Provider name
505491
name = "front" # Instance name
506492
key_pair = openstack_compute_keypair_v2.test_keypair.name
507493
flavor_name = "d2-2" # Instance type name
@@ -518,17 +504,15 @@ resource "openstack_compute_instance_v2" "front" {
518504
}
519505
depends_on = [ovh_cloud_project_network_private_subnet.private_subnet] # Depends on private network
520506
}
521-
507+
522508
# Create an attachable storage device for the backup (volume)
523509
resource "openstack_blockstorage_volume_v2" "backup" {
524510
name = "backup_disk" # Name of storage device
525511
size = 10 # Size
526-
provider = openstack.ovh # Provider name
527512
}
528-
513+
529514
# Create an instance with a network interface and storage device
530515
resource "openstack_compute_instance_v2" "back" {
531-
provider = openstack.ovh # Provider name
532516
name = "back" # Instance name
533517
key_pair = openstack_compute_keypair_v2.test_keypair.name
534518
flavor_name = "d2-2" # Instance type name

pages/public_cloud/public_cloud_cross_functional/how_to_use_terraform/guide.en-asia.md

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ required_version = ">= 0.14.0" # Takes into account Terraform versions from 0
7878
source = "terraform-provider-openstack/openstack"
7979
version = ">= 3.0.0"
8080
}
81-
81+
8282
ovh = {
8383
source = "ovh/ovh"
8484
version = ">= 2.1.0"
@@ -90,11 +90,9 @@ required_version = ">= 0.14.0" # Takes into account Terraform versions from 0
9090
provider "openstack" {
9191
auth_url = "https://auth.cloud.ovh.net/v3/" # Authentication URL
9292
domain_name = "default" # Domain name - Always at 'default' for OVHcloud
93-
alias = "ovh" # An alias
9493
}
9594

9695
provider "ovh" {
97-
alias = "ovh"
9896
endpoint = "ovh-eu"
9997
application_key = "<your_access_key>"
10098
application_secret = "<your_application_secret>"
@@ -145,15 +143,13 @@ For example purposes, we will create a simple instance on **Debian 10** with the
145143
```python
146144
# Creating an SSH key pair resource
147145
resource "openstack_compute_keypair_v2" "test_keypair" {
148-
provider = openstack.ovh # Provider name declared in provider.tf
149146
name = "test_keypair" # Name of the SSH key to use for creation
150147
public_key = file("~/.ssh/id_rsa.pub") # Path to your previously generated SSH key
151148
}
152-
149+
153150
# Creating the instance
154151
resource "openstack_compute_instance_v2" "test_terraform_instance" {
155152
name = "terraform_instance" # Instance name
156-
provider = openstack.ovh # Provider name
157153
image_name = "Debian 10" # Image name
158154
flavor_name = "d2-2" # Instance type name
159155
# Name of openstack_compute_keypair_v2 resource named keypair_test
@@ -162,7 +158,7 @@ resource "openstack_compute_instance_v2" "test_terraform_instance" {
162158
name = "Ext-Net" # Adds the network component to reach your instance
163159
}
164160
lifecycle {
165-
# OVHcloud regularly updates the base image of a given OS so that customer has less packages to update after spawning a new instance
161+
# OVHcloud regularly updates the base image of a given OS so that customer has less packages to update after spawning a new instance
166162
# To avoid terraform to have some issue with that, the following ignore_changes is required.
167163
ignore_changes = [
168164
image_name
@@ -281,22 +277,20 @@ To do this, we will create a file named `multiple_instance.tf`. In it, we first
281277
type = list
282278
default = ["GRA11", "SBG5", "BHS5"]
283279
}
284-
280+
285281
# Creating an SSH key pair
286282
resource "openstack_compute_keypair_v2" "test_keypair_all" {
287283
count = length(var.region)
288-
provider = openstack.ovh # Specify provider name
289284
name = "test_keypair_all" # Name of the SSH key
290285
public_key = file("~/.ssh/id_rsa.pub") # Your SSH key path
291286
region = element(var.region, count.index)
292287
}
293-
288+
294289
# Create a resource that is an OpenStack instance in each region
295290
resource "openstack_compute_instance_v2" "instances_on_all_regions" {
296291
# Number of times the resource will be created
297292
# defined by the length of the list named region
298293
count = length(var.region)
299-
provider = openstack.ovh # Provider name
300294
name = "terraform_instances" # Instance name
301295
flavor_name = "d2-2" # Instance flavor
302296
image_name = "Debian 10" # Image name
@@ -334,9 +328,8 @@ In this example we will attach a new storage volume to our first instance. Open
334328
resource "openstack_blockstorage_volume_v2" "volume_to_add" {
335329
name = "simple_volume" # Volume name
336330
size = 10 # Volume size in GB
337-
provider = openstack.ovh # Provider name
338331
}
339-
332+
340333
# Attach the volume created previously to the instance
341334
resource "openstack_compute_volume_attach_v2" "attached" {
342335
# ID of openstack_compute_instance_v2 resource named test_terraform_instance
@@ -381,18 +374,17 @@ variable "region" {
381374
resource "ovh_vrack_cloudproject" "vcp" {
382375
service_name = var.service_name
383376
project_id = var.project_id
384-
}
377+
}
385378

386379
# Creating a private network
387380
resource "ovh_cloud_project_network_private" "network" {
388381
service_name = var.service_name
389382
name = "private_network" # Network name
390383
regions = [var.region]
391-
provider = ovh.ovh # Provider name
392384
vlan_id = 168 # VLAN ID for vRack
393385
depends_on = [ovh_vrack_cloudproject.vcp] # Depends on the vRack's association with the cloud project
394386
}
395-
387+
396388
# Creating a subnet using the previously created private network
397389
resource "ovh_cloud_project_network_private_subnet" "subnet" {
398390
service_name = var.service_name
@@ -403,13 +395,11 @@ variable "region" {
403395
network = "192.168.168.0/24" # Subnet IP address location
404396
dhcp = true # Enables DHCP
405397
region = var.region
406-
provider = ovh.ovh # Provider name
407398
no_gateway = true # No default gateway
408399
}
409-
400+
410401
# Creating an instance with 2 network interfaces
411402
resource "openstack_compute_instance_v2" "proxy_instance" {
412-
provider = openstack.ovh # Provider name
413403
name = "proxy_instance" # Instance name
414404
image_name = "Debian 10" # Image name
415405
flavor_name = "d2-2" # Flavor name
@@ -465,12 +455,11 @@ variable myregion {
465455
resource "ovh_cloud_project_network_private" "private_network" {
466456
service_name = var.service_name
467457
name = "backend" # Network name
468-
regions = [var.myregion]
469-
provider = ovh.ovh # Provider name
458+
regions = [var.myregion]
470459
vlan_id = 42 # vRack vlan ID
471460
depends_on = [ovh_vrack_cloudproject.vcp] # Depends on vRack being associated with the cloud project
472461
}
473-
462+
474463
# Creating a private subnet
475464
resource "ovh_cloud_project_network_private_subnet" "private_subnet" {
476465
# ID for the ovh_cloud_network_private resource named private_network
@@ -481,27 +470,24 @@ resource "ovh_cloud_project_network_private_subnet" "private_subnet" {
481470
start = "192.168.42.2" # First IP of the subnet
482471
end = "192.168.42.200" # Last IP of the subnet
483472
dhcp = false # Disabling DHCP
484-
provider = ovh.ovh # Provider name
485473
no_gateway = true # No default gateway
486474
}
487-
475+
488476
# Search for the latest Archlinux image
489477
data "openstack_images_image_v2" "archlinux" {
490478
name = "Archlinux" # Image name
491479
most_recent = true # Limits search to the most recent
492-
provider = openstack.ovh # Provider name
493480
}
494-
481+
495482
# List of possible private IP addresses for front-ends
496483
variable "front_private_ip" {
497484
type = list(any)
498485
default = ["192.168.42.2", "192.168.42.3"]
499486
}
500-
487+
501488
# Create 2 instances with 2 network interfaces
502489
resource "openstack_compute_instance_v2" "front" {
503490
count = length(var.front_private_ip) # Number of instances to create
504-
provider = openstack.ovh # Provider name
505491
name = "front" # Instance name
506492
key_pair = openstack_compute_keypair_v2.test_keypair.name
507493
flavor_name = "d2-2" # Instance type name
@@ -518,17 +504,15 @@ resource "openstack_compute_instance_v2" "front" {
518504
}
519505
depends_on = [ovh_cloud_project_network_private_subnet.private_subnet] # Depends on private network
520506
}
521-
507+
522508
# Create an attachable storage device for the backup (volume)
523509
resource "openstack_blockstorage_volume_v2" "backup" {
524510
name = "backup_disk" # Name of storage device
525511
size = 10 # Size
526-
provider = openstack.ovh # Provider name
527512
}
528-
513+
529514
# Create an instance with a network interface and storage device
530515
resource "openstack_compute_instance_v2" "back" {
531-
provider = openstack.ovh # Provider name
532516
name = "back" # Instance name
533517
key_pair = openstack_compute_keypair_v2.test_keypair.name
534518
flavor_name = "d2-2" # Instance type name

0 commit comments

Comments
 (0)