Skip to content

Commit

Permalink
refactor: adding documentation and moving code to src/
Browse files Browse the repository at this point in the history
  • Loading branch information
felipempda committed Jan 5, 2024
1 parent 252bcbf commit f2075dd
Show file tree
Hide file tree
Showing 18 changed files with 235 additions and 34 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ This POC aims to deploy two VPCs in order to test route53 inbound and outbound c
## Deploy terraform

```bash
cd src/
terraform init
terraform apply -auto-approve -var=use_output_endpoint=false
```
Expand Down Expand Up @@ -150,3 +151,9 @@ In summary:
nslookup google.environment-a.private.com # It works now, because there's an outbound resolver that forwards queries to VPC-A inbound resolver
nslookup google.environment-a.private.com 10.78.100.10 # It works, because it queries VPC-A inbound resolver IP directly
```

## Destroy resources

```bash
terraform destroy -auto-approve
```
7 changes: 0 additions & 7 deletions ec2/output.tf

This file was deleted.

78 changes: 78 additions & 0 deletions src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Documentation - solution

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | 5.31.0 |
| <a name="requirement_http"></a> [http](#requirement\_http) | 3.4.1 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.31.0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_ec2-a"></a> [ec2-a](#module\_ec2-a) | ./ec2 | n/a |
| <a name="module_ec2-b"></a> [ec2-b](#module\_ec2-b) | ./ec2 | n/a |
| <a name="module_vpc-a"></a> [vpc-a](#module\_vpc-a) | ./vpc | n/a |
| <a name="module_vpc-b"></a> [vpc-b](#module\_vpc-b) | ./vpc | n/a |

## Resources

| Name | Type |
|------|------|
| [aws_route.traffic-from-a-to-b-private](https://registry.terraform.io/providers/hashicorp/aws/5.31.0/docs/resources/route) | resource |
| [aws_route.traffic-from-a-to-b-public](https://registry.terraform.io/providers/hashicorp/aws/5.31.0/docs/resources/route) | resource |
| [aws_route.traffic-from-b-to-a-private](https://registry.terraform.io/providers/hashicorp/aws/5.31.0/docs/resources/route) | resource |
| [aws_route.traffic-from-b-to-a-public](https://registry.terraform.io/providers/hashicorp/aws/5.31.0/docs/resources/route) | resource |
| [aws_route53_record.google](https://registry.terraform.io/providers/hashicorp/aws/5.31.0/docs/resources/route53_record) | resource |
| [aws_route53_resolver_endpoint.inbound](https://registry.terraform.io/providers/hashicorp/aws/5.31.0/docs/resources/route53_resolver_endpoint) | resource |
| [aws_route53_resolver_endpoint.outbound](https://registry.terraform.io/providers/hashicorp/aws/5.31.0/docs/resources/route53_resolver_endpoint) | resource |
| [aws_route53_resolver_rule.from-b-to-a](https://registry.terraform.io/providers/hashicorp/aws/5.31.0/docs/resources/route53_resolver_rule) | resource |
| [aws_route53_resolver_rule_association.this](https://registry.terraform.io/providers/hashicorp/aws/5.31.0/docs/resources/route53_resolver_rule_association) | resource |
| [aws_route53_zone.dns_zone_private](https://registry.terraform.io/providers/hashicorp/aws/5.31.0/docs/resources/route53_zone) | resource |
| [aws_security_group.inbound](https://registry.terraform.io/providers/hashicorp/aws/5.31.0/docs/resources/security_group) | resource |
| [aws_security_group.outbound](https://registry.terraform.io/providers/hashicorp/aws/5.31.0/docs/resources/security_group) | resource |
| [aws_vpc_peering_connection.peer](https://registry.terraform.io/providers/hashicorp/aws/5.31.0/docs/resources/vpc_peering_connection) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_aza"></a> [aza](#input\_aza) | Availability Zone for subnets A | `string` | `"ca-central-1a"` | no |
| <a name="input_azb"></a> [azb](#input\_azb) | Availability Zone for subnets B | `string` | `"ca-central-1b"` | no |
| <a name="input_private_domain"></a> [private\_domain](#input\_private\_domain) | Private Hosted Zone Name to be deployed on VPC-A | `string` | `"environment-a.private.com"` | no |
| <a name="input_public_key_path"></a> [public\_key\_path](#input\_public\_key\_path) | Path to public key to be used with EC2 instance | `string` | `"~/.ssh/id_rsa.pub"` | no |
| <a name="input_region"></a> [region](#input\_region) | Region where to deploy code | `string` | `"ca-central-1"` | no |
| <a name="input_use_output_endpoint"></a> [use\_output\_endpoint](#input\_use\_output\_endpoint) | Create outbound endpoint on environment B? | `bool` | `true` | no |
| <a name="input_vpca_cidr"></a> [vpca\_cidr](#input\_vpca\_cidr) | CIDR Block of VPC-A | `string` | `"10.78.0.0/16"` | no |
| <a name="input_vpca_inbound_resolver_ipa"></a> [vpca\_inbound\_resolver\_ipa](#input\_vpca\_inbound\_resolver\_ipa) | IP of inbound resolver on VPC-A private subnet A | `string` | `"10.78.100.10"` | no |
| <a name="input_vpca_inbound_resolver_ipb"></a> [vpca\_inbound\_resolver\_ipb](#input\_vpca\_inbound\_resolver\_ipb) | IP of inbound resolver on VPC-A private subnet B | `string` | `"10.78.101.10"` | no |
| <a name="input_vpca_private_subneta_cidr"></a> [vpca\_private\_subneta\_cidr](#input\_vpca\_private\_subneta\_cidr) | CIDR Block of VPC-A private subnet A | `string` | `"10.78.100.0/24"` | no |
| <a name="input_vpca_private_subnetb_cidr"></a> [vpca\_private\_subnetb\_cidr](#input\_vpca\_private\_subnetb\_cidr) | CIDR Block of VPC-A private subnet B | `string` | `"10.78.101.0/24"` | no |
| <a name="input_vpca_public_subneta_cidr"></a> [vpca\_public\_subneta\_cidr](#input\_vpca\_public\_subneta\_cidr) | CIDR Block of VPC-A public subnet A | `string` | `"10.78.0.0/24"` | no |
| <a name="input_vpca_public_subnetb_cidr"></a> [vpca\_public\_subnetb\_cidr](#input\_vpca\_public\_subnetb\_cidr) | CIDR Block of VPC-A public subnet B | `string` | `"10.78.1.0/24"` | no |
| <a name="input_vpcb_cidr"></a> [vpcb\_cidr](#input\_vpcb\_cidr) | CIDR Block of VPC-B | `string` | `"10.99.0.0/16"` | no |
| <a name="input_vpcb_outbound_resolver_ipa"></a> [vpcb\_outbound\_resolver\_ipa](#input\_vpcb\_outbound\_resolver\_ipa) | IP of outbound resolver on VPC-B private subnet A | `string` | `"10.99.100.10"` | no |
| <a name="input_vpcb_outbound_resolver_ipb"></a> [vpcb\_outbound\_resolver\_ipb](#input\_vpcb\_outbound\_resolver\_ipb) | IP of outbound resolver on VPC-B private subnet B | `string` | `"10.99.101.10"` | no |
| <a name="input_vpcb_private_subneta_cidr"></a> [vpcb\_private\_subneta\_cidr](#input\_vpcb\_private\_subneta\_cidr) | CIDR Block of VPC-B private subnet A | `string` | `"10.99.100.0/24"` | no |
| <a name="input_vpcb_private_subnetb_cidr"></a> [vpcb\_private\_subnetb\_cidr](#input\_vpcb\_private\_subnetb\_cidr) | CIDR Block of VPC-B private subnet B | `string` | `"10.99.101.0/24"` | no |
| <a name="input_vpcb_public_subneta_cidr"></a> [vpcb\_public\_subneta\_cidr](#input\_vpcb\_public\_subneta\_cidr) | CIDR Block of VPC-B public subnet A | `string` | `"10.99.0.0/24"` | no |
| <a name="input_vpcb_public_subnetb_cidr"></a> [vpcb\_public\_subnetb\_cidr](#input\_vpcb\_public\_subnetb\_cidr) | CIDR Block of VPC-B public subnet B | `string` | `"10.99.1.0/24"` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_vpca-inbound-resolver-ipA"></a> [vpca-inbound-resolver-ipA](#output\_vpca-inbound-resolver-ipA) | IP of inbound-resolver on VPCA-A private subnet A |
| <a name="output_vpca-inbound-resolver-ipB"></a> [vpca-inbound-resolver-ipB](#output\_vpca-inbound-resolver-ipB) | IP of inbound-resolver on VPCA-A private subnet B |
| <a name="output_vpca-instance-public-dns"></a> [vpca-instance-public-dns](#output\_vpca-instance-public-dns) | Public DNS of instance-a |
| <a name="output_vpcb-instance-public-dns"></a> [vpcb-instance-public-dns](#output\_vpcb-instance-public-dns) | Public DNS of instance-b |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
47 changes: 47 additions & 0 deletions src/ec2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Documentation - module ec2

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

No requirements.

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
| <a name="provider_http"></a> [http](#provider\_http) | n/a |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_instance.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance) | resource |
| [aws_key_pair.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/key_pair) | resource |
| [aws_security_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |
| [aws_security_group_rule.all-egress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_security_group_rule.icmp-ingress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_security_group_rule.ssh-ingress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
| [aws_ami.ubuntu](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source |
| [http_http.myip](https://registry.terraform.io/providers/hashicorp/http/latest/docs/data-sources/http) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_name"></a> [name](#input\_name) | Tag Name of ec2 instance | `string` | `"ec2-instance"` | no |
| <a name="input_public_key_path"></a> [public\_key\_path](#input\_public\_key\_path) | Path to public key to be used with EC2 instance | `string` | `"~/.ssh/id_rsa.pub"` | no |
| <a name="input_subnet_id"></a> [subnet\_id](#input\_subnet\_id) | Subnet where to deploy EC2 | `any` | n/a | yes |
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | Subnet where to create Security Group | `any` | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_instance_id"></a> [instance\_id](#output\_instance\_id) | ID of EC2 Instance |
| <a name="output_public_dns"></a> [public\_dns](#output\_public\_dns) | Public DNS of EC2 Instance |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
File renamed without changes.
9 changes: 9 additions & 0 deletions src/ec2/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
output "public_dns" {
value = aws_instance.this.public_dns
description = "Public DNS of EC2 Instance"
}

output "instance_id" {
value = aws_instance.this.id
description = "ID of EC2 Instance"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
59 changes: 59 additions & 0 deletions src/vpc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Documentation - module vpc

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

No requirements.

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_internet_gateway.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/internet_gateway) | resource |
| [aws_route.route-public](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route) | resource |
| [aws_route_table.private](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table) | resource |
| [aws_route_table.public](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table) | resource |
| [aws_route_table_association.private-subneta](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table_association) | resource |
| [aws_route_table_association.private-subnetb](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table_association) | resource |
| [aws_route_table_association.public-subneta](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table_association) | resource |
| [aws_route_table_association.public-subnetb](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table_association) | resource |
| [aws_subnet.private-subnet-a](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet) | resource |
| [aws_subnet.private-subnet-b](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet) | resource |
| [aws_subnet.public-subnet-a](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet) | resource |
| [aws_subnet.public-subnet-b](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet) | resource |
| [aws_vpc.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_private_subneta_cidr"></a> [private\_subneta\_cidr](#input\_private\_subneta\_cidr) | CIDR Block of Private Subnet A | `any` | n/a | yes |
| <a name="input_private_subnetb_cidr"></a> [private\_subnetb\_cidr](#input\_private\_subnetb\_cidr) | CIDR Block of Private Subnet B | `any` | n/a | yes |
| <a name="input_public_subneta_cidr"></a> [public\_subneta\_cidr](#input\_public\_subneta\_cidr) | CIDR Block of Public Subnet A | `any` | n/a | yes |
| <a name="input_public_subnetb_cidr"></a> [public\_subnetb\_cidr](#input\_public\_subnetb\_cidr) | CIDR Block of Public Subnet B | `any` | n/a | yes |
| <a name="input_subneta_az"></a> [subneta\_az](#input\_subneta\_az) | Availability Zone of subnet A | `any` | n/a | yes |
| <a name="input_subnetb_az"></a> [subnetb\_az](#input\_subnetb\_az) | Availability Zone of subnet B | `any` | n/a | yes |
| <a name="input_vpc_cidr_block"></a> [vpc\_cidr\_block](#input\_vpc\_cidr\_block) | CIDR Block of VPC | `any` | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_private_route_table_id"></a> [private\_route\_table\_id](#output\_private\_route\_table\_id) | ID of Private Route Table |
| <a name="output_private_subneta_id"></a> [private\_subneta\_id](#output\_private\_subneta\_id) | ID of Private Subnet A |
| <a name="output_private_subnetb_id"></a> [private\_subnetb\_id](#output\_private\_subnetb\_id) | ID of Private Subnet B |
| <a name="output_public_route_table_id"></a> [public\_route\_table\_id](#output\_public\_route\_table\_id) | ID of Public Route Table |
| <a name="output_public_subneta_id"></a> [public\_subneta\_id](#output\_public\_subneta\_id) | ID of Public Subnet A |
| <a name="output_public_subnetb_id"></a> [public\_subnetb\_id](#output\_public\_subnetb\_id) | ID of Public Subnet B |
| <a name="output_vpc_id"></a> [vpc\_id](#output\_vpc\_id) | ID of VPC |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
File renamed without changes.
35 changes: 35 additions & 0 deletions src/vpc/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
output "vpc_id" {
value = aws_vpc.this.id
description = "ID of VPC"
}

output "public_subneta_id" {
value = aws_subnet.public-subnet-a.id
description = "ID of Public Subnet A"
}

output "private_subnetb_id" {
value = aws_subnet.private-subnet-b.id
description = "ID of Private Subnet B"
}

output "private_subneta_id" {
value = aws_subnet.private-subnet-a.id
description = "ID of Private Subnet A"

}

output "public_subnetb_id" {
value = aws_subnet.public-subnet-b.id
description = "ID of Public Subnet B"
}

output "public_route_table_id" {
value = aws_route_table.public.id
description = "ID of Public Route Table"
}

output "private_route_table_id" {
value = aws_route_table.private.id
description = "ID of Private Route Table"
}
File renamed without changes.
File renamed without changes.
27 changes: 0 additions & 27 deletions vpc/output.tf

This file was deleted.

0 comments on commit f2075dd

Please sign in to comment.