-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
67 lines (59 loc) · 1.95 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# ECS Instance Module
terraform {
required_version = ">= 0.12.0"
//Uncomment if you want to use Object storage as bakcend for your .tfstate
/*backend "s3" {
bucket = "obs-terraform-backend"
key = "ecs-p2-terraform-plan--boot-from-volumes"
region = "eu-west-0"
endpoint = "https://oss.eu-west-0.prod-cloud-ocb.orange-business.com"
skip_region_validation = true
skip_credentials_validation = true
}*/
}
// Instance ressource block_device
resource "flexibleengine_compute_instance_v2" "instance" {
availability_zone = var.availability_zone
count = var.instance_count
name = var.instance_name[terraform.workspace]
flavor_name = var.flavor_name
key_pair = var.key_pair
user_data = var.user_data
block_device {
uuid = var.system_disk[terraform.workspace]
source_type = "volume"
destination_type = "volume"
boot_index = 0
delete_on_termination = false
}
block_device {
uuid = var.data_disk[terraform.workspace]
source_type = "volume"
destination_type = "volume"
boot_index = 1
delete_on_termination = false
}
network {
port = flexibleengine_networking_port_v2.instance_port[count.index].id
access_network = true
}
}
resource "flexibleengine_networking_port_v2" "instance_port" {
network_id = var.network_id
count = var.instance_count
security_group_ids = var.security_groups
admin_state_up = "true"
fixed_ip {
subnet_id = var.subnet_id
ip_address = var.fixed_ip[terraform.workspace]
}
}
resource "flexibleengine_networking_floatingip_v2" "fip" {
count = var.attach_eip ? var.instance_count : 0
pool = var.ext_net_name
port_id = element(
flexibleengine_networking_port_v2.instance_port.*.id,
count.index,
)
depends_on = [flexibleengine_compute_instance_v2.instance]
}