Skip to content

Commit

Permalink
feat: Tags refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
sugdyzhekov committed Jul 18, 2020
1 parent 7178b97 commit 6ad9c55
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
20 changes: 6 additions & 14 deletions launch_template.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,20 @@ resource "aws_network_interface" "nat" {
subnet_id = local.public_subnet_ids[0]
source_dest_check = false
security_groups = [aws_security_group.nat.id]

tags = {
Name = local.name
}
tags = local.tags
}

resource "aws_eip" "public_ip" {
vpc = true
network_interface = aws_network_interface.nat.id

tags = {
Name = local.name
}
vpc = true
network_interface = aws_network_interface.nat.id
tags = local.tags
}

resource "aws_launch_template" "nat_instance" {
name_prefix = local.name
image_id = data.aws_ami.nat.id
instance_type = local.instance_type
tags = local.tags

network_interfaces {
device_index = 0
Expand All @@ -29,9 +24,6 @@ resource "aws_launch_template" "nat_instance" {

tag_specifications {
resource_type = "instance"

tags = {
Name = local.name
}
tags = local.tags
}
}
5 changes: 1 addition & 4 deletions routes.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
resource "aws_route_table" "nat" {
vpc_id = local.vpc_id

tags = {
Name = local.name
}
tags = local.tags
}

resource "aws_route" "internet" {
Expand Down
1 change: 1 addition & 0 deletions s3_endpoint.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ resource "aws_vpc_endpoint" "s3" {
service_name = "com.amazonaws.${data.aws_region.current.name}.s3"
auto_accept = true
route_table_ids = [aws_route_table.nat.id]
tags = local.tags
}
1 change: 1 addition & 0 deletions security_group.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ resource "aws_security_group" "nat" {
name = "Nat"
description = "Default rules for Nat instance"
vpc_id = local.vpc_id
tags = local.tags
}

resource "aws_security_group_rule" "ingess_http" {
Expand Down
9 changes: 9 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
variable "name" {
default = "NatInstance"
}
variable "tags" {
description = "Tags."
type = map(string)
}
variable "public_subnet_id" {}
variable "instance_type" {
default = "t3a.small"
Expand Down Expand Up @@ -32,4 +36,9 @@ locals {
public_subnet_ids = [var.public_subnet_id]
private_subnet_cidrs = var.private_subnet_cidrs
az = "${data.aws_region.current.name}b"
tags = merge({
Name = local.name
Module = "Nat Instance"
ModuleSource = "https://github.com/jetbrains-infra/terraform-aws-nat-instance/"
}, var.tags)
}

0 comments on commit 6ad9c55

Please sign in to comment.