From b728fbcb19e6458c24aa2bbbe31f0790e8d7dbcd Mon Sep 17 00:00:00 2001 From: Dmitry Kireev Date: Wed, 26 Jun 2024 20:41:05 +0000 Subject: [PATCH] Add external tags, cleanup tags, lint --- main.tf | 25 ++++++++++--------------- variables.tf | 8 +++++++- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/main.tf b/main.tf index abb8fc8..0969b62 100644 --- a/main.tf +++ b/main.tf @@ -17,28 +17,23 @@ resource "aws_security_group" "this" { cidr_blocks = var.allowed_cidr_blocks } - tags = { - Terraform = "true" - Env = var.env - Name = "${var.env}-bastion" - } + tags = merge({ + name = "${var.env}-bastion" + }, var.tags) } # TODO: This needs to become an autoscale of one instance resource "aws_instance" "this" { - ami = data.aws_ami.this.id - key_name = var.ec2_key_pair_name - instance_type = var.instance_type - iam_instance_profile = aws_iam_instance_profile.this.name + ami = data.aws_ami.this.id + key_name = var.ec2_key_pair_name + instance_type = var.instance_type + iam_instance_profile = aws_iam_instance_profile.this.name vpc_security_group_ids = concat(var.ext_security_groups, [ aws_security_group.this.id ]) subnet_id = var.private_subnets[0] associate_public_ip_address = false - - tags = { - Terraform = "true" - Env = var.env - Name = local.name - } + tags = merge({ + name = "${var.env}-bastion" + }, var.tags) } diff --git a/variables.tf b/variables.tf index c6dcda5..bf99d56 100644 --- a/variables.tf +++ b/variables.tf @@ -24,6 +24,12 @@ variable "ssm_role" { default = "arn:aws:iam::aws:policy/service-role/AmazonEC2RoleforSSM" } +variable "tags" { + type = map(string) + description = "Additional tags for the resources" + default = {} +} + variable "ssh_forward_rules" { type = list(string) description = "Rules that will enable port forwarding. SSH Config syntax" @@ -40,7 +46,7 @@ locals { proxycommand = <<-EOT ProxyCommand sh -c "aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p'" EOT - ssh_config = concat([ + ssh_config = concat([ "# SSH over Session Manager", "host i-* mi-*", "ServerAliveInterval 180",