diff --git a/cloud/terraform/otc/main.tf b/cloud/terraform/otc/main.tf index c6e81bf3..86e38e1e 100644 --- a/cloud/terraform/otc/main.tf +++ b/cloud/terraform/otc/main.tf @@ -14,24 +14,18 @@ resource "opentelekomcloud_networking_secgroup_rule_v2" "secgroup_rule_1" { security_group_id = opentelekomcloud_networking_secgroup_v2.secgroup_1.id } -resource "opentelekomcloud_networking_network_v2" "network_1" { - name = var.network_name +resource "opentelekomcloud_vpc_v1" "vpc_1" { + name = var.vpc_name + cidr = var.vpc_cidr } -resource "opentelekomcloud_networking_subnet_v2" "subnet_1" { - name = var.subnet_name - network_id = opentelekomcloud_networking_network_v2.network_1.id - cidr = "192.168.0.0/24" - dns_nameservers = ["1.1.1.1", "8.8.8.8"] -} +resource "opentelekomcloud_vpc_subnet_v1" "subnet_1" { + name = var.subnet_name + cidr = var.subnet_cidr + vpc_id = opentelekomcloud_vpc_v1.vpc_1.id -resource "opentelekomcloud_networking_router_v2" "router_1" { - name = var.router_name -} - -resource "opentelekomcloud_networking_router_interface_v2" "router_interface_1" { - router_id = opentelekomcloud_networking_router_v2.router_1.id - subnet_id = opentelekomcloud_networking_subnet_v2.subnet_1.id + gateway_ip = var.subnet_gateway_ip + dns_list = ["100.125.4.25", "100.125.129.199"] } resource "random_id" "tpot" { @@ -39,33 +33,35 @@ resource "random_id" "tpot" { prefix = var.ecs_prefix } -resource "opentelekomcloud_compute_instance_v2" "ecs_1" { +resource "opentelekomcloud_ecs_instance_v1" "ecs_1" { + name = random_id.tpot.b64_std + image_id = data.opentelekomcloud_images_image_v2.debian.id + flavor = var.ecs_flavor + vpc_id = opentelekomcloud_vpc_v1.vpc_1.id + + nics { + network_id = opentelekomcloud_vpc_subnet_v1.subnet_1.id + } + + system_disk_size = var.ecs_disk_size + security_groups = [opentelekomcloud_networking_secgroup_v2.secgroup_1.id] availability_zone = var.availability_zone - name = random_id.tpot.b64_std - flavor_name = var.flavor - key_pair = var.key_pair - security_groups = [opentelekomcloud_networking_secgroup_v2.secgroup_1.name] + key_name = var.key_pair user_data = templatefile("../cloud-init.yaml", { timezone = var.timezone, password = var.linux_password, tpot_flavor = var.tpot_flavor, web_user = var.web_user, web_password = var.web_password }) +} - network { - name = opentelekomcloud_networking_network_v2.network_1.name +resource "opentelekomcloud_vpc_eip_v1" "eip_1" { + publicip { + type = "5_bgp" } - - block_device { - uuid = data.opentelekomcloud_images_image_v2.debian.id - source_type = "image" - volume_size = var.volume_size - destination_type = "volume" - delete_on_termination = "true" + bandwidth { + name = "bandwidth-${random_id.tpot.b64_std}" + size = var.eip_size + share_type = "PER" } - - depends_on = [opentelekomcloud_networking_router_interface_v2.router_interface_1] } -resource "opentelekomcloud_networking_floatingip_v2" "floatip_1" { -} - -resource "opentelekomcloud_compute_floatingip_associate_v2" "fip_2" { - floating_ip = opentelekomcloud_networking_floatingip_v2.floatip_1.address - instance_id = opentelekomcloud_compute_instance_v2.ecs_1.id +resource "opentelekomcloud_compute_floatingip_associate_v2" "fip_1" { + floating_ip = opentelekomcloud_vpc_eip_v1.eip_1.publicip.0.ip_address + instance_id = opentelekomcloud_ecs_instance_v1.ecs_1.id } diff --git a/cloud/terraform/otc/outputs.tf b/cloud/terraform/otc/outputs.tf index 2ec77c27..96cc7922 100644 --- a/cloud/terraform/otc/outputs.tf +++ b/cloud/terraform/otc/outputs.tf @@ -1,11 +1,11 @@ output "Admin_UI" { - value = "https://${opentelekomcloud_networking_floatingip_v2.floatip_1.address}:64294" + value = "https://${opentelekomcloud_vpc_eip_v1.eip_1.publicip.0.ip_address}:64294" } output "SSH_Access" { - value = "ssh -p 64295 linux@${opentelekomcloud_networking_floatingip_v2.floatip_1.address}" + value = "ssh -p 64295 linux@${opentelekomcloud_vpc_eip_v1.eip_1.publicip.0.ip_address}" } output "Web_UI" { - value = "https://${opentelekomcloud_networking_floatingip_v2.floatip_1.address}:64297" + value = "https://${opentelekomcloud_vpc_eip_v1.eip_1.publicip.0.ip_address}:64297" } diff --git a/cloud/terraform/otc/variables.tf b/cloud/terraform/otc/variables.tf index 40831815..e70c89eb 100644 --- a/cloud/terraform/otc/variables.tf +++ b/cloud/terraform/otc/variables.tf @@ -1,4 +1,4 @@ -# cloud-init configuration +## cloud-init configuration ## variable "timezone" { default = "UTC" } @@ -13,40 +13,52 @@ variable "linux_password" { } } -# Cloud resources name configuration +## Security Group ## variable "secgroup_name" { - default = "tpot-secgroup" + default = "sg-tpot" } variable "secgroup_desc" { - default = "T-Pot Security Group" + default = "Security Group for T-Pot" } -variable "network_name" { - default = "tpot-network" +## Virtual Private Cloud ## +variable "vpc_name" { + default = "vpc-tpot" } +variable "vpc_cidr" { + default = "192.168.0.0/16" +} + +## Subnet ## variable "subnet_name" { - default = "tpot-subnet" + default = "subnet-tpot" } -variable "router_name" { - default = "tpot-router" +variable "subnet_cidr" { + default = "192.168.0.0/24" } +variable "subnet_gateway_ip" { + default = "192.168.0.1" +} + +## Elastic Cloud Server ## variable "ecs_prefix" { default = "tpot-" } -# ECS configuration -variable "availability_zone" { - default = "eu-de-03" - description = "Select an availability zone" +variable "ecs_flavor" { + default = "s3.medium.8" } -variable "flavor" { - default = "s3.medium.8" - description = "Select a compute flavor" +variable "ecs_disk_size" { + default = "128" +} + +variable "availability_zone" { + default = "eu-de-03" } variable "key_pair" { @@ -59,12 +71,12 @@ variable "key_pair" { } } -variable "volume_size" { - default = "128" - description = "Set the volume size" +## Elastic IP ## +variable "eip_size" { + default = "100" } -# These will go in the generated tpot.conf file +## These will go in the generated tpot.conf file ## variable "tpot_flavor" { default = "STANDARD" description = "Specify your tpot flavor [STANDARD, SENSOR, INDUSTRIAL, COLLECTOR, NEXTGEN, MEDICAL]"