consul/test/load/terraform/test-servers.tf

77 lines
2.0 KiB
Terraform
Raw Normal View History

# Copyright (c) HashiCorp, Inc.
[COMPLIANCE] License changes (#18443) * Adding explicit MPL license for sub-package This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at <Blog URL>, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
2023-08-11 13:12:13 +00:00
# SPDX-License-Identifier: BUSL-1.1
data "aws_ami" "test" {
most_recent = true
owners = var.ami_owners
filter {
name = "virtualization-type"
values = ["hvm"]
}
filter {
name = "is-public"
values = ["false"]
}
filter {
name = "name"
values = ["consul-test-*"]
}
}
2020-10-06 01:16:09 +00:00
# ---------------------------------------------------------------------------------------------------------------------
# Start up test servers to run tests from
# ---------------------------------------------------------------------------------------------------------------------
resource "aws_security_group" "test-servers" {
name = "${local.random_name}-test-server-sg"
vpc_id = module.vpc.vpc_id
ingress {
from_port = 8500
to_port = 8500
security_groups = [module.consul_clients.security_group_id]
2020-10-06 01:16:09 +00:00
protocol = "6"
2022-05-16 20:49:46 +00:00
cidr_blocks = [var.vpc_cidr]
2020-10-06 01:16:09 +00:00
}
ingress {
from_port = 22
to_port = 22
protocol = "6"
cidr_blocks = [var.vpc_allwed_ssh_cidr]
2020-10-06 01:16:09 +00:00
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
2020-10-06 01:16:09 +00:00
}
}
resource "aws_instance" "test-server" {
ami = var.test_server_ami == null ? data.aws_ami.test.id : var.test_server_ami
instance_type = var.test_instance_type
key_name = module.keys.key_name
vpc_security_group_ids = toset([aws_security_group.test-servers.id])
2020-10-06 01:16:09 +00:00
associate_public_ip_address = var.test_public_ip
subnet_id = (module.vpc.public_subnets)[0]
tags = {
Name = "consul-load-generator-server-${local.random_name}"
}
provisioner "remote-exec" {
inline = [
"export LB_ENDPOINT=${module.alb.this_lb_dns_name}",
2020-12-15 23:03:44 +00:00
"k6 run -q /home/ubuntu/scripts/loadtest.js"
]
connection {
type = "ssh"
user = "ubuntu"
timeout = "1m"
private_key = module.keys.private_key_pem
host = aws_instance.test-server.public_ip
2020-10-06 01:16:09 +00:00
}
}
}