Files
threshold/enos/modules/target/main.tf
T
Michael AnthonyandJosh Brand 073f8fe98e [QT-405] Create solo worker module (#3148)
* Create solo worker module

---------

Co-authored-by: Josh Brand <jbrand@hashicorp.com>
2023-04-12 14:21:23 -06:00

63 lines
1.4 KiB
Terraform

# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
variable "vpc_id" {}
variable "ami_id" {}
variable "subnet_ids" {}
variable "target_count" {}
variable "environment" {}
variable "project_name" {}
variable "instance_type" {}
variable "aws_ssh_keypair_name" {}
variable "enos_user" {}
variable "additional_tags" {
default = {}
}
resource "aws_security_group" "boundary_target" {
name_prefix = "boundary-target-sg"
description = "SSH and boundary Traffic"
vpc_id = var.vpc_id
# SSH
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["10.0.0.0/8"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
"Name" : "boundary-target-sg"
}
}
resource "aws_instance" "target" {
count = var.target_count
ami = var.ami_id
instance_type = var.instance_type
vpc_security_group_ids = [aws_security_group.boundary_target.id]
subnet_id = var.subnet_ids[count.index % length(var.subnet_ids)]
key_name = var.aws_ssh_keypair_name
tags = merge(var.additional_tags, {
"Name" : "boundary-target-${count.index}",
"Type" : "target",
"Project" : "Enos",
"Project Name" : "qti-enos-boundary",
"Environment" : var.environment
"Enos User" : var.enos_user,
})
}
output "target_ips" {
value = aws_instance.target.*.private_ip
}