diff --git a/.github/workflows/readme.yml b/.github/workflows/readme.yml
new file mode 100644
index 0000000..3646f9f
--- /dev/null
+++ b/.github/workflows/readme.yml
@@ -0,0 +1,54 @@
+name: 'Create README.md file'
+on:
+ push:
+ branches:
+ - master
+
+jobs:
+ readme-create:
+ name: 'readme-create'
+ runs-on: ubuntu-latest
+ steps:
+ - name: 'Checkout'
+ uses: actions/checkout@master
+
+ - name: Set up Python 3.7.
+ uses: actions/setup-python@v2
+ with:
+ python-version: '3.x'
+
+ - name: 'create readme'
+ uses: 'clouddrove/github-actions@v4.0'
+ with:
+ actions_subcommand: 'readme'
+ github_token: '${{ secrets.GITHUB}}'
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
+
+
+ - name: pre-commit check errors
+ uses: pre-commit/action@v2.0.0
+ continue-on-error: true
+
+ - name: pre-commit fix erros
+ uses: pre-commit/action@v2.0.0
+ continue-on-error: true
+
+ - name: 'push readme'
+ uses: 'clouddrove/github-actions@v4.0'
+ continue-on-error: true
+ with:
+ actions_subcommand: 'push'
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
+
+ - name: 'Slack Notification'
+ uses: clouddrove/action-slack@v2
+ with:
+ status: ${{ job.status }}
+ fields: repo,author
+ author_name: 'CloudDrove'
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
+ SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
+ if: always()
\ No newline at end of file
diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml
index 1480640..86f5230 100644
--- a/.github/workflows/terraform.yml
+++ b/.github/workflows/terraform.yml
@@ -1,79 +1,90 @@
name: 'Terraform GitHub Actions'
on:
- - pull_request
+ pull_request:
+ branches:
+ - master
jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
steps:
-
- name: 'Checkout'
uses: actions/checkout@master
+ - name: Configure AWS Credentials
+ uses: clouddrove/configure-aws-credentials@v1
+ with:
+ aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY }}
+ aws-secret-access-key: ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }}
+ aws-region: us-east-2
+
- name: 'Terraform Format'
- uses: clouddrove/github-actions@v2.0
+ uses: 'clouddrove/github-actions@v4.0'
with:
actions_subcommand: 'fmt'
- - name: 'ALB Terraform Init'
- uses: clouddrove/github-actions@v2.0
+ - name: 'Terraform init for alb'
+ uses: 'clouddrove/github-actions@v4.0'
with:
actions_subcommand: 'init'
tf_actions_working_dir: ./_example/alb
- - name: Configure AWS Credentials
- uses: clouddrove/configure-aws-credentials@v1
+ - name: 'Terraform validate for alb'
+ uses: 'clouddrove/github-actions@v4.0'
with:
- aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
- aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- aws-region: us-east-2
+ actions_subcommand: 'validate'
+ tf_actions_working_dir: ./_example/alb
- - name: 'ALB Terraform Plan'
- uses: clouddrove/github-actions@v2.0
+ - name: 'Terraform plan for alb'
+ uses: 'clouddrove/github-actions@v4.0'
with:
actions_subcommand: 'plan'
tf_actions_working_dir: ./_example/alb
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- - name: 'ALB Terratest'
- uses: clouddrove/github-actions@v2.0
+ - name: 'Terraform init for clb'
+ uses: 'clouddrove/github-actions@v4.0'
with:
- actions_subcommand: 'terratest'
- tf_actions_working_dir: ./_test/alb
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ actions_subcommand: 'init'
+ tf_actions_working_dir: ./_example/clb
- - name: 'CLB Terraform Init'
- uses: clouddrove/github-actions@v2.0
+ - name: 'Terraform validate for clb'
+ uses: 'clouddrove/github-actions@v4.0'
with:
- actions_subcommand: 'init'
+ actions_subcommand: 'validate'
tf_actions_working_dir: ./_example/clb
- - name: 'CLB Terraform Plan'
- uses: clouddrove/github-actions@v2.0
+ - name: 'Terraform plan for clb'
+ uses: 'clouddrove/github-actions@v4.0'
with:
actions_subcommand: 'plan'
tf_actions_working_dir: ./_example/clb
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- - name: 'CLB Terratest'
- uses: clouddrove/github-actions@v2.0
+ - name: 'Terraform init for nlb'
+ uses: 'clouddrove/github-actions@v4.0'
with:
- actions_subcommand: 'terratest'
- tf_actions_working_dir: ./_test/clb
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ actions_subcommand: 'init'
+ tf_actions_working_dir: ./_example/nlb
+
+ - name: 'Terraform validate for nlb'
+ uses: 'clouddrove/github-actions@v4.0'
+ with:
+ actions_subcommand: 'validate'
+ tf_actions_working_dir: ./_example/nlb
+
+ - name: 'Terraform plan for nlb'
+ uses: 'clouddrove/github-actions@v4.0'
+ with:
+ actions_subcommand: 'plan'
+ tf_actions_working_dir: ./_example/nlb
- name: 'Slack Notification'
uses: clouddrove/action-slack@v2
with:
status: ${{ job.status }}
fields: repo,author
- author_name: 'Clouddrove'
+ author_name: 'CloudDrove'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
- SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} # required
+ SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
if: always()
\ No newline at end of file
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index aa6e42c..9a789cb 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,13 +1,13 @@
repos:
- repo: git://github.com/antonbabenko/pre-commit-terraform
- rev: v1.12.0
+ rev: v1.43.0
hooks:
- id: terraform_fmt
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v2.0.0
+ rev: v3.2.0
hooks:
- id: check-merge-conflict
- - id: trailing-whitespace
- id: check-yaml
- id: check-added-large-files
+ - id: trailing-whitespace
\ No newline at end of file
diff --git a/README.md b/README.md
deleted file mode 100644
index a56f2c7..0000000
--- a/README.md
+++ /dev/null
@@ -1,319 +0,0 @@
-
-
-
-
-
-
- Terraform AWS ALB
-
-
-
- This terraform module is used to create ALB on AWS.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-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 Bigger problems are always solved by breaking them into smaller manageable problems. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller connected yet manageable pieces 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).
-
-
-Here are examples of how you can use this module in your inventory structure:
-### ALB Example
-```hcl
- module "alb" {
- source = "git::https://github.com/clouddrove/terraform-aws-alb.git?ref=tags/0.12.7"
- name = "alb"
- application = "clouddrove"
- environment = "test"
- label_order = ["environment", "application", "name"]
- internal = false
- load_balancer_type = "application"
- instance_count = module.ec2.instance_count
- security_groups = [module.ssh.security_group_ids, module.http-https.security_group_ids]
- subnets = module.public_subnets.public_subnet_id
- enable_deletion_protection = false
- target_id = module.ec2.instance_id
- vpc_id = module.vpc.vpc_id
- https_enabled = true
- http_enabled = true
- https_port = 443
- listener_type = "forward"
- listener_certificate_arn = "arn:aws:acm:eu-west-1:924144197303:certificate/0418d2ba-91f7-4196-991b-28b5c60cd4cf"
- target_group_port = 80
- target_groups = [
- {
- backend_protocol = "HTTP"
- backend_port = 80
- target_type = "instance"
- deregistration_delay = 300
- health_check = {
- enabled = true
- interval = 30
- path = "/"
- port = "traffic-port"
- healthy_threshold = 3
- unhealthy_threshold = 3
- timeout = 10
- protocol = "HTTP"
- matcher = "200-399"
- }
- }
- ]
- }
-```
-
-### NLB Example
-```hcl
- module "alb" {
- source = "git::https://github.com/clouddrove/terraform-aws-alb.git?ref=tags/0.12.7"
- name = "nlb"
- application = "clouddrove"
- environment = "test"
- label_order = ["environment", "application", "name"]
- internal = false
- load_balancer_type = "application"
- instance_count = module.ec2.instance_count
- subnets = module.public_subnets.public_subnet_id
- enable_deletion_protection = false
- target_id = module.ec2.instance_id
- vpc_id = module.vpc.vpc_id
- http_tcp_listeners = [
- {
- port = 80
- protocol = "TCP"
- target_group_index = 0
- },
- ]
-
- https_listeners = [
- {
- port = 443
- protocol = "TLS"
- certificate_arn = "arn:aws:acm:eu-west-1:924144197303:certificate/0418d2ba-91f7-4196-991b-28b5c60cd4cf"
- target_group_index = 1
- },
- ]
-
- target_groups = [
- {
- backend_protocol = "TCP"
- backend_port = 80
- target_type = "instance"
- },
- {
- backend_protocol = "TLS"
- backend_port = 443
- target_type = "instance"
- },
- ]
- }
-```
-
-### CLB Example
-```hcl
- module "clb" {
- source = "git::https://github.com/clouddrove/terraform-aws-alb.git?ref=tags/0.12.7"
-
- name = "clb"
- application = "clouddrove"
- environment = "test"
- label_order = ["environment", "application", "name"]
-
- load_balancer_type = "classic"
- internal = false
- target_id = module.ec2.instance_id
- security_groups = [module.ssh.security_group_ids, module.http_https.security_group_ids]
- subnets = module.public_subnets.public_subnet_id
-
- listeners = [
- {
- lb_port = 22000
- lb_protocol = "TCP"
- instance_port = 22000
- instance_protocol = "TCP"
- ssl_certificate_id = null
- },
- {
- lb_port = 4444
- lb_protocol = "TCP"
- instance_port = 4444
- instance_protocol = "TCP"
- ssl_certificate_id = null
- }
- ]
-
- health_check_target = "TCP:4444"
- health_check_timeout = 10
- health_check_interval = 30
- health_check_unhealthy_threshold = 5
- health_check_healthy_threshold = 5
-}
-```
-
-
-
-
-
-
-## Inputs
-
-| Name | Description | Type | Default | Required |
-|------|-------------|:----:|:-----:|:-----:|
-| access\_logs | Access logs Enable or Disable. | bool | `"false"` | 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 | `` | no |
-| availability\_zones | The AZ's to serve traffic in. | list(map(string)) | `` | no |
-| clb\_enable | If true, create clb. | bool | `"false"` | no |
-| connection\_draining | TBoolean to enable connection draining. Default: false. | bool | `"false"` | no |
-| connection\_draining\_timeout | The time after which connection draining is aborted in seconds. | number | `"300"` | no |
-| delimiter | Delimiter to be used between `organization`, `environment`, `name` and `attributes`. | string | `"-"` | no |
-| drop\_invalid\_header\_fields | Indicates whether HTTP headers with header fields that are not valid are removed by the load balancer \(true\) or routed to targets \(false\). The default is false. Elastic Load Balancing requires that message header names contain only alphanumeric characters and hyphens. Only valid for Load Balancers of type application. | bool | `"false"` | no |
-| enable | If true, create alb. | bool | `"false"` | no |
-| enable\_connection\_draining | Whether or not to enable connection draining \("true" or "false"\). | bool | `"false"` | 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. | bool | `"false"` | 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 successful health checks before an instance is put into service. | number | `"10"` | no |
-| health\_check\_interval | The time between health check attempts in seconds. | number | `"30"` | no |
-| health\_check\_target | The target to use for health checks. | string | `"TCP:80"` | no |
-| health\_check\_timeout | The time after which a health check is considered failed in seconds. | number | `"5"` | no |
-| health\_check\_unhealthy\_threshold | The number of failed health checks before an instance is taken out of service. | number | `"2"` | no |
-| http\_enabled | A boolean flag to enable/disable HTTP listener. | bool | `"true"` | no |
-| http\_listener\_type | The type of routing action. Valid values are forward, redirect, fixed-response, authenticate-cognito and authenticate-oidc. | string | `"redirect"` | no |
-| http\_port | The port on which the load balancer is listening. like 80 or 443. | number | `"80"` | no |
-| http\_tcp\_listeners | A list of maps describing the HTTP listeners for this ALB. Required key/values: port, protocol. Optional key/values: target\_group\_index \(defaults to 0\) | list(map(string)) | `` | no |
-| https\_enabled | A boolean flag to enable/disable HTTPS listener. | bool | `"true"` | no |
-| https\_listeners | A list of maps describing the HTTPS listeners for this ALB. Required key/values: port, certificate\_arn. Optional key/values: ssl\_policy \(defaults to ELBSecurityPolicy-2016-08\), target\_group\_index \(defaults to 0\) | list(map(string)) | `` | no |
-| https\_port | The port on which the load balancer is listening. like 80 or 443. | number | `"443"` | no |
-| 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 | `` | 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 | `"forward"` | no |
-| listeners | A list of listener configurations for the ELB. | object | `` | no |
-| 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 |
-| managedby | ManagedBy, eg 'CloudDrove' or 'AnmolNagpal'. | string | `"anmol@clouddrove.com"` | 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 | `` | no |
-| status\_code | The HTTP redirect code. The redirect is either permanent \(HTTP\_301\) or temporary \(HTTP\_302\). | string | `"HTTP_301"` | 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 |
-| subnet\_mapping | A list of subnet mapping blocks describing subnets to attach to network load balancer | list(map(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 | `` | no |
-| tags | Additional tags \(e.g. map\(`BusinessUnit`,`XYZ`\). | map | `