'Missing attribute for AWS terraform

I have been practicing this terraform tutorial course on YouTube. I have been encountering a syntax error that I've spent hours trying to fix and reformat, but to no avail. Please Forgive me it might be a simple fix, but it hasn't worked out for me. I am receiving an error that I have denoted in the code where the error occurs. I will be very grateful. The error is

The Terraform configuration must be valid before initialization so that Terraform can determine which modules and providers need to be installed.

Error: Missing attribute value
On aws.tf line 39: Expected an attribute value, introduced by an equals sign ("=").

resource "aws_key_pair" "deployer" {
key name   = "deployer-key"
public_key = "ssh-rsa 
}

data "template_file" "user_data" {
template = file("./userdata.yaml")

}

resource "aws_instance" "big_server" {
ami           = "ami-0c92fb55uuuuy6"
instance_type = "t2.micro"
key_name   = "${aws_key_pair.deployer.key_name}"
vpc_security_group_ids = [aws_security_group.sg_big_server.id]
user_data = data.template_file.user_data.rendered
tags = {
  Name = "BigServer"
  }
}

data "aws_vpc" "main" {
id = "vpc-cc0627b6"
}

resource "aws_security_group" "big_sg_server" {
name        = "sg_my_server"
description = "My Security Group"
vpc_id      = vpc-cc0644006

ingress = {
{
 description      = "HTTP"
 from_port        = 80
 to_port          = 80
 protocol         = "tcp"
 cidr_blocks      = ["0.0.0.0/0"]
 ipv6_cidr_blocks = []
 },                           
}

{
  description      = "SSH"
  from_port        = 22
  to_port          = 22
  protocol         = "tcp"
  cidr_blocks      = ["73.128.36.113/32"]
  ipv6_cidr_blocks = []
 }

}
 egress = {
{
 from_port        = 0
 to_port          = 0
 protocol         = "-1"
 cidr_blocks      = ["0.0.0.0/0"]
 ipv6_cidr_blocks = ["::/0"]
 }
}

 tags = {
 Name = "allow_tls"
}
}


Solution 1:[1]

There are many sytax problems. Please run terraform fmt and terraform validate to check your code first.

with a quick check, the first resource has two issues

resource "aws_key_pair" "deployer" {
  key_name   = "deployer-key".   # no space in key name
  public_key = "ssh-rsa"         # need closed quote “
}

There are more waiting you to fix them by yourself

Regarding the error you facing. It is about the way to set up Multiple ingress rules.

Yours is not proper, there are some discussions in stackoverflow already, take a look

Create multiple rules in AWS security Group

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1