Browse Source

refacto vpc

master
art.dambrine 4 years ago
parent
commit
94364bcfb7
  1. 27
      main.tf
  2. 2
      variables.tf

27
main.tf

@ -118,7 +118,7 @@ resource "aws_security_group" "allow_all_trafic_from_vpc" {
vpc_id = aws_vpc.main.id
ingress {
description = "HTTP from VPC"
description = "All from VPC"
from_port = 0
to_port = 0
protocol = "-1"
@ -182,7 +182,7 @@ resource "aws_route_table" "public" {
vpc_id = aws_vpc.main.id
tags = {
Name = "Public route table"
Name = "${var.vpc_name}-public"
}
}
@ -203,7 +203,7 @@ resource "aws_route_table" "private" {
vpc_id = aws_vpc.main.id
tags = {
Name = "Private route table - subnet - ${each.key}"
Name = "${var.vpc_name}-private-${var.aws_region}${each.key}"
}
}
@ -231,3 +231,24 @@ resource "aws_route_table_association" "association_private_nat" {
route_table_id = aws_route_table.private[each.key].id
}
# Deploy one Ubuntu to private subnet 1a
# resource "aws_key_pair" "key_nat" {
# key_name = "my-key-nat-12345"
# public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7IKentO/3FHXk1T2DTudVB6G/FxN2ziGT1UcOiTGzUu9JyZmZrskQKzyFfMvsiSkOio8tT9tHSj1x148nWX8qtu/NM26uVu2DuOg2oN60Y6HSUppeEwtnxH9zYH2WAU4Y45Y28YpLDz9/CC+O+ulBZP2JHHfYG4seX3Zk7+kLdPFLW6HwhMBn1WydDjT/U1x6aHSIIE/JEq9Kj8ni3GKG/JCghBLXDTrg4zg8JhqnY2qFky/ys1OUcusP0CPOHgiXO4OLaYGhZYX0FLYlWZqpazj/A/EBgXgH4owqMtI0Ro4r5hL10VcpUee/3I0Hba1E75Es6wk474wyw7Rj0bql ec2-user@ip-172-22-252-73"
# }
# resource "aws_instance" "web" {
# ami = "ami-0144fa93c0eb299d2"
# instance_type = "t2.micro"
# subnet_id = aws_subnet.private["a"].id
# key_name = "my-key-nat-12345"
# vpc_security_group_ids = [aws_security_group.allow_ssh_to_nat.id, aws_security_group.allow_all_trafic_from_vpc.id]
# tags = {
# Name = "test private"
# }
# }

2
variables.tf

@ -5,7 +5,7 @@ variable "aws_region" {
variable "vpc_name" {
type = string
default = "my-could"
default = "mycould"
description = "VPC name"
}

Loading…
Cancel
Save