Skip to content

Commit

Permalink
terraform 0.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamlesh committed Aug 20, 2019
1 parent 09c16b1 commit 14de74b
Show file tree
Hide file tree
Showing 15 changed files with 775 additions and 289 deletions.
6 changes: 2 additions & 4 deletions .gitignore
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Compiled files
# ignored files
*.tfstate
*.tfstate.backup

# Module directory
.terraform
.idea
*.iml
*.iml
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repos:
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.12.0
hooks:
- id: terraform_fmt

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.0.0
hooks:
- id: check-merge-conflict
- id: trailing-whitespace
- id: check-yaml
- id: check-added-large-files
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Cloud Drove

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export GENIE_PATH ?= $(shell 'pwd')/../../../genie

include $(GENIE_PATH)/Makefile
199 changes: 184 additions & 15 deletions README.md
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,24 +1,193 @@
AWS ALB
==============
<!-- This file was automatically generated by the `geine`. Make all changes to `README.yaml` and run `make readme` to rebuild this file. -->

This module is for create alb with related resources.
<p align="center"> <img src="https://user-images.githubusercontent.com/50652676/62349836-882fef80-b51e-11e9-99e3-7b974309c7e3.png" width="100" height="100"></p>

###### main.tf
contain resource code for alb.

###### variables.tf
contain variables declaration. all variables are empty by default. we will define or put value to variables in equls.tf (main file for infrastructure). these are input vars.
<h1 align="center">
Terraform AWS ALB
</h1>

###### outputs.tf
is alse contain variables but we will these variables for output like ec2 instance id.
<p align="center" style="font-size: 1.2rem;">
This terraform module is used to create ALB on AWS.
</p>

## Infrastructure creats by this module
<p align="center">

1. Alb
2. Alb listener
3. Alb target group
4. Alb target group attachment.

<a href="https://www.terraform.io">
<img src="https://img.shields.io/badge/Terraform-v0.12-green" alt="Terraform">
</a>
<a href="LICENSE.md">
<img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="Licence">
</a>


</p>
<p align="center">

<a href='https://facebook.com/sharer/sharer.php?u=https://github.com/clouddrove/terraform-aws-alb'>
<img title="Share on Facebook" src="https://user-images.githubusercontent.com/50652676/62817743-4f64cb80-bb59-11e9-90c7-b057252ded50.png" />
</a>
<a href='https://www.linkedin.com/shareArticle?mini=true&title=Terraform+AWS+ALB&url=https://github.com/clouddrove/terraform-aws-alb'>
<img title="Share on LinkedIn" src="https://user-images.githubusercontent.com/50652676/62817742-4e339e80-bb59-11e9-87b9-a1f68cae1049.png" />
</a>
<a href='https://twitter.com/intent/tweet/?text=Terraform+AWS+ALB&url=https://github.com/clouddrove/terraform-aws-alb'>
<img title="Share on Twitter" src="https://user-images.githubusercontent.com/50652676/62817740-4c69db00-bb59-11e9-8a79-3580fbbf6d5c.png" />
</a>

</p>
<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.

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.

We have [*fifty plus terraform modules*][terraform_modules]. A few of them are comepleted and are available for open source usage while a few others are in progress.




## Prerequisites

This module has a few dependencies:

- [Terraform 0.12](https://learn.hashicorp.com/terraform/getting-started/install.html)
- [Go](https://golang.org/doc/install)
- [github.com/stretchr/testify/assert](https://github.com/stretchr/testify)
- [github.com/gruntwork-io/terratest/modules/terraform](https://github.com/gruntwork-io/terratest)






## 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-alb/releases).


### Simple Example
Here is an example of how you can use this module in your inventory structure:
```hcl
module "alb" {
source = "git::https://github.com/clouddrove/terraform-aws-alb.git"
name = "alb"
application = "clouddrove"
environment = "test"
label_order = ["environment", "name", "application"]
internal = false
load_balancer_type = "application"
instance_count = 2
security_groups = ["sg-xxxxxxx"]
subnets = "subnet-xxxxxxx"
enable_deletion_protection = false
target_id = "i-xxxxxxxxxx"
vpc_id = "vpc-xxxxxxxxx"
target_group_protocol = "HTTP"
target_group_port = 80
listener_certificate_arn = "arn:aws:acm:eu-west-1:xxxxxxxxxxxx:certificate/xxxxxx-xxxx-xxxxx-xxxx"
https_enabled = true
http_enabled = true
}
```



## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| access_logs | Access logs Enable or Disable. | bool | `false` | no |
| alb_environment | A mapping of tags to assign to the resource. | string | `` | no |
| alb_name | The name of the LB. This name must be unique within your AWS account, can have a maximum of 32 characters, must contain only alphanumeric characters or hyphens, and must not begin or end with a hyphen. If not specified, Terraform will autogenerate a name beginning with tf-lb. | string | `` | no |
| allocation_id | The allocation ID of the Elastic IP address. | string | `` | no |
| application | Application (e.g. `cd` or `clouddrove`). | string | `` | no |
| attributes | Additional attributes (e.g. `1`). | list | `<list>` | no |
| delimiter | Delimiter to be used between `organization`, `environment`, `name` and `attributes`. | string | `-` | no |
| deregistration_delay | The amount time for Elastic Load Balancing to wait before changing the state of a deregistering target from draining to unused. The range is 0-3600 seconds. The default value is 300 seconds. | number | `300` | no |
| enable_cross_zone_load_balancing | Indicates whether cross zone load balancing should be enabled in application load balancers. | bool | `false` | no |
| enable_deletion_protection | If true, deletion of the load balancer will be disabled via the AWS API. This will prevent Terraform from deleting the load balancer. Defaults to false. | string | `` | no |
| enable_http2 | Indicates whether HTTP/2 is enabled in application load balancers. | bool | `true` | no |
| environment | Environment (e.g. `prod`, `dev`, `staging`). | string | `` | no |
| health_check_healthy_threshold | The number of consecutive health checks successes required before considering an unhealthy target healthy. | number | `2` | no |
| health_check_interval | The duration in seconds in between health checks. | number | `15` | no |
| health_check_matcher | The HTTP response codes to indicate a healthy check. | string | `200-399` | no |
| health_check_path | The destination for the health check request. | string | `/` | no |
| health_check_timeout | The amount of time to wait in seconds before failing a health check request. | number | `10` | no |
| health_check_unhealthy_threshold | The number of consecutive health check failures required before considering the target unhealthy. | number | `2` | no |
| http_enabled | A boolean flag to enable/disable HTTP listener. | bool | `true` | no |
| http_port | The port on which the load balancer is listening. like 80 or 443. | number | `80` | no |
| https_enabled | A boolean flag to enable/disable HTTPS listener. | bool | `true` | no |
| https_port | The port on which the load balancer is listening. like 80 or 443. | number | - | yes |
| idle_timeout | The time in seconds that the connection is allowed to be idle. | number | `60` | no |
| instance_count | The count of instances. | number | `0` | no |
| internal | If true, the LB will be internal. | string | `` | no |
| ip_address_type | The type of IP addresses used by the subnets for your load balancer. The possible values are ipv4 and dualstack. | string | `ipv4` | no |
| label_order | Label order, e.g. `name`,`application`. | list | `<list>` | no |
| listener_certificate_arn | The ARN of the SSL server certificate. Exactly one certificate is required if the protocol is HTTPS. | string | `` | no |
| listener_protocol | The protocol for connections from clients to the load balancer. Valid values are TCP, HTTP and HTTPS. Defaults to HTTP. | string | `HTTPS` | no |
| listener_ssl_policy | The security policy if using HTTPS externally on the load balancer. [See](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-security-policy-table.html). | string | `ELBSecurityPolicy-2016-08` | no |
| listener_type | The type of routing action. Valid values are forward, redirect, fixed-response, authenticate-cognito and authenticate-oidc. | string | - | yes |
| load_balancer_create_timeout | Timeout value when creating the ALB. | string | `10m` | no |
| load_balancer_delete_timeout | Timeout value when deleting the ALB. | string | `10m` | no |
| load_balancer_type | The type of load balancer to create. Possible values are application or network. The default value is application. | string | `` | no |
| load_balancer_update_timeout | Timeout value when updating the ALB. | string | `10m` | no |
| log_bucket_name | S3 bucket (externally created) for storing load balancer access logs. Required if logging_enabled is true. | string | `` | no |
| name | Name (e.g. `app` or `cluster`). | string | `` | no |
| security_groups | A list of security group IDs to assign to the LB. Only valid for Load Balancers of type application. | list | `<list>` | no |
| subnet_id | The id of the subnet of which to attach to the load balancer. You can specify only one subnet per Availability Zone. | string | `` | no |
| subnets | A list of subnet IDs to attach to the LB. Subnets cannot be updated for Load Balancers of type network. Changing this value will for load balancers of type network will force a recreation of the resource. | list | `<list>` | no |
| tags | Additional tags (e.g. map(`BusinessUnit`,`XYZ`). | map | `<map>` | no |
| target_group_port | The port on which targets receive traffic, unless overridden when registering a specific target. | string | `` | no |
| target_group_protocol | The protocol to use for routing traffic to the targets. | string | `` | no |
| target_id | The ID of the target. This is the Instance ID for an instance, or the container ID for an ECS container. If the target type is ip, specify an IP address. | list | - | yes |
| target_type | The type of target that you must specify when registering targets with this target group. The possible values are instance (targets are specified by instance ID) or ip (targets are specified by IP address) or lambda (targets are specified by lambda arn). The default is instance. | string | `instance` | no |
| vpc_id | The identifier of the VPC in which to create the target group. | string | `` | no |

## Outputs

| Name | Description |
|------|-------------|
| arn | The ARN of the ALB. |
| arn_suffix | The ARN suffix of the ALB. |
| dns_name | DNS name of ALB. |
| http_listener_arn | The ARN of the HTTP listener. |
| https_listener_arn | The ARN of the HTTPS listener. |
| listener_arns | A list of all the listener ARNs. |
| main_target_group_arn | The main target group ARN. |
| name | The ARN suffix of the ALB. |
| tags | A mapping of tags to assign to the resource. |
| zone_id | The ID of the zone which ALB is provisioned. |



## 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
go test -run Test
```



## Feedback
If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/terraform-aws-alb/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-alb)!

## About us

At [CloudDrove][website], we offer expert guidance, implementation support and services to help organisations accelerate their journey to the cloud. Our services include docker and container orchestration, cloud migration and adoption, infrastructure automation, application modernisation and remediation, and performance engineering.

<p align="center">We are <b> The Cloud Experts!</b></p>
<hr />
<p align="center">We ❤️ <a href="https://github.com/clouddrove">Open Source</a> and you can check out <a href="https://github.com/clouddrove">our other modules</a> to get help with your new Cloud ideas.</p>

[website]: https://clouddrove.com
[github]: https://github.com/clouddrove
[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=
58 changes: 58 additions & 0 deletions README.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
#
# This is the canonical configuration for the `README.md`
# Run `make readme` to rebuild the `README.md`
#

# Name of this project
name : Terraform AWS ALB

# License of this project
license: "MIT"

# Canonical GitHub repo
github_repo: clouddrove/terraform-aws-alb

# Badges to display
badges:
- name: "Terraform"
image: "https://img.shields.io/badge/Terraform-v0.12-green"
url: "https://www.terraform.io"
- name: "Licence"
image: "https://img.shields.io/badge/License-MIT-blue.svg"
url: "LICENSE.md"

# description of this project
description: |-
This terraform module is used to create ALB on AWS.
# extra content
include:
- "terraform.md"

# How to use this project
usage : |-
### Simple Example
Here is an example of how you can use this module in your inventory structure:
```hcl
module "alb" {
source = "git::https://github.com/clouddrove/terraform-aws-alb.git"
name = "alb"
application = "clouddrove"
environment = "test"
label_order = ["environment", "name", "application"]
internal = false
load_balancer_type = "application"
instance_count = 2
security_groups = ["sg-xxxxxxx"]
subnets = "subnet-xxxxxxx"
enable_deletion_protection = false
target_id = "i-xxxxxxxxxx"
vpc_id = "vpc-xxxxxxxxx"
target_group_protocol = "HTTP"
target_group_port = 80
listener_certificate_arn = "arn:aws:acm:eu-west-1:xxxxxxxxxxxx:certificate/xxxxxx-xxxx-xxxxx-xxxx"
https_enabled = true
http_enabled = true
}
```
Loading

0 comments on commit 14de74b

Please sign in to comment.