Skip to content

Conversation

grok-rv
Copy link
Owner

@grok-rv grok-rv commented Apr 10, 2020

No description provided.

@github-actions
Copy link

terraform fmt Failed

./a-loadbalancer/main.tf
 #-----------------------module/a-loadbalancer/main.tf-------------------
 #----------create an application load balancer---------------------
 resource "aws_lb" "alb-frontend" {
-  name = "aws-alb"
-  internal = false
-  security_groups = [ var.alb-sg ]
-  subnets = var.pub-subnet 
+  name                             = "aws-alb"
+  internal                         = false
+  security_groups                  = [var.alb-sg]
+  subnets                          = var.pub-subnet
   enable_cross_zone_load_balancing = true
-  ip_address_type = var.ip_type
+  ip_address_type                  = var.ip_type
   tags = {
     Name = "alb-frontend"
   }
     interval            = "30"
   }
 
- }
+}
 
 #--------------create a http listenr for load balancer----------------------
 resource "aws_lb_listener" "alb-frontend" {
   load_balancer_arn = "${aws_lb.alb-frontend.arn}"
-  port = 80
-  protocol = "HTTP"
+  port              = 80
+  protocol          = "HTTP"
   default_action {
-    type = "forward"
+    type             = "forward"
     target_group_arn = "${aws_lb_target_group.alb-frontend.arn}"
   }
-  
+
 }
 
 #-----------attach ec2 instances to the the application load balancer---------------------------------
 resource "aws_lb_target_group_attachment" "alb-frontend" {
-  count = 2
+  count            = 2
   target_group_arn = "${aws_lb_target_group.alb-frontend.arn}"
-  target_id =  "${element(split(", ", join(", ", var.target-id)), count.index)}"
-  port = 80
+  target_id        = "${element(split(", ", join(", ", var.target-id)), count.index)}"
+  port             = 80
 }
