terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
}

provider "aws" {
  region = "us-east-1"
}

resource "aws_instance" "rbac_worker" {
  count         = 3
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "m5.xlarge"
  key_name      = "performance-test-key"

  tags = {
    Name = "rbac-worker-${count.index}"
  }
}

resource "aws_instance" "load_generator" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "m5.2xlarge"
  key_name      = "performance-test-key"

  tags = {
    Name = "rbac-load-generator"
  }
}

resource "aws_security_group" "perf_test" {
  name        = "rbac-perf-test-sg"
  description = "Allow test traffic between nodes"

  ingress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    self        = true
  }

  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"]
  }
}