Skip to content

Instantly share code, notes, and snippets.

View 100daysofdevops's full-sized avatar
🎯
Focusing

100daysofdevops

🎯
Focusing
View GitHub Profile
#!/bin/bash
mkfs.ext4 /dev/xvdh
mount /dev/xvdh /mnt
echo /dev/xvdh /mnt defaults,nofail 0 2 >> /etc/fstab
vpc_cidr = "10.0.0.0/16"
public_cidrs
= [
"10.0.1.0/24",
"10.0.2.0/24"
]
private_cidrs
= [
"10.0.3.0/24",
"10.0.4.0/24"
variable "vpc_cidr" {}
variable "public_cidrs" {
type = "list"
}
variable "private_cidrs" {
type = "list"
}
module "vpc_networking" {
source = "./vpc_networking"
vpc_cidr = "${var.vpc_cidr}"
public_cidrs = "${var.public_cidrs}"
private_cidrs = "${var.private_cidrs}"
}
variable "vpc_cidr" {
default = "10.0.0.0/16"
}
variable "public_cidrs" {
type = "list"
default = ["10.0.1.0/24","10.0.2.0/24"]
}
variable "private_cidrs" {
$ terraform apply
data.aws_availability_zones.available: Refreshing state...
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
+ module.vpc_networking.aws_default_route_table.private_route
$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
data.aws_availability_zones.available: Refreshing state...
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
$ terraform init
Initializing modules...
- module.vpc_networking
Getting source "./networking"
# Ingress Security Port 22
resource "aws_security_group_rule" "ssh_inbound_access" {
from_port = 22
protocol = "tcp"
security_group_id = "${aws_security_group.test_sg.id}"
to_port = 22
type = "ingress"
cidr_blocks = ["0.0.0.0/0"]
}
# Associate Public Subnet with Public Route Table
resource "aws_route_table_association" "public_subnet_assoc" {
count = "${aws_subnet.public_subnet.count}"
route_table_id = "${aws_route_table.public_route.id}"
subnet_id = "${aws_subnet.public_subnet.*.id[count.index]}"
depends_on = ["aws_route_table.public_route", "aws_subnet.public_subnet"]
}
# Associate Private Subnet with Private Route Table
resource "aws_route_table_association" "private_subnet_assoc" {