diff options
Diffstat (limited to 'fdio.infra.terraform/terraform-aws-1n-aws-c5n')
6 files changed, 82 insertions, 49 deletions
diff --git a/fdio.infra.terraform/terraform-aws-1n-aws-c5n/hosts.tftpl b/fdio.infra.terraform/terraform-aws-1n-aws-c5n/hosts.tftpl new file mode 100644 index 0000000000..58594efe9d --- /dev/null +++ b/fdio.infra.terraform/terraform-aws-1n-aws-c5n/hosts.tftpl @@ -0,0 +1,5 @@ +all: + children: + tg: + hosts: + ${tg_public_ip}
\ No newline at end of file diff --git a/fdio.infra.terraform/terraform-aws-1n-aws-c5n/main.tf b/fdio.infra.terraform/terraform-aws-1n-aws-c5n/main.tf index c99d839bd2..e455b6b104 100644 --- a/fdio.infra.terraform/terraform-aws-1n-aws-c5n/main.tf +++ b/fdio.infra.terraform/terraform-aws-1n-aws-c5n/main.tf @@ -38,19 +38,24 @@ module "subnet_b" { } # Create Private Key -resource "tls_private_key" "private_key" { - algorithm = var.private_key_algorithm - ecdsa_curve = var.private_key_ecdsa_curve - rsa_bits = var.private_key_rsa_bits +module "private_key" { + source = "pmikus/private-key/tls" + version = "4.0.4" + + private_key_algorithm = var.private_key_algorithm } # Create Key Pair -resource "aws_key_pair" "key_pair" { - depends_on = [ - tls_private_key.private_key - ] - key_name = local.key_pair_key_name - public_key = tls_private_key.private_key.public_key_openssh +module "key_pair" { + source = "pmikus/key-pair/aws" + version = "5.7.0" + + key_pair_key_name = local.key_pair_key_name + key_pair_public_key = module.private_key.public_key_openssh + + key_pair_tags = { + "Environment" = local.environment + } } # Create Placement Group @@ -70,7 +75,7 @@ resource "aws_instance" "tg" { associate_public_ip_address = var.tg_associate_public_ip_address instance_initiated_shutdown_behavior = var.tg_instance_initiated_shutdown_behavior instance_type = var.tg_instance_type - key_name = aws_key_pair.key_pair.key_name + key_name = module.key_pair.key_pair_key_name placement_group = aws_placement_group.placement_group.id private_ip = var.tg_private_ip source_dest_check = var.tg_source_dest_check @@ -167,7 +172,7 @@ resource "null_resource" "deploy_tg" { connection { user = "ubuntu" host = aws_instance.tg.public_ip - private_key = tls_private_key.private_key.private_key_pem + private_key = module.private_key.private_key_pem } provisioner "remote-exec" { @@ -175,27 +180,32 @@ resource "null_resource" "deploy_tg" { } } +resource "local_file" "topology_file" { + depends_on = [ + aws_instance.tg + ] -resource "null_resource" "deploy_topology" { + content = templatefile( + "${path.module}/topology-${local.topology_name}.tftpl", + { + tg_if1_mac = data.aws_network_interface.tg_if1.mac_address + tg_if2_mac = data.aws_network_interface.tg_if2.mac_address + tg_public_ip = aws_instance.tg.public_ip + } + ) + filename = "${path.module}/../../topologies/available/${local.topology_name}-${local.testbed_name}.yaml" +} + +resource "local_file" "hosts" { depends_on = [ aws_instance.tg ] - provisioner "ansible" { - plays { - playbook { - file_path = var.ansible_topology_path - } - hosts = ["local"] - extra_vars = { - ansible_python_interpreter = local.ansible_python_executable - testbed_name = local.testbed_name - cloud_topology = local.topology_name - tg_if1_mac = data.aws_network_interface.tg_if1.mac_address - tg_if2_mac = data.aws_network_interface.tg_if2.mac_address - tg_public_ip = aws_instance.tg.public_ip - public_ip_list = "${aws_instance.tg.public_ip}" - } + content = templatefile( + "${path.module}/hosts.tftpl", + { + tg_public_ip = aws_instance.tg.public_ip } - } + ) + filename = "${path.module}/../../fdio.infra.ansible/inventories/cloud_inventory/hosts.yaml" }
\ No newline at end of file diff --git a/fdio.infra.terraform/terraform-aws-1n-aws-c5n/providers.tf b/fdio.infra.terraform/terraform-aws-1n-aws-c5n/providers.tf index d0e7490d38..2482ca2839 100644 --- a/fdio.infra.terraform/terraform-aws-1n-aws-c5n/providers.tf +++ b/fdio.infra.terraform/terraform-aws-1n-aws-c5n/providers.tf @@ -5,7 +5,7 @@ provider "aws" { } provider "vault" { - address = "http://vault.service.consul:8200" + address = "http://10.30.51.24:8200" skip_tls_verify = true token = "s.4z5PsufFwV3sHbCzK9Y2Cojd" }
\ No newline at end of file diff --git a/fdio.infra.terraform/terraform-aws-1n-aws-c5n/topology-1n-aws-c5n.tftpl b/fdio.infra.terraform/terraform-aws-1n-aws-c5n/topology-1n-aws-c5n.tftpl new file mode 100644 index 0000000000..c99d1f5ebc --- /dev/null +++ b/fdio.infra.terraform/terraform-aws-1n-aws-c5n/topology-1n-aws-c5n.tftpl @@ -0,0 +1,30 @@ +--- +metadata: + version: 0.1 + schema: + - resources/topology_schemas/1_node_topology.sch.yaml + - resources/topology_schemas/topology.sch.yaml + tags: [hw, 1-node] + +nodes: + TG: + type: TG + subtype: TREX + host: "${tg_public_ip}" + arch: x86_64 + port: 22 + username: testuser + password: Csit1234 + interfaces: + port1: + # tg_instance/p1 - 50GE port1 on ENA NIC. + mac_address: "${tg_if1_mac}" + pci_address: "0000:00:06.0" + link: link1 + model: Amazon-Nitro-50G + port2: + # tg_instance/p2 - 50GE port2 on ENA NIC. + mac_address: "${tg_if2_mac}" + pci_address: "0000:00:07.0" + link: link1 + model: Amazon-Nitro-50G
\ No newline at end of file diff --git a/fdio.infra.terraform/terraform-aws-1n-aws-c5n/variables.tf b/fdio.infra.terraform/terraform-aws-1n-aws-c5n/variables.tf index 0eb6bcc769..566a073266 100644 --- a/fdio.infra.terraform/terraform-aws-1n-aws-c5n/variables.tf +++ b/fdio.infra.terraform/terraform-aws-1n-aws-c5n/variables.tf @@ -24,19 +24,7 @@ variable "testbed_name" { variable "private_key_algorithm" { description = "The name of the algorithm to use for the key." type = string - default = "RSA" -} - -variable "private_key_ecdsa_curve" { - description = "When algorithm is ECDSA, the name of the elliptic curve to use." - type = string - default = "P521" -} - -variable "private_key_rsa_bits" { - description = "When algorithm is RSA, the size of the generated RSA key in bits." - type = number - default = 4096 + default = "ED25519" } # Variables for Placement Group @@ -50,7 +38,7 @@ variable "placement_group_strategy" { variable "tg_ami" { description = "AMI to use for the instance." type = string - default = "ami-01d1d62914ef00b25" + default = "ami-07430bfa17fd4e597" } variable "tg_associate_public_ip_address" { diff --git a/fdio.infra.terraform/terraform-aws-1n-aws-c5n/versions.tf b/fdio.infra.terraform/terraform-aws-1n-aws-c5n/versions.tf index 0eead1fc01..7e17bb4924 100644 --- a/fdio.infra.terraform/terraform-aws-1n-aws-c5n/versions.tf +++ b/fdio.infra.terraform/terraform-aws-1n-aws-c5n/versions.tf @@ -2,19 +2,19 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 4.3.0" + version = ">= 5.7.0" } null = { source = "hashicorp/null" - version = "~> 3.1.0" + version = ">= 3.2.1" } tls = { source = "hashicorp/tls" - version = "~> 3.1.0" + version = ">= 4.0.4" } vault = { - version = ">=2.22.1" + version = ">= 3.15.2" } } - required_version = ">= 1.0.4" + required_version = ">= 1.4.2" } |