This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#provider | |
provider "aws" { | |
profile = "root" | |
region = "ap-south-1" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vpc | |
resource "aws_vpc" "tf_vpc" { | |
cidr_block = "192.168.0.0/16" | |
enable_dns_support = true | |
enable_dns_hostnames = true | |
tags= { | |
Name = "tf-vpc" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# public subnet | |
resource "aws_subnet" "pub_subnet1" { | |
vpc_id = aws_vpc.tf_vpc.id | |
availability_zone = "ap-south-1a" | |
cidr_block = "192.168.1.0/24" | |
map_public_ip_on_launch = true | |
tags= { | |
Name = "pub-subnet1" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_security_group" "tf_sql_sg" { | |
depends_on = [ | |
aws_route_table_association.tf_ng_assoc | |
] | |
name = "tf_sql_sg" | |
description = "mysql inbound" | |
vpc_id = aws_vpc.tf_vpc.id | |
ingress { | |
description = "mysql" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Internet Gateway | |
resource "aws_internet_gateway" "tf_ig" { | |
vpc_id = aws_vpc.tf_vpc.id | |
tags = { | |
Name = "tf-ig" | |
} | |
} | |
# IGW Route Table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# EIP | |
resource "aws_eip" "tf-eip" { | |
tags = { | |
"Name" = "vpc-eip" | |
} | |
} | |
# NAT Gateway | |
resource "aws_nat_gateway" "tf_ngw" { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_instance" "wordpress" { | |
ami = "ami-0732b62d310b80e97" | |
instance_type = "t2.micro" | |
subnet_id = aws_subnet.pub_subnet1.id | |
security_groups = [aws_security_group.tf_wp_sg.id] | |
key_name = "key1" | |
tags = { | |
Name = "wordpress" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_instance" "wordpress" { | |
ami = "ami-0732b62d310b80e97" | |
instance_type = "t2.micro" | |
subnet_id = aws_subnet.pub_subnet1.id | |
security_groups = [aws_security_group.tf_wp_sg.id] | |
key_name = "key1" | |
tags = { | |
Name = "wordpress" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_instance" "mysql" { | |
depends_on = [ | |
aws_instance.wordpress | |
] | |
ami = "ami-0732b62d310b80e97" | |
instance_type = "t2.micro" | |
subnet_id = aws_subnet.pvt_subnet2.id | |
security_groups = [aws_security_group.tf_sql_sg.id] | |
key_name = "key1" | |
user_data = <<END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# security group for wordpress | |
resource "aws_security_group" "tf_wp_sg" { | |
name = "tf_wp_sg" | |
description = "wordpress inbound" | |
vpc_id = aws_vpc.tf_vpc.id | |
ingress { | |
description = "http" | |
from_port = 80 | |
to_port = 80 |
OlderNewer