commit
1b48e88872
13 changed files with 137 additions and 0 deletions
@ -0,0 +1,22 @@ |
|||
|
|||
# Created by https://www.gitignore.io/api/terraform |
|||
|
|||
### Terraform ### |
|||
# Local .terraform directories |
|||
**/.terraform/* |
|||
|
|||
# .tfstate files |
|||
*.tfstate |
|||
*.tfstate.* |
|||
|
|||
# Crash log files |
|||
crash.log |
|||
|
|||
# Ignore any .tfvars files that are generated automatically for each Terraform run. Most |
|||
# .tfvars files are managed as part of configuration and so should be included in |
|||
# version control. |
|||
# |
|||
*.tfvars |
|||
|
|||
|
|||
# End of https://www.gitignore.io/api/terraform |
@ -0,0 +1,10 @@ |
|||
repos: |
|||
- repo: git://github.com/antonbabenko/pre-commit-terraform |
|||
sha: v1.39.0 |
|||
hooks: |
|||
- id: terraform_fmt |
|||
|
|||
- repo: git://github.com/pre-commit/pre-commit-hooks |
|||
sha: v3.2.0 |
|||
hooks: |
|||
- id: check-merge-conflict |
@ -0,0 +1,87 @@ |
|||
# Terraform AWS VPC |
|||
|
|||
## :package: Install Terraform |
|||
|
|||
Install Terraform by following the [documentation](https://www.terraform.io/downloads.html) |
|||
|
|||
Make sure `terraform` is working properly |
|||
|
|||
```hcl |
|||
$ terraform |
|||
Usage: terraform [--version] [--help] <command> [args] |
|||
|
|||
The available commands for execution are listed below. |
|||
The most common, useful commands are shown first, followed by |
|||
less common or more advanced commands. If you're just getting |
|||
started with Terraform, stick with the common commands. For the |
|||
other commands, please read the help and docs before usage. |
|||
|
|||
Common commands: |
|||
apply Builds or changes infrastructure |
|||
console Interactive console for Terraform interpolations |
|||
# ... |
|||
``` |
|||
|
|||
*Based on [standard module structure](https://www.terraform.io/docs/modules/create.html#standard-module-structure) guidelines* |
|||
|
|||
## :triangular_ruler: Naming Convention |
|||
|
|||
Common variables referenced in naming standards |
|||
|
|||
| Variable | RegExp | Example | |
|||
|:----------------------|:--------------------------------|:------------------------------------------------------------| |
|||
| `<availability_zone>` | `[a-z]{2}-[a-z]{1,}-[1-2][a-f]` | `us-east-1a`, `us-west-2c`, `eu-west-1a`, `ap-northeast-1c` | |
|||
|
|||
--- |
|||
|
|||
## AWS - Resource Naming Standards |
|||
|
|||
| AWS Resource | Resource Naming | Comment | Example | |
|||
|:-----------------|:-----------------------------------------|:--------|:---------------------------------| |
|||
| VPC | `<vpc_name>-vpc` | | `mycloud-vpc` | |
|||
| Subnets | `<vpc_name>-private-<availability_zone>` | | `mycloud-private-us-east-1b` | |
|||
| | `<vpc_name>-public-<availability_zone>` | | `mycloud-public-us-east-1b` | |
|||
| Route Tables | `<vpc_name>-private-<availability_zone>` | | `mycloud-private-us-east-1b` | |
|||
| | `<vpc_name>-public` | | `mycloud-public` | |
|||
| Internet Gateway | `<vpc_name>-igw` | | `mycloud-igw` | |
|||
| Nat Gateway | `<vpc_name>-nat-<availability_zone>` | | `mycloud-nat-us-east-1b` | |
|||
|
|||
|
|||
## 1. Create a `VPC` |
|||
|
|||
The really first stage for bootstrapping an AWS account is to create a `VPC` |
|||
|
|||
* [aws_vpc](https://www.terraform.io/docs/providers/aws/r/vpc.html) |
|||
|
|||
 |
|||
|
|||
## 2. Create `public` and `private` Subnets |
|||
|
|||
Then create `public` and `private` subnets in each `AZs` (`us-east-1a`, `us-east-1b`, `us-east-1c`) |
|||
|
|||
* [aws_subnet](https://www.terraform.io/docs/providers/aws/r/subnet.html) |
|||
|
|||
 |
|||
|
|||
## 3. Create `internet` and `nat` Gateways |
|||
|
|||
Create one `internet gateway` so that the `VPC` can communicate with the outisde world. For instances located in `private` subnets, we will need `NAT` instances to be setup in each `availability zones` |
|||
|
|||
* [aws_internet_gateway](https://www.terraform.io/docs/providers/aws/r/internet_gateway.html) |
|||
* [aws_ami](https://www.terraform.io/docs/providers/aws/d/ami.html) |
|||
* [aws_key_pair](https://www.terraform.io/docs/providers/aws/r/key_pair.html) |
|||
* [aws_instance](https://www.terraform.io/docs/providers/aws/r/instance.html) |
|||
* [aws_eip](https://www.terraform.io/docs/providers/aws/r/eip.html) |
|||
* [aws_eip_association](https://www.terraform.io/docs/providers/aws/r/eip_association.html) |
|||
|
|||
 |
|||
|
|||
## 4. Create `route tables` and `routes` |
|||
|
|||
Finaly, link the infrastructure together by creating `route tables` and `routes` so that servers from `public` and `private` subnets can send their traffic to the respective gateway, either the `internet gateway` or the `NAT` ones. |
|||
|
|||
* [aws_route_table](https://www.terraform.io/docs/providers/aws/r/route_table.html) |
|||
* [aws_route](https://www.terraform.io/docs/providers/aws/r/route.html) |
|||
* [aws_route_table_association](https://www.terraform.io/docs/providers/aws/r/route_table_association.html) |
|||
|
|||
 |
@ -0,0 +1,4 @@ |
|||
# TP Terraform - AWS |
|||
|
|||
https://infrastructure.aws |
|||
|
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 86 KiB |
After Width: | Height: | Size: 119 KiB |
@ -0,0 +1,6 @@ |
|||
### Module Main |
|||
|
|||
provider "aws" { |
|||
region = var.aws_region |
|||
} |
|||
|
@ -0,0 +1,4 @@ |
|||
variable "aws_region" { |
|||
type = string |
|||
default = "us-east-1" |
|||
} |
@ -0,0 +1,4 @@ |
|||
|
|||
terraform { |
|||
required_version = ">= 0.12" |
|||
} |
Loading…
Reference in new issue