File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Terraform Validate & Plan
2+
3+ on :
4+ pull_request :
5+ push :
6+ branches :
7+ - main
8+
9+ jobs :
10+ terraform-validate-plan :
11+ name : Terraform Validate & Plan
12+ runs-on : ubuntu-latest
13+
14+ steps :
15+ - name : Checkout Repository
16+ uses : actions/checkout@v4
17+
18+ - name : Setup Terraform
19+ uses : hashicorp/setup-terraform@v3
20+ with :
21+ terraform_version : latest
22+
23+ - name : Find Terraform Directories
24+ id : find-dirs
25+ run : |
26+ echo "directories=$(find env -type f -name 'main.tf' -exec dirname {} \; | sort | uniq | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_ENV
27+
28+ - name : Validate & Plan
29+ run : |
30+ for dir in $(echo $directories | jq -r '.[]'); do
31+ echo "Processing $dir"
32+ terraform -chdir=$dir init
33+ terraform -chdir=$dir validate
34+ terraform -chdir=$dir plan -out=tfplan
35+ done
36+
Original file line number Diff line number Diff line change 1+ resource "aws_eks_cluster" "eks" {
2+ name = var. cluster_name
3+ role_arn = var. cluster_role_arn
4+
5+ vpc_config {
6+ subnet_ids = var. subnet_ids
7+ }
8+
9+ tags = {
10+ Name = var.cluster_name
11+ }
12+ }
13+
Original file line number Diff line number Diff line change 1+ output "cluster_id" {
2+ value = aws_eks_cluster. eks . id
3+ }
4+
5+ output "cluster_endpoint" {
6+ value = aws_eks_cluster. eks . endpoint
7+ }
8+
Original file line number Diff line number Diff line change 1+ variable "region" {}
2+ variable "cluster_name" {}
3+ variable "cluster_role_arn" {}
4+ variable "subnet_ids" { type = list (string ) }
5+
Original file line number Diff line number Diff line change 1+ resource "aws_eks_node_group" "node_group" {
2+ cluster_name = var. cluster_name
3+ node_role_arn = var. node_role_arn
4+ subnet_ids = var. subnet_ids
5+ instance_types = var. instance_types
6+ scaling_config {
7+ desired_size = var. desired_size
8+ max_size = var. max_size
9+ min_size = var. min_size
10+ }
11+ }
12+
Original file line number Diff line number Diff line change 1+ output "node_group_id" {
2+ value = aws_eks_node_group. node_group . id
3+ }
4+
Original file line number Diff line number Diff line change 1+ variable "region" {}
2+ variable "cluster_name" {}
3+ variable "node_role_arn" {}
4+ variable "subnet_ids" { type = list (string ) }
5+ variable "instance_types" { type = list (string ) }
6+ variable "desired_size" {}
7+ variable "max_size" {}
8+ variable "min_size" {}
9+
Original file line number Diff line number Diff line change 1+ resource "aws_vpc" "main" {
2+ cidr_block = var. vpc_cidr
3+
4+ tags = {
5+ Name = var.vpc_name
6+ }
7+ }
8+
9+ resource "aws_subnet" "public" {
10+ count = length (var. public_subnets )
11+
12+ vpc_id = aws_vpc. main . id
13+ cidr_block = var. public_subnets [count . index ]
14+ availability_zone = element (var. azs , count. index )
15+ map_public_ip_on_launch = true
16+
17+ tags = {
18+ Name = " ${ var . vpc_name } -public-${ count . index } "
19+ }
20+ }
21+
22+ resource "aws_subnet" "private" {
23+ count = length (var. private_subnets )
24+
25+ vpc_id = aws_vpc. main . id
26+ cidr_block = var. private_subnets [count . index ]
27+ availability_zone = element (var. azs , count. index )
28+
29+ tags = {
30+ Name = " ${ var . vpc_name } -private-${ count . index } "
31+ }
32+ }
Original file line number Diff line number Diff line change 1+ output "vpc_id" {
2+ value = aws_vpc. main . id
3+ }
4+
5+ output "public_subnets" {
6+ value = aws_subnet. public [* ]. id
7+ }
8+
9+ output "private_subnets" {
10+ value = aws_subnet. private [* ]. id
11+ }
12+
Original file line number Diff line number Diff line change 1+ variable "region" {}
2+ variable "vpc_cidr" {}
3+ variable "vpc_name" {}
4+ variable "public_subnets" { type = list (string ) }
5+ variable "private_subnets" { type = list (string ) }
6+ variable "azs" { type = list (string ) }
You can’t perform that action at this time.
0 commit comments