aboutsummaryrefslogtreecommitdiffstats
path: root/fdio.infra.terraform
diff options
context:
space:
mode:
Diffstat (limited to 'fdio.infra.terraform')
-rw-r--r--fdio.infra.terraform/terraform-aws-subnet/README.md54
-rw-r--r--fdio.infra.terraform/terraform-aws-subnet/example/main.tf17
-rw-r--r--fdio.infra.terraform/terraform-aws-subnet/example/output.tf0
-rw-r--r--fdio.infra.terraform/terraform-aws-subnet/example/providers.tf3
-rw-r--r--fdio.infra.terraform/terraform-aws-subnet/example/variables.tf5
-rw-r--r--fdio.infra.terraform/terraform-aws-subnet/example/versions.tf9
-rw-r--r--fdio.infra.terraform/terraform-aws-subnet/main.tf26
-rw-r--r--fdio.infra.terraform/terraform-aws-subnet/outputs.tf4
-rw-r--r--fdio.infra.terraform/terraform-aws-subnet/variables.tf45
-rw-r--r--fdio.infra.terraform/terraform-aws-subnet/versions.tf9
-rw-r--r--fdio.infra.terraform/terraform-aws-vpc/main.tf34
-rw-r--r--fdio.infra.terraform/terraform-aws-vpc/outputs.tf5
12 files changed, 194 insertions, 17 deletions
diff --git a/fdio.infra.terraform/terraform-aws-subnet/README.md b/fdio.infra.terraform/terraform-aws-subnet/README.md
new file mode 100644
index 0000000000..4903bcb36f
--- /dev/null
+++ b/fdio.infra.terraform/terraform-aws-subnet/README.md
@@ -0,0 +1,54 @@
+<!-- BEGIN_TF_DOCS -->
+## Requirements
+
+| Name | Version |
+|------|---------|
+| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.1.4 |
+| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 4.3.0 |
+
+## Providers
+
+| Name | Version |
+|------|---------|
+| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 4.3.0 |
+
+## Modules
+
+No modules.
+
+## Resources
+
+| Name | Type |
+|------|------|
+| [aws_internet_gateway.internet_gateway](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/internet_gateway) | resource |
+| [aws_route.route](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route) | resource |
+| [aws_security_group.security_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |
+| [aws_subnet.subnet](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet) | resource |
+| [aws_vpc.vpc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc) | resource |
+
+## Inputs
+
+| Name | Description | Type | Default | Required |
+|------|-------------|------|---------|:--------:|
+| <a name="input_security_group_description"></a> [security\_group\_description](#input\_security\_group\_description) | Security group description. | `string` | `"Allow inbound/outbound traffic"` | no |
+| <a name="input_security_group_egress"></a> [security\_group\_egress](#input\_security\_group\_egress) | Egress security group map. | `list(any)` | <pre>[<br> {<br> "cidr_blocks": [<br> "0.0.0.0/0"<br> ],<br> "from_port": 0,<br> "ipv6_cidr_blocks": [<br> "::/0"<br> ],<br> "protocol": "-1",<br> "to_port": 0<br> }<br>]</pre> | no |
+| <a name="input_security_group_ingress"></a> [security\_group\_ingress](#input\_security\_group\_ingress) | Ingress security group map. | `list(any)` | <pre>[<br> {<br> "cidr_blocks": [<br> "0.0.0.0/0"<br> ],<br> "from_port": 22,<br> "ipv6_cidr_blocks": [<br> "::/0"<br> ],<br> "protocol": "tcp",<br> "to_port": 22<br> }<br>]</pre> | no |
+| <a name="input_security_group_name"></a> [security\_group\_name](#input\_security\_group\_name) | Name of the security group. | `string` | n/a | yes |
+| <a name="input_security_group_revoke_rules_on_delete"></a> [security\_group\_revoke\_rules\_on\_delete](#input\_security\_group\_revoke\_rules\_on\_delete) | Instruct Terraform to revoke all of the Security Groups attached ingress and egress rules before deleting the rule itself. | `bool` | `false` | no |
+| <a name="input_subnet_assign_ipv6_address_on_creation"></a> [subnet\_assign\_ipv6\_address\_on\_creation](#input\_subnet\_assign\_ipv6\_address\_on\_creation) | Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. | `bool` | `false` | no |
+| <a name="input_subnet_availability_zone"></a> [subnet\_availability\_zone](#input\_subnet\_availability\_zone) | AWS availability zone | `string` | `"us-east-1a"` | no |
+| <a name="input_subnet_map_public_ip_on_launch"></a> [subnet\_map\_public\_ip\_on\_launch](#input\_subnet\_map\_public\_ip\_on\_launch) | Specify true to indicate that instances launched into the subnet should be assigned a public IP address. | `bool` | `false` | no |
+| <a name="input_tags_environment"></a> [tags\_environment](#input\_tags\_environment) | Environment used for tag. | `string` | `""` | no |
+| <a name="input_tags_name"></a> [tags\_name](#input\_tags\_name) | Name used for tag. | `string` | `""` | no |
+| <a name="input_vpc_assign_generated_ipv6_cidr_block"></a> [vpc\_assign\_generated\_ipv6\_cidr\_block](#input\_vpc\_assign\_generated\_ipv6\_cidr\_block) | Requests an Amazon-provided IPv6 CIDR block with a /56 prefix length for the VPC. | `bool` | `true` | no |
+| <a name="input_vpc_cidr_block"></a> [vpc\_cidr\_block](#input\_vpc\_cidr\_block) | The CIDR block for the association. | `string` | `"192.168.0.0/24"` | no |
+| <a name="input_vpc_enable_dns_hostnames"></a> [vpc\_enable\_dns\_hostnames](#input\_vpc\_enable\_dns\_hostnames) | Whether or not the VPC has DNS hostname support. | `bool` | `true` | no |
+| <a name="input_vpc_enable_dns_support"></a> [vpc\_enable\_dns\_support](#input\_vpc\_enable\_dns\_support) | Whether or not the VPC has DNS support. | `bool` | `true` | no |
+| <a name="input_vpc_instance_tenancy"></a> [vpc\_instance\_tenancy](#input\_vpc\_instance\_tenancy) | The allowed tenancy of instances launched into the selected VPC. | `string` | `"default"` | no |
+
+## Outputs
+
+| Name | Description |
+|------|-------------|
+| <a name="output_vpc_id"></a> [vpc\_id](#output\_vpc\_id) | The ID of the VPC |
+<!-- END_TF_DOCS --> \ No newline at end of file
diff --git a/fdio.infra.terraform/terraform-aws-subnet/example/main.tf b/fdio.infra.terraform/terraform-aws-subnet/example/main.tf
new file mode 100644
index 0000000000..98f8613876
--- /dev/null
+++ b/fdio.infra.terraform/terraform-aws-subnet/example/main.tf
@@ -0,0 +1,17 @@
+module "vpc" {
+ source = "../../terraform-aws-vpc"
+ security_group_name = "terraform-sg"
+ subnet_availability_zone = "us-east-1a"
+ tags_name = "terraform-vpc"
+ tags_environment = "terraform-vpc-environment"
+}
+
+module "subnet" {
+ source = "../"
+ subnet_cidr_block = "192.168.10.0/24"
+ subnet_ipv6_cidr_block = cidrsubnet(module.vpc.vpc_ipv6_cidr_block, 8, 1)
+ subnet_availability_zone = "us-east-1a"
+ tags_name = "terraform-subnet"
+ tags_environment = "terraform-subnet-environment"
+ subnet_vpc_id = module.vpc.vpc_id
+}
diff --git a/fdio.infra.terraform/terraform-aws-subnet/example/output.tf b/fdio.infra.terraform/terraform-aws-subnet/example/output.tf
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/fdio.infra.terraform/terraform-aws-subnet/example/output.tf
diff --git a/fdio.infra.terraform/terraform-aws-subnet/example/providers.tf b/fdio.infra.terraform/terraform-aws-subnet/example/providers.tf
new file mode 100644
index 0000000000..5ff54f0d65
--- /dev/null
+++ b/fdio.infra.terraform/terraform-aws-subnet/example/providers.tf
@@ -0,0 +1,3 @@
+provider "aws" {
+ region = var.region
+} \ No newline at end of file
diff --git a/fdio.infra.terraform/terraform-aws-subnet/example/variables.tf b/fdio.infra.terraform/terraform-aws-subnet/example/variables.tf
new file mode 100644
index 0000000000..f75f3d547f
--- /dev/null
+++ b/fdio.infra.terraform/terraform-aws-subnet/example/variables.tf
@@ -0,0 +1,5 @@
+variable "region" {
+ description = "AWS Region."
+ type = string
+ default = "us-east-1"
+}
diff --git a/fdio.infra.terraform/terraform-aws-subnet/example/versions.tf b/fdio.infra.terraform/terraform-aws-subnet/example/versions.tf
new file mode 100644
index 0000000000..af1be4a4e1
--- /dev/null
+++ b/fdio.infra.terraform/terraform-aws-subnet/example/versions.tf
@@ -0,0 +1,9 @@
+terraform {
+ required_providers {
+ aws = {
+ source = "hashicorp/aws"
+ version = ">= 4.3.0"
+ }
+ }
+ required_version = ">= 1.1.4"
+}
diff --git a/fdio.infra.terraform/terraform-aws-subnet/main.tf b/fdio.infra.terraform/terraform-aws-subnet/main.tf
new file mode 100644
index 0000000000..d14aa5f827
--- /dev/null
+++ b/fdio.infra.terraform/terraform-aws-subnet/main.tf
@@ -0,0 +1,26 @@
+locals {
+ tags = {
+ "Name" = "${var.tags_name}"
+ "Environment" = "${var.tags_environment}"
+ }
+}
+
+# Create VPC IPv4 CIDR Block Association
+resource "aws_vpc_ipv4_cidr_block_association" "ipv4_cidr_block_association" {
+ cidr_block = var.subnet_cidr_block
+ vpc_id = var.subnet_vpc_id
+}
+
+# Create Subnet
+resource "aws_subnet" "subnet" {
+ depends_on = [
+ aws_vpc_ipv4_cidr_block_association.ipv4_cidr_block_association
+ ]
+ assign_ipv6_address_on_creation = var.subnet_assign_ipv6_address_on_creation
+ availability_zone = var.subnet_availability_zone
+ cidr_block = var.subnet_cidr_block
+ ipv6_cidr_block = var.subnet_ipv6_cidr_block
+ map_public_ip_on_launch = var.subnet_map_public_ip_on_launch
+ tags = local.tags
+ vpc_id = var.subnet_vpc_id
+}
diff --git a/fdio.infra.terraform/terraform-aws-subnet/outputs.tf b/fdio.infra.terraform/terraform-aws-subnet/outputs.tf
new file mode 100644
index 0000000000..7f17d95717
--- /dev/null
+++ b/fdio.infra.terraform/terraform-aws-subnet/outputs.tf
@@ -0,0 +1,4 @@
+output "subnet_id" {
+ value = aws_subnet.subnet.id
+ description = "The ID of the Subnet"
+}
diff --git a/fdio.infra.terraform/terraform-aws-subnet/variables.tf b/fdio.infra.terraform/terraform-aws-subnet/variables.tf
new file mode 100644
index 0000000000..cae74bae78
--- /dev/null
+++ b/fdio.infra.terraform/terraform-aws-subnet/variables.tf
@@ -0,0 +1,45 @@
+variable "tags_name" {
+ description = "Name used for tag."
+ type = string
+ default = ""
+}
+
+variable "tags_environment" {
+ description = "Environment used for tag."
+ type = string
+ default = ""
+}
+
+# Variables for Subnet
+variable "subnet_assign_ipv6_address_on_creation" {
+ description = "Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address."
+ type = bool
+ default = false
+}
+
+variable "subnet_availability_zone" {
+ description = "AZ for the subnet."
+ type = string
+ default = "us-east-1a"
+}
+
+variable "subnet_cidr_block" {
+ description = "The IPv4 CIDR block for the subnet."
+ type = string
+}
+
+variable "subnet_ipv6_cidr_block" {
+ description = "The IPv6 network range for the subnet, in CIDR notation."
+ type = string
+}
+
+variable "subnet_map_public_ip_on_launch" {
+ description = "Specify true to indicate that instances launched into the subnet should be assigned a public IP address."
+ type = bool
+ default = false
+}
+
+variable "subnet_vpc_id" {
+ description = "The VPC ID."
+ type = string
+}
diff --git a/fdio.infra.terraform/terraform-aws-subnet/versions.tf b/fdio.infra.terraform/terraform-aws-subnet/versions.tf
new file mode 100644
index 0000000000..66b9c17f9b
--- /dev/null
+++ b/fdio.infra.terraform/terraform-aws-subnet/versions.tf
@@ -0,0 +1,9 @@
+terraform {
+ required_providers {
+ aws = {
+ source = "hashicorp/aws"
+ version = "~> 4.3.0"
+ }
+ }
+ required_version = ">= 1.1.4"
+}
diff --git a/fdio.infra.terraform/terraform-aws-vpc/main.tf b/fdio.infra.terraform/terraform-aws-vpc/main.tf
index ed2e8715e7..59ac63663d 100644
--- a/fdio.infra.terraform/terraform-aws-vpc/main.tf
+++ b/fdio.infra.terraform/terraform-aws-vpc/main.tf
@@ -15,7 +15,7 @@ resource "aws_vpc" "vpc" {
tags = local.tags
}
-# Create Security Groups
+# Create Security Group
resource "aws_security_group" "security_group" {
depends_on = [
aws_vpc.vpc
@@ -29,26 +29,26 @@ resource "aws_security_group" "security_group" {
dynamic "ingress" {
for_each = var.security_group_ingress
content {
- from_port = ingress.value["from_port"]
- to_port = ingress.value["to_port"]
- protocol = ingress.value["protocol"]
- cidr_blocks = ingress.value["cidr_blocks"]
- ipv6_cidr_blocks = ingress.value["ipv6_cidr_blocks"]
+ from_port = lookup(ingress.value, "from_port", null)
+ to_port = lookup(ingress.value, "to_port", null)
+ protocol = lookup(ingress.value, "protocol", null)
+ cidr_blocks = lookup(ingress.value, "cidr_blocks", null)
+ ipv6_cidr_blocks = lookup(ingress.value, "ipv6_cidr_blocks", null)
}
}
dynamic "egress" {
for_each = var.security_group_egress
content {
- from_port = ingress.value["from_port"]
- to_port = ingress.value["to_port"]
- protocol = ingress.value["protocol"]
- cidr_blocks = ingress.value["cidr_blocks"]
- ipv6_cidr_blocks = ingress.value["ipv6_cidr_blocks"]
+ from_port = lookup(ingress.value, "from_port", null)
+ to_port = lookup(ingress.value, "to_port", null)
+ protocol = lookup(ingress.value, "protocol", null)
+ cidr_blocks = lookup(ingress.value, "cidr_blocks", null)
+ ipv6_cidr_blocks = lookup(ingress.value, "ipv6_cidr_blocks", null)
}
}
}
-# Create Gateway
+# Create Internet Gateway
resource "aws_internet_gateway" "internet_gateway" {
depends_on = [
aws_vpc.vpc
@@ -57,18 +57,18 @@ resource "aws_internet_gateway" "internet_gateway" {
vpc_id = aws_vpc.vpc.id
}
-# Create Routes
+# Create Route
resource "aws_route" "route" {
depends_on = [
aws_vpc.vpc,
aws_internet_gateway.internet_gateway
]
- destination_cidr_block = "0.0.0.0/0"
- gateway_id = aws_internet_gateway.internet_gateway.id
- route_table_id = aws_vpc.vpc.main_route_table_id
+ destination_cidr_block = "0.0.0.0/0"
+ gateway_id = aws_internet_gateway.internet_gateway.id
+ route_table_id = aws_vpc.vpc.main_route_table_id
}
-# Create Subnets
+# Create Subnet
resource "aws_subnet" "subnet" {
depends_on = [
aws_vpc.vpc
diff --git a/fdio.infra.terraform/terraform-aws-vpc/outputs.tf b/fdio.infra.terraform/terraform-aws-vpc/outputs.tf
index 444cde448a..e1072a6b16 100644
--- a/fdio.infra.terraform/terraform-aws-vpc/outputs.tf
+++ b/fdio.infra.terraform/terraform-aws-vpc/outputs.tf
@@ -1,4 +1,9 @@
output "vpc_id" {
value = aws_vpc.vpc.id
description = "The ID of the VPC"
+}
+
+output "vpc_ipv6_cidr_block" {
+ value = aws_vpc.vpc.ipv6_cidr_block
+ description = "IPv6 CIDR block"
} \ No newline at end of file