Skip to content

Commit

Permalink
Tag "Name" added to vpc, subnet and e2 resources.
Browse files Browse the repository at this point in the history
  • Loading branch information
sradzhabov committed Sep 25, 2024
1 parent 8bb391f commit 39f638b
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 41 deletions.
3 changes: 3 additions & 0 deletions aws/terraform/compute/ec2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ resource "aws_instance" "ec2_server" {
encrypted = false
delete_on_termination = true
}
tags = {
Name = var.ec2_name
}
}
4 changes: 2 additions & 2 deletions aws/terraform/compute/ec2/provider.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
source = "hashicorp/aws"
version = "5.68.0"
}
}
}

provider "aws" {
region = var.aws_region
region = var.aws_region
}
25 changes: 15 additions & 10 deletions aws/terraform/compute/ec2/variables.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
variable "ec2_size" {
type = string
description = "Provide a name of AWS EC2 instance size such as t2.micro, etc."
default = "t2.micro"
type = string
description = "Provide a name of AWS EC2 instance size such as t2.micro, etc."
default = "t2.micro"
}

#variable "ec2_sshpub_key" {
Expand All @@ -10,17 +10,22 @@ variable "ec2_size" {
#}

variable "ec2_storage_size" {
type = number
description = "Provide size of storage volume in Gb"
default = 8
type = number
description = "Provide size of storage volume in Gb"
default = 8
}

variable "ec2_subnet_id" {
type = string
description = "Provide the subnet ID where the EC2 will be placed"
type = string
description = "Provide the subnet ID where the EC2 will be placed"
}

variable "aws_region" {
type = string
default = "eu-central-1"
type = string
default = "eu-central-1"
}

variable "ec2_name" {
type = string
description = "The name set as value for the tag Name"
}
9 changes: 6 additions & 3 deletions aws/terraform/networking-contentdelivery/subnet/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
resource "aws_subnet" "subnet" {
vpc_id = var.vpc_id
cidr_block = var.cidr_block
availability_zone = "${var.aws_region}${var.aws_az}"
vpc_id = var.vpc_id
cidr_block = var.cidr_block
availability_zone = "${var.aws_region}${var.aws_az}"
map_public_ip_on_launch = var.public_ip
tags = {
Name = var.subnet_name
}
}
4 changes: 2 additions & 2 deletions aws/terraform/networking-contentdelivery/subnet/output.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
output "subnet_id" {
description = "ID of the subnet"
value = aws_subnet.subnet.id
description = "ID of the subnet"
value = aws_subnet.subnet.id
}
4 changes: 2 additions & 2 deletions aws/terraform/networking-contentdelivery/subnet/provider.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
source = "hashicorp/aws"
version = "5.68.0"
}
}
}

provider "aws" {
region = var.aws_region
region = var.aws_region
}
29 changes: 17 additions & 12 deletions aws/terraform/networking-contentdelivery/subnet/variables.tf
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
variable "vpc_id" {
type = string
description = "Id of the VPC where the subnet has to be provisioned"
type = string
description = "Id of the VPC where the subnet has to be provisioned"
}

variable "cidr_block" {
type = string
description = "IP range for a subnet"
type = string
description = "IP range for a subnet"
}

variable "aws_region" {
type = string
description = "The region where the subnet has to be created"
default = "eu-central-1"
type = string
description = "The region where the subnet has to be created"
default = "eu-central-1"
}

variable "aws_az" {
type = string
description = "Single char ID of an availability zone i.e. 'a' for eu-central-1a"
type = string
description = "Single char ID of an availability zone i.e. 'a' for eu-central-1a"
}

variable "public_ip" {
type = bool
default = false
description = "Whether the subnet should provision public IP or not for the deployed instances"
type = bool
default = false
description = "Whether the subnet should provision public IP or not for the deployed instances"
}

variable "subnet_name" {
type = string
description = "The name set as value for the tag Name"
}
7 changes: 5 additions & 2 deletions aws/terraform/networking-contentdelivery/vpc/main.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
resource "aws_vpc" "vpc" {
provider = aws
cidr_block = var.cidr_block
provider = aws
cidr_block = var.cidr_block
tags = {
Name = var.vpc_name
}
}
4 changes: 2 additions & 2 deletions aws/terraform/networking-contentdelivery/vpc/output.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
output "vpc_id" {
description = "ID of the VPC"
value = aws_vpc.vpc.id
description = "ID of the VPC"
value = aws_vpc.vpc.id
}
4 changes: 2 additions & 2 deletions aws/terraform/networking-contentdelivery/vpc/provider.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
source = "hashicorp/aws"
version = "5.68.0"
}
}
}

provider "aws" {
region = var.aws_region
region = var.aws_region
}
13 changes: 9 additions & 4 deletions aws/terraform/networking-contentdelivery/vpc/variables.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
variable "cidr_block" {
type = string
description = "IP range for a new VPC"
type = string
description = "IP range for a new VPC"
}

variable "aws_region" {
type = string
default = "eu-central-1"
type = string
default = "eu-central-1"
}

variable "vpc_name" {
type = string
description = "The name set as value for the tag Name"
}

0 comments on commit 39f638b

Please sign in to comment.