Skip to content

Commit d0cb2f4

Browse files
committed
updated terraform varaiables with AWS resources for cloud migration
1 parent 972a816 commit d0cb2f4

1 file changed

Lines changed: 41 additions & 30 deletions

File tree

terraform/variables.tf

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,58 @@
11
variable "aws_region" {
2-
description = "AWS region"
3-
type = string
4-
default = "us-east-1"
2+
default = "us-east-1"
53
}
64

75
variable "project_name" {
8-
description = "Project name for resource naming"
9-
type = string
10-
default = "api-server"
6+
default = "two-az-network"
7+
}
8+
9+
variable "vpc_cidr" {
10+
default = "10.0.0.0/16"
11+
}
12+
13+
variable "azs" {
14+
type = map(object({
15+
public = string
16+
app = string
17+
db = string
18+
dependent = string
19+
observability = string
20+
}))
21+
default = {
22+
"us-east-1a" = {
23+
public = "10.0.0.0/24"
24+
app = "10.0.1.0/24"
25+
db = "10.0.2.0/24"
26+
dependent = "10.0.3.0/24"
27+
observability = "10.0.4.0/24"
28+
}
29+
"us-east-1b" = {
30+
public = "10.0.10.0/24"
31+
app = "10.0.11.0/24"
32+
db = "10.0.12.0/24"
33+
dependent = "10.0.13.0/24"
34+
observability = "10.0.14.0/24"
35+
}
36+
}
1137
}
1238

1339
variable "ami_id" {
14-
description = "Ubuntu AMI ID"
15-
type = string
16-
default = "ami-020cba7c55df1f615"
40+
default = "ami-020cba7c55df1f615"
1741
}
1842

1943
variable "instance_type" {
20-
description = "EC2 instance type"
21-
type = string
22-
default = "t3.xlarge"
44+
default = "t3.micro"
2345
}
2446

2547
variable "key_name" {
26-
description = "Key pair name"
27-
type = string
28-
default = "api-server"
48+
description = "EC2 key pair name"
2949
}
3050

31-
variable "vpc_cidr" {
32-
description = "VPC CIDR block"
33-
type = string
34-
default = "10.0.0.0/16"
35-
}
51+
variable "my_ip" {
52+
description = "Your public IP for SSH access"
3653

37-
variable "public_subnet_cidr" {
38-
description = "Public subnet CIDR block"
39-
type = string
40-
default = "10.0.1.0/24"
54+
validation {
55+
condition = can(regex("^([0-9]{1,3}\\.){3}[0-9]{1,3}/32$", var.my_ip))
56+
error_message = "my_ip must be a valid /32 CIDR, e.g., 203.0.113.25/32"
57+
}
4158
}
42-
43-
variable "availability_zone" {
44-
description = "Availability zone"
45-
type = string
46-
default = "us-east-1a"
47-
}

0 commit comments

Comments
 (0)