From 71770f793de1a90fea014e719992fb706b18f489 Mon Sep 17 00:00:00 2001 From: Novikov Sergey Date: Wed, 7 Sep 2022 18:36:41 +0200 Subject: [PATCH] OPS-0 fix outdated modules (#11) * OPS-0 fix outdated modules * OPS-0 fix ec2-modules * OPS-0 fix formatting --- main.tf | 25 +++++++++++++------------ versions.tf | 9 +++++++++ 2 files changed, 22 insertions(+), 12 deletions(-) create mode 100644 versions.tf diff --git a/main.tf b/main.tf index d80c232..6c9cd55 100644 --- a/main.tf +++ b/main.tf @@ -16,7 +16,8 @@ locals { # VPC module "vpc" { - source = "terraform-aws-modules/vpc/aws" + source = "terraform-aws-modules/vpc/aws" + version = "3.14.4" name = "xlt-${var.name}" cidr = var.local_network @@ -34,7 +35,7 @@ module "vpc" { # Security Group for the EC2 Agents module "ec2_sg" { source = "terraform-aws-modules/security-group/aws" - version = "3.0.1" + version = "4.13.0" name = "${var.name}-sg" description = "Security group for - xceptance - ec2-to-nlb" @@ -71,16 +72,16 @@ module "ec2_sg" { # XLT module "xceptance_cluster" { source = "terraform-aws-modules/ec2-instance/aws" - version = "~> 2.0" + version = "4.1.4" - name = "xlt-${var.name}" - instance_count = var.instance_count + count = var.instance_count + name = "xlt-${var.name}-${count.index}" ami = var.ami instance_type = var.instance_type key_name = var.keyname monitoring = true - vpc_security_group_ids = [module.ec2_sg.this_security_group_id] + vpc_security_group_ids = [module.ec2_sg.security_group_id] subnet_id = module.vpc.private_subnets[0] user_data = "{\"acPassword\":\"${var.password}\",\"hostData\":\"\"}" @@ -91,16 +92,16 @@ module "xceptance_cluster" { # Grafana module "grafana" { source = "terraform-aws-modules/ec2-instance/aws" - version = "~> 2.0" + version = "4.1.4" - name = "grafana-${var.name}" - instance_count = var.grafana_enabled ? 1 : 0 + name = "grafana-${var.name}" + create = var.grafana_enabled ? true : false ami = var.grafana_ami instance_type = "m4.xlarge" key_name = var.keyname monitoring = true - vpc_security_group_ids = [module.ec2_sg.this_security_group_id] + vpc_security_group_ids = [module.ec2_sg.security_group_id] subnet_id = module.vpc.private_subnets[0] private_ip = local.graphite_host associate_public_ip_address = false @@ -154,7 +155,7 @@ resource "aws_lb_listener" "this" { resource "aws_lb_target_group_attachment" "agents" { count = var.instance_count target_group_arn = aws_lb_target_group.this[count.index].arn - target_id = module.xceptance_cluster.private_ip[count.index] + target_id = module.xceptance_cluster[count.index].private_ip port = 8500 } @@ -187,7 +188,7 @@ resource "aws_lb_listener" "grafana" { resource "aws_lb_target_group_attachment" "grafana" { count = var.grafana_enabled ? 1 : 0 target_group_arn = concat(aws_lb_target_group.grafana.*.arn, [""])[0] - target_id = module.grafana.private_ip[0] + target_id = module.grafana.private_ip port = 443 } diff --git a/versions.tf b/versions.tf new file mode 100644 index 0000000..d265b5c --- /dev/null +++ b/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 4" + } + } + required_version = ">= 1.0" +}