./a-loadbalancer/variables.tf
 
 variable "ip_type" {
   default = "ipv4"
-  type = "string"
+  type    = "string"
 }
 
 variable "alb-sg" {
./instance/main.tf
 
 data "aws_ami" "ami" {
   most_recent = true
-  owners = ["amazon"]
-  filter  {
-    name = "name"
+  owners      = ["amazon"]
+  filter {
+    name   = "name"
     values = ["amzn-ami-hvm*-x86_64-gp2"]
   }
 
./main.tf
 provider "aws" {
 }
 module "storage" {
-  source = "./storage"
+  source      = "./storage"
   projectname = var.projectname
 }
 
 module "network" {
-  source = "./networking"
-  cidrblock = var.cidrblock
-  accessIp = var.accessIp
-  cidr_public = var.cidr_public 
+  source       = "./networking"
+  cidrblock    = var.cidrblock
+  accessIp     = var.accessIp
+  cidr_public  = var.cidr_public
   cidr_private = var.cidr_private
 }
 
 module "instance" {
-  source = "./instance"
-  keyname = var.keyname
-  publickeypath = var.publickeypath
-  bastion-sg = "${module.network.bastion-sg}"
-  ec2-sg = "${module.network.ec2-sg}"
-  instancetype = var.instancetype
-  counts = var.counts
-  private-subnets = "${module.network.private_subnet}"   
-  public-subnet = "${module.network.public_Subnet}"
+  source          = "./instance"
+  keyname         = var.keyname
+  publickeypath   = var.publickeypath
+  bastion-sg      = "${module.network.bastion-sg}"
+  ec2-sg          = "${module.network.ec2-sg}"
+  instancetype    = var.instancetype
+  counts          = var.counts
+  private-subnets = "${module.network.private_subnet}"
+  public-subnet   = "${module.network.public_Subnet}"
 }
 module "loadbalancer" {
-  source = "./a-loadbalancer"
-  alb-sg = "${module.network.alb-sg}"
+  source     = "./a-loadbalancer"
+  alb-sg     = "${module.network.alb-sg}"
   pub-subnet = "${module.network.public_Subnet}"
-  vpc-id = "${module.network.vpc-id}"
-  target-id = [ "${module.instance.ec2instance_id}" ]
+  vpc-id     = "${module.network.vpc-id}"
+  target-id  = ["${module.instance.ec2instance_id}"]
 }
./networking/main.tf
 }
 #---------------create a vpc--------------------------
 resource "aws_vpc" "tfs_vpc" {
-  cidr_block = var.cidrblock
-  enable_dns_support = true
+  cidr_block           = var.cidrblock
+  enable_dns_support   = true
   enable_dns_hostnames = true
   tags = {
     Name = "tf-vpc"
 
 #---------------------public and private subnet resources---------------------
 resource "aws_subnet" "tfs_public-subnet" {
-  count = 2
-  cidr_block = var.cidr_public[count.index]
-  vpc_id = "${aws_vpc.tfs_vpc.id}"
-  availability_zone  = "${data.aws_availability_zones.available_az.names[count.index]}"
+  count             = 2
+  cidr_block        = var.cidr_public[count.index]
+  vpc_id            = "${aws_vpc.tfs_vpc.id}"
+  availability_zone = "${data.aws_availability_zones.available_az.names[count.index]}"
   tags = {
     Name = "tfs-public-subnets-${count.index + 1}"
   }
 }
 #--------------public and private route tables associations to subnets------------------
 resource "aws_route_table_association" "tfs-public-rta" {
-  count = length(aws_subnet.tfs_public-subnet)
-  subnet_id = "${aws_subnet.tfs_public-subnet.*.id[count.index]}"
+  count          = length(aws_subnet.tfs_public-subnet)
+  subnet_id      = "${aws_subnet.tfs_public-subnet.*.id[count.index]}"
   route_table_id = "${aws_route_table.public-route.id}"
 }
 
 resource "aws_route_table_association" "tfs-private-rta" {
-  count = length(aws_subnet.tfs_private-subnet)
-  subnet_id = "${aws_subnet.tfs_private-subnet.*.id[count.index]}"
+  count          = length(aws_subnet.tfs_private-subnet)
+  subnet_id      = "${aws_subnet.tfs_private-subnet.*.id[count.index]}"
   route_table_id = "${aws_default_route_table.private-route.id}"
 }
 
 #-------allocate an elastic ip------------
 
 resource "aws_eip" "nat-eip" {
-  vpc = true
+  vpc        = true
   depends_on = ["aws_internet_gateway.tfs_ig"]
 }
 
 
 #-------------------------bastion host security group------------------------------
 resource "aws_security_group" "bastion-sg" {
-  name = "bastion-sg"
+  name   = "bastion-sg"
   vpc_id = "${aws_vpc.tfs_vpc.id}"
-  
+
   ingress {
-    from_port = 22
-    to_port = 22 
-    protocol = "tcp"
-    cidr_blocks = [ var.accessIp ]
+    from_port   = 22
+    to_port     = 22
+    protocol    = "tcp"
+    cidr_blocks = [var.accessIp]
   }
- 
+
   egress {
-    from_port = 0
-    to_port = 0
-    protocol = "-1"
+    from_port   = 0
+    to_port     = 0
+    protocol    = "-1"
     cidr_blocks = ["0.0.0.0/0"]
   }
 }
 
 #----------------application load balancer security group-----------------------
 resource "aws_security_group" "alb-sg" {
-  name = "alb-sg"
+  name   = "alb-sg"
   vpc_id = "${aws_vpc.tfs_vpc.id}"
   ingress {
-    from_port = 80
-    to_port = 80
-    protocol = "tcp"
+    from_port   = 80
+    to_port     = 80
+    protocol    = "tcp"
     cidr_blocks = ["0.0.0.0/0"]
   }
   egress {
-    from_port = 0
-    to_port = 0
-    protocol = "-1"
+    from_port   = 0
+    to_port     = 0
+    protocol    = "-1"
     cidr_blocks = ["0.0.0.0/0"]
   }
 
 
 
 
-    
+
./networking/outputs.tf
   value = "${aws_subnet.tfs_private-subnet.*.id}"
 }
 output "bastion-sg" {
- value = "${aws_security_group.bastion-sg.id}"
+  value = "${aws_security_group.bastion-sg.id}"
 }
 output "ec2-sg" {
   value = "${aws_security_group.ec2-sg.id}"
./storage/main.tf
 }
 #----------------------create a s3 bucket----------------------------------
 resource "aws_s3_bucket" "s3_bucket" {
-  bucket = "${var.projectname}-${random_id.bucket_id.dec}"
-  acl = "private"
+  bucket        = "${var.projectname}-${random_id.bucket_id.dec}"
+  acl           = "private"
   force_destroy = true
   tags = {
     Name = "tfs_bucket"
./storage/outputs.tf
 output "s3_bucket" {
-  value ="s3 bucket id is ${aws_s3_bucket.s3_bucket.id}"
+  value = "s3 bucket id is ${aws_s3_bucket.s3_bucket.id}"
 }
./variables.tf
 }
 
 variable "cidr_public" {
-  type = list
+  type        = list
   description = "this is the cidr block for public subnet list: example [\"10.123.1.0/24\", \"10.123.2.0/24\"]"
 }
 
 variable "cidr_private" {
-  type = list
+  type        = list
   description = "this is the cidr block for private subnet list: example [\"10.123.3.0/24\", \"10.123.4.0/24\"]"
 }
 variable "counts" {

Workflow: Terraform GitHub Actions, Action: hashicorpterraform-github-actions1, Working Directory: ., Workspace: default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants