Skip to content

Commit

Permalink
fix labels managedby variables (#7)
Browse files Browse the repository at this point in the history
* fix labels managedby variables

* fix labels managedby variables
  • Loading branch information
Nikita Dugar authored Mar 30, 2020
1 parent bd9cad4 commit 9d33de2
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 46 deletions.
92 changes: 49 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Terraform AWS Subnet
</h1>

<p align="center" style="font-size: 1.2rem;">
<p align="center" style="font-size: 1.2rem;">
Terraform module to create public, private and public-private subnet with network acl, route table, Elastic IP, nat gateway, flow log.
</p>

Expand Down Expand Up @@ -38,7 +38,7 @@
<hr>


We eat, drink, sleep and most importantly love **DevOps**. We are working towards stratergies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy <b>Bigger problems are always solved by breaking them into smaller manageable problems</b>. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller <b>connected yet manageable pieces</b> within the infrastructure.
We eat, drink, sleep and most importantly love **DevOps**. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy <b>Bigger problems are always solved by breaking them into smaller manageable problems</b>. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller <b>connected yet manageable pieces</b> within the infrastructure.

This module is basically combination of [Terraform open source](https://www.terraform.io/) and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.

Expand All @@ -49,7 +49,7 @@ We have [*fifty plus terraform modules*][terraform_modules]. A few of them are c

## Prerequisites

This module has a few dependencies:
This module has a few dependencies:

- [Terraform 0.12](https://learn.hashicorp.com/terraform/getting-started/install.html)
- [Go](https://golang.org/doc/install)
Expand All @@ -61,16 +61,18 @@ This module has a few dependencies:




## Examples


**IMPORTANT:** Since the `master` branch used in `source` varies based on new modifications, we suggest that you use the release versions [here](https://github.com/clouddrove/terraform-aws-subnet/releases).


Here are some examples of how you can use this module in your inventory structure:
### Private Subnet
```hcl
module "subnets" {
source = "git::https://github.com/clouddrove/terraform-aws-subnet.git?ref=tags/0.12.4"
source = "git::https://github.com/clouddrove/terraform-aws-subnet.git?ref=tags/0.12.5"
name = "subnets"
application = "clouddrove"
environment = "test"
Expand All @@ -87,7 +89,7 @@ Here are some examples of how you can use this module in your inventory structur
### Public-Private Subnet
```hcl
module "subnets" {
source = "git::https://github.com/clouddrove/terraform-aws-subnet.git?ref=tags/0.12.4"
source = "git::https://github.com/clouddrove/terraform-aws-subnet.git?ref=tags/0.12.5"
name = "subnets"
application = "clouddrove"
environment = "test"
Expand All @@ -104,7 +106,7 @@ Here are some examples of how you can use this module in your inventory structur
### Public Subnet
```hcl
module "subnets" {
source = "git::https://github.com/clouddrove/terraform-aws-subnet.git?ref=tags/0.12.4"
source = "git::https://github.com/clouddrove/terraform-aws-subnet.git?ref=tags/0.12.5"
name = "subnets"
application = "clouddrove"
environment = "test"
Expand All @@ -119,54 +121,58 @@ Here are some examples of how you can use this module in your inventory structur






## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| application | Application (e.g. `cd` or `clouddrove`). | string | `` | no |
| attributes | Additional attributes (e.g. `1`). | list | `<list>` | no |
| availability_zones | List of Availability Zones (e.g. `['us-east-1a', 'us-east-1b', 'us-east-1c']`). | list(string) | `<list>` | no |
| az_ngw_count | Count of items in the `az_ngw_ids` map. Needs to be explicitly provided since Terraform currently can't use dynamic count on computed resources from different modules. https://github.com/hashicorp/terraform/issues/10857. | number | `0` | no |
| az_ngw_ids | Only for private subnets. Map of AZ names to NAT Gateway IDs that are used as default routes when creating private subnets. | map(string) | `<map>` | no |
| cidr_block | Base CIDR block which is divided into subnet CIDR blocks (e.g. `10.0.0.0/16`). | string | - | yes |
| delimiter | Delimiter to be used between `organization`, `environment`, `name` and `attributes`. | string | `-` | no |
| enable_acl | Set to false to prevent the module from creating any resources. | bool | `true` | no |
| enable_flow_log | Enable subnet_flow_log logs. | bool | `false` | no |
| enabled | Set to false to prevent the module from creating any resources. | bool | `true` | no |
| environment | Environment (e.g. `prod`, `dev`, `staging`). | string | `` | no |
| igw_id | Internet Gateway ID that is used as a default route when creating public subnets (e.g. `igw-9c26a123`). | string | `` | no |
| label_order | Label order, e.g. `name`,`application`. | list | `<list>` | no |
| map_public_ip_on_launch | Specify true to indicate that instances launched into the subnet should be assigned a public IP address. | bool | `true` | no |
| max_subnets | Maximum number of subnets that can be created. The variable is used for CIDR blocks calculation. | number | `6` | no |
| name | Name (e.g. `app` or `cluster`). | string | `` | no |
| nat_gateway_enabled | Flag to enable/disable NAT Gateways creation in public subnets. | bool | `false` | no |
| private_network_acl_id | Network ACL ID that is added to the private subnets. If empty, a new ACL will be created. | string | `` | no |
| public_network_acl_id | Network ACL ID that is added to the public subnets. If empty, a new ACL will be created. | string | `` | no |
| public_subnet_ids | A list of public subnet ids. | list(string) | `<list>` | no |
| s3_bucket_arn | S3 ARN for vpc logs. | string | `` | no |
| tags | Additional tags (e.g. map(`BusinessUnit`,`XYZ`). | map | `<map>` | no |
| traffic_type | Type of traffic to capture. Valid values: ACCEPT,REJECT, ALL. | string | `ALL` | no |
| type | Type of subnets to create (`private` or `public`). | string | `` | no |
| vpc_id | VPC ID. | string | - | yes |
| application | Application \(e.g. `cd` or `clouddrove`\). | string | `""` | no |
| attributes | Additional attributes \(e.g. `1`\). | list | `<list>` | no |
| availability\_zones | List of Availability Zones \(e.g. `\['us-east-1a', 'us-east-1b', 'us-east-1c'\]`\). | list(string) | `<list>` | no |
| az\_ngw\_count | Count of items in the `az\_ngw\_ids` map. Needs to be explicitly provided since Terraform currently can't use dynamic count on computed resources from different modules. https://github.com/hashicorp/terraform/issues/10857. | number | `"0"` | no |
| az\_ngw\_ids | Only for private subnets. Map of AZ names to NAT Gateway IDs that are used as default routes when creating private subnets. | map(string) | `<map>` | no |
| cidr\_block | Base CIDR block which is divided into subnet CIDR blocks \(e.g. `10.0.0.0/16`\). | string | n/a | yes |
| delimiter | Delimiter to be used between `organization`, `environment`, `name` and `attributes`. | string | `"-"` | no |
| enable\_acl | Set to false to prevent the module from creating any resources. | bool | `"true"` | no |
| enable\_flow\_log | Enable subnet\_flow\_log logs. | bool | `"false"` | no |
| enabled | Set to false to prevent the module from creating any resources. | bool | `"true"` | no |
| environment | Environment \(e.g. `prod`, `dev`, `staging`\). | string | `""` | no |
| igw\_id | Internet Gateway ID that is used as a default route when creating public subnets \(e.g. `igw-9c26a123`\). | string | `""` | no |
| label\_order | Label order, e.g. `name`,`application`. | list | `<list>` | no |
| managedby | ManagedBy, eg 'CloudDrove' or 'AnmolNagpal'. | string | `"anmol@clouddrove.com"` | no |
| map\_public\_ip\_on\_launch | Specify true to indicate that instances launched into the subnet should be assigned a public IP address. | bool | `"true"` | no |
| max\_subnets | Maximum number of subnets that can be created. The variable is used for CIDR blocks calculation. | number | `"6"` | no |
| name | Name \(e.g. `app` or `cluster`\). | string | `""` | no |
| nat\_gateway\_enabled | Flag to enable/disable NAT Gateways creation in public subnets. | bool | `"false"` | no |
| private\_network\_acl\_id | Network ACL ID that is added to the private subnets. If empty, a new ACL will be created. | string | `""` | no |
| public\_network\_acl\_id | Network ACL ID that is added to the public subnets. If empty, a new ACL will be created. | string | `""` | no |
| public\_subnet\_ids | A list of public subnet ids. | list(string) | `<list>` | no |
| s3\_bucket\_arn | S3 ARN for vpc logs. | string | `""` | no |
| tags | Additional tags \(e.g. map\(`BusinessUnit`,`XYZ`\). | map | `<map>` | no |
| traffic\_type | Type of traffic to capture. Valid values: ACCEPT,REJECT, ALL. | string | `"ALL"` | no |
| type | Type of subnets to create \(`private` or `public`\). | string | `""` | no |
| vpc\_id | VPC ID. | string | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| private_route_tables_id | The ID of the routing table. |
| private_subnet_cidrs | CIDR blocks of the created private subnets. |
| private_subnet_id | The ID of the private subnet. |
| private_tags | A mapping of private tags to assign to the resource. |
| public_route_tables_id | The ID of the routing table. |
| public_subnet_cidrs | CIDR blocks of the created public subnets. |
| public_subnet_id | The ID of the subnet. |
| public_tags | A mapping of public tags to assign to the resource. |
| private\_route\_tables\_id | The ID of the routing table. |
| private\_subnet\_cidrs | CIDR blocks of the created private subnets. |
| private\_subnet\_id | The ID of the private subnet. |
| private\_tags | A mapping of private tags to assign to the resource. |
| public\_route\_tables\_id | The ID of the routing table. |
| public\_subnet\_cidrs | CIDR blocks of the created public subnets. |
| public\_subnet\_id | The ID of the subnet. |
| public\_tags | A mapping of public tags to assign to the resource. |



## Testing

In this module testing is performed with [terratest](https://github.com/gruntwork-io/terratest) and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a [GO environment](https://golang.org/doc/install) in your system.
## Testing
In this module testing is performed with [terratest](https://github.com/gruntwork-io/terratest) and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a [GO environment](https://golang.org/doc/install) in your system.

You need to run the following command in the testing folder:
```hcl
Expand All @@ -175,7 +181,7 @@ You need to run the following command in the testing folder:



## Feedback
## Feedback
If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/terraform-aws-subnet/issues), or feel free to drop us an email at [hello@clouddrove.com](mailto:hello@clouddrove.com).

If you have found it worth your time, go ahead and give us a ★ on [our GitHub](https://github.com/clouddrove/terraform-aws-subnet)!
Expand All @@ -193,4 +199,4 @@ At [CloudDrove][website], we offer expert guidance, implementation support and s
[linkedin]: https://cpco.io/linkedin
[twitter]: https://twitter.com/clouddrove/
[email]: https://clouddrove.com/contact-us.html
[terraform_modules]: https://github.com/clouddrove?utf8=%E2%9C%93&q=terraform-&type=&language=
[terraform_modules]: https://github.com/clouddrove?utf8=%E2%9C%93&q=terraform-&type=&language=
6 changes: 3 additions & 3 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ usage : |-
### Private Subnet
```hcl
module "subnets" {
source = "git::https://github.com/clouddrove/terraform-aws-subnet.git?ref=tags/0.12.4"
source = "git::https://github.com/clouddrove/terraform-aws-subnet.git?ref=tags/0.12.5"
name = "subnets"
application = "clouddrove"
environment = "test"
Expand All @@ -53,7 +53,7 @@ usage : |-
### Public-Private Subnet
```hcl
module "subnets" {
source = "git::https://github.com/clouddrove/terraform-aws-subnet.git?ref=tags/0.12.4"
source = "git::https://github.com/clouddrove/terraform-aws-subnet.git?ref=tags/0.12.5"
name = "subnets"
application = "clouddrove"
environment = "test"
Expand All @@ -70,7 +70,7 @@ usage : |-
### Public Subnet
```hcl
module "subnets" {
source = "git::https://github.com/clouddrove/terraform-aws-subnet.git?ref=tags/0.12.4"
source = "git::https://github.com/clouddrove/terraform-aws-subnet.git?ref=tags/0.12.5"
name = "subnets"
application = "clouddrove"
environment = "test"
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module "private-labels" {
name = var.name
application = var.application
environment = var.environment
managedby = var.managedby
label_order = var.label_order
attributes = compact(concat(var.attributes, list("private")))
}
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ variable "tags" {
description = "Additional tags (e.g. map(`BusinessUnit`,`XYZ`)."
}

variable "managedby" {
type = string
default = "anmol@clouddrove.com"
description = "ManagedBy, eg 'CloudDrove' or 'AnmolNagpal'."
}

#Module : SUBNET
#Description : Terraform SUBNET module variables.
variable "availability_zones" {
Expand Down

0 comments on commit 9d33de2

Please sign in to comment.