concated strings

terraform
Daniel Mikula 2023-05-17 11:54:38 +02:00
parent 24f1d015ea
commit 46e88e057a
1 changed files with 8 additions and 8 deletions

16
ec2.tf
View File

@ -53,7 +53,7 @@ resource "aws_vpc" "k3s_box_vpc" {
cidr_block = "10.0.0.0/16" cidr_block = "10.0.0.0/16"
tags = { tags = {
Name = "k3s-box-vpc" Name = concat(var.instance_name, "-vpc")
} }
} }
@ -63,7 +63,7 @@ resource "aws_subnet" "k3s_box_public_subnet" {
availability_zone = var.availability_zone availability_zone = var.availability_zone
tags = { tags = {
Name = "k3s-box-public-subnet" Name = concat(var.instance_name, "-public-subnet")
} }
} }
@ -73,7 +73,7 @@ resource "aws_subnet" "k3s_box_private_subnet" {
availability_zone = var.availability_zone availability_zone = var.availability_zone
tags = { tags = {
Name = "k3s-box-private-subnet" Name = concat(var.instance_name, "-private-subnet")
} }
} }
@ -81,7 +81,7 @@ resource "aws_internet_gateway" "k3s_box_ig" {
vpc_id = aws_vpc.k3s_box_vpc.id vpc_id = aws_vpc.k3s_box_vpc.id
tags = { tags = {
Name = "k3s-box-internet-gateway" Name = concat(var.instance_name, "-internet-gateway")
} }
} }
@ -99,7 +99,7 @@ resource "aws_route_table" "k3s_box_rt" {
} }
tags = { tags = {
Name = "k3s-box-route-table" Name = concat(var.instance_name, "-route-table")
} }
} }
@ -150,7 +150,7 @@ resource "aws_security_group" "k3s_box_sg" {
} }
tags = { tags = {
Name = "k3s-box-sg" Name = concat(var.instance_name, "-sg")
} }
} }
@ -161,14 +161,14 @@ resource "tls_private_key" "rsa" {
} }
resource "aws_key_pair" "k3s_box_kp" { resource "aws_key_pair" "k3s_box_kp" {
key_name = "k3s-box-key" key_name = concat(var.instance_name, "-key")
public_key = tls_private_key.rsa.public_key_openssh public_key = tls_private_key.rsa.public_key_openssh
} }
# save key pair to machine # save key pair to machine
resource "local_file" "k3s_box_private_key" { resource "local_file" "k3s_box_private_key" {
content = tls_private_key.rsa.private_key_pem content = tls_private_key.rsa.private_key_pem
filename = "k3s_box_private_key" filename = concat(var.instance_name, "-private_key.pem")
file_permission = 0400 file_permission = 0400
} }