You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
consul/test/load/terraform/test-servers.tf

77 lines
2.0 KiB

# 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>
1 year ago
# 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-*"]
}
}
# ---------------------------------------------------------------------------------------------------------------------
# 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]
protocol = "6"
cidr_blocks = [var.vpc_cidr]
}
ingress {
from_port = 22
to_port = 22
protocol = "6"
cidr_blocks = [var.vpc_allwed_ssh_cidr]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
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])
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}",
"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
}
}
}