Skip to content

Commit 5e99802

Browse files
Add Readme and output.tf
1 parent 9b5046c commit 5e99802

File tree

5 files changed

+127
-10
lines changed

5 files changed

+127
-10
lines changed

.github/workflows/ci-terraform.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ jobs:
2323
- name: Setup Terraform
2424
uses: hashicorp/setup-terraform@v1
2525

26-
# Setup pre-commit hooks for terraform validation.
27-
- name: pre-commit
28-
uses: pre-commit/[email protected]
29-
with:
30-
# options to pass to pre-commit run
31-
extra_args: flake8 --all-files
32-
3326
# Checks that all Terraform configuration files adhere to a canonical format
3427
- name: Terraform Format
3528
run: terraform fmt -check

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Local .terraform directories
2+
*.terraform
23
**/.terraform/*
34

45
# .tfstate files

README.md

Lines changed: 122 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,122 @@
1-
# AWS VPC Module
2-
Terraform AWS VPC Module
1+
# Hashicorp Terraform AWS VPC Module
2+
Terraform AWS VPC Module by Source4Learn(An Opensource Community to learn and share knowledge)
3+
![s4l](s4l.png "Source4Learn")
4+
5+
## AWS VPC Module Usage
6+
This AWS VPC Module will creates 1/2/3 tier resources as per user inputs:
7+
- Subnets ["Public", "Private", "Storage"]
8+
- Route Tables ["Public", "Private", "Storage"]
9+
- Security Gruoups
10+
- Internet Gateway
11+
- NAT Gateway
12+
- Elatic IPs
13+
- Network ACLs
14+
- VPC Endpoints
15+
16+
Example: Single tier AWS VPC architecture having only Public Subnet with required resources.
17+
18+
```terraform
19+
resource "aws_vpc" "vpc" {
20+
cidr_block = "10.0.0.0/20"
21+
22+
tags = {
23+
Name = "my-vpc"
24+
Environment = "my-environment"
25+
}
26+
}
27+
28+
# AWS VPC Internet Gateway
29+
resource "aws_internet_gateway" "igw" {
30+
vpc_id = aws_vpc.vpc.id
31+
32+
tags = {
33+
Name = "my-igw"
34+
Environment = "my-environment"
35+
}
36+
}
37+
38+
# AWS VPC Subnets Module - Public Subnet
39+
module "public_subnet" {
40+
source = "./modules/subnets"
41+
vpc_id = aws_vpc.vpc.id
42+
aws_internet_gateway_id = aws_internet_gateway.igw.id
43+
cidr = "10.0.0.0/20"
44+
subnet_bits = "4"
45+
prefix = "my-subnet"
46+
environment = "my-environment"
47+
subnet_type = ["public"]
48+
}
49+
```
50+
51+
In adadition to above example, users can provision 2/3 tier AWS VPC architecture.
52+
53+
```terraform
54+
module "nat_gateway" {
55+
source = "./modules/nat-gateways"
56+
prefix = "my-nat-gateway"
57+
environment = "my-environment"
58+
public_subnet_ids = module.public_subnet.public_subnet_ids
59+
}
60+
61+
module "private_subnet" {
62+
source = "./modules/subnets"
63+
vpc_id = aws_vpc.vpc.id
64+
aws_nat_gateway_id = module.nat_gateway.nat_gateway_ids
65+
cidr = "10.0.0.0/20"
66+
subnet_bits = "4"
67+
prefix = "my-subnet"
68+
environment = "my-environment"
69+
subnet_type = ["private", "storage"]
70+
}
71+
72+
module "security_group" {
73+
source = "./modules/security-groups"
74+
vpc_id = aws_vpc.vpc.id
75+
prefix = "my-security-group"
76+
environment = "my-environment"
77+
}
78+
```
79+
80+
## Requirements
81+
82+
| Name | Version |
83+
|------|---------|
84+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.0 |
85+
86+
## Providers
87+
88+
| Name | Version |
89+
|------|---------|
90+
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
91+
92+
## Modules
93+
94+
| Name | Source | Version |
95+
|------|--------|---------|
96+
| <a name="module_nat_gateway"></a> [nat\_gateway](#module\_nat\_gateway) | ./modules/nat-gateways | |
97+
| <a name="module_private_subnet"></a> [private\_subnet](#module\_private\_subnet) | ./modules/subnets | |
98+
| <a name="module_public_subnet"></a> [public\_subnet](#module\_public\_subnet) | ./modules/subnets | |
99+
| <a name="module_security_group"></a> [security\_group](#module\_security\_group) | ./modules/security-groups | |
100+
101+
## Resources
102+
103+
| Name | Type |
104+
|------|------|
105+
| [aws_internet_gateway.igw](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/internet_gateway) | resource |
106+
| [aws_vpc.vpc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc) | resource |
107+
108+
## Inputs
109+
110+
| Name | Description | Type | Default | Required |
111+
|------|-------------|------|---------|:--------:|
112+
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | AWS Default Region | `string` | n/a | yes |
113+
| <a name="input_cidr"></a> [cidr](#input\_cidr) | CIDR block value to define the size of the AWS VPC | `string` | `"10.0.0.0/20"` | no |
114+
| <a name="input_environment"></a> [environment](#input\_environment) | To apply generic environment to AWS VPC Resources | `string` | n/a | yes |
115+
| <a name="input_prefix"></a> [prefix](#input\_prefix) | To apply generic naming to AWS VPC Resources | `string` | n/a | yes |
116+
| <a name="input_subnet_bits"></a> [subnet\_bits](#input\_subnet\_bits) | Subnet bits for cidrsubnet interpolation or Size we need to define for the Subnet (cidr of VPC + Subnet bits) | `string` | n/a | yes |
117+
118+
## Outputs
119+
120+
| Name | Description |
121+
|------|-------------|
122+
| <a name="output_vpc_id"></a> [vpc\_id](#output\_vpc\_id) | Terraform Output |

output.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
# Terraform Output
1+
# Terraform Output
2+
output "vpc_id" {
3+
value = aws_vpc.vpc.id
4+
}

s4l.png

6.45 KB
Loading

0 commit comments

Comments
 (0)