Skip to content

Commit

Permalink
Merge pull request #1 from fyde/big-bang
Browse files Browse the repository at this point in the history
Add AWS ASG module
  • Loading branch information
GMartinez-Sisti authored Aug 11, 2020
2 parents c8348a7 + 1557e05 commit b56089d
Show file tree
Hide file tree
Showing 11 changed files with 559 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.terraform
terraform.tfstate
*.tfstate*
terraform.tfvars
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
repos:
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.31.0
hooks:
- id: terraform_fmt
- id: terraform_validate
- id: terraform_docs_replace
- id: terraform_tflint
- id: terraform_tfsec
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Change Log

## v1.0.0

- [aws-asg] Initial release
57 changes: 55 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,55 @@
# fyde-terraform
Terraform modules for Fyde products
# Fyde - Terraform modules

![Fyde](https://raw.githubusercontent.com/fyde/docs/master/imgs/fyde-logo.png)

Website: <https://fyde.com>

Documentation: <https://fyde.github.io/docs>

## Fyde Access Proxy

### AWS - Auto Scaling Group

Usage example:

```yaml
module "fyde-access-proxy" {
source = "git::git@github.com:fyde/terraform-modules.git//modules/aws-asg?ref=v1.0.0"

# Fyde Access Proxy
fyde_access_proxy_public_port = 443
fyde_access_proxy_token = "replace_with_token"

# AWS
aws_region = "us-east-1"

# Network Load Balancing
nlb_subnets = ["subnet-public-1", "subnet-public-2", "subnet-public-3"]

# Auto Scaling Group
asg_desired_capacity = 3
asg_min_size = 3
asg_max_size = 3
asg_subnets = ["subnet-private-1", "subnet-private-2", "subnet-private-3"]

# Launch Configuration
launch_cfg_instance_type = "t2.small"
launch_cfg_key_pair_name = "key_pair_name"
}

output "Network_Load_Balancer_DNS_Name" {
value = module.fyde-access-proxy.Network_Load_Balancer_DNS_Name
}

output "Security_Group_for_Resources" {
value = module.fyde-access-proxy.Security_Group_for_Resources
}
```

Check all the available variables [here](modules/aws-asg/README.md)

## Misc

- This repository has [pre-commit](https://github.com/antonbabenko/pre-commit-terraform) configured
- Test all the pre-commit hooks with `pre-commit run -a`
- Test branch with `git::git@github.com:fyde/terraform-modules.git//modules/aws-asg?ref=<branch-name>`
40 changes: 40 additions & 0 deletions modules/aws-asg/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## Requirements

| Name | Version |
|------|---------|
| terraform | ~> 0.12 |
| aws | ~> 2 |
| template | ~> 2 |

## Providers

| Name | Version |
|------|---------|
| aws | ~> 2 |
| null | n/a |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| asg\_desired\_capacity | The number of Amazon EC2 instances that should be running in the auto scaling group | `number` | `3` | no |
| asg\_max\_size | The minimum size of the auto scaling group | `number` | `3` | no |
| asg\_min\_size | The maximum size of the auto scaling group | `number` | `3` | no |
| asg\_notification\_arn\_topic | Optional ARN topic to get Auto Scaling Group events | `string` | `""` | no |
| asg\_subnets | A list of subnet IDs to launch resources in. Use Private Subnets with NAT Gateway configured or Public Subnets | `list` | n/a | yes |
| aws\_region | AWS Region | `string` | n/a | yes |
| fyde\_access\_proxy\_public\_port | Public port for this proxy (must match the value configured in the console for this proxy) | `number` | `443` | no |
| fyde\_access\_proxy\_token | Fyde Access Proxy Token for this proxy (obtained from the console after proxy creation) | `any` | n/a | yes |
| launch\_cfg\_associate\_public\_ip\_address | Associate a public ip address with an instance in a VPC | `bool` | `false` | no |
| launch\_cfg\_instance\_type | The type of instance to use (t2.micro, t2.small, t2.medium, etc) | `string` | `"t2.small"` | no |
| launch\_cfg\_key\_pair\_name | The name of the key pair to use | `string` | n/a | yes |
| module\_version | Terraform module version | `string` | `"v1.0.0"` | no |
| nlb\_enable\_cross\_zone\_load\_balancing | Configure cross zone load balancing for the NLB | `bool` | `false` | no |
| nlb\_subnets | A list of public subnet IDs to attach to the LB. Use Public Subnets only | `list(string)` | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| Network\_Load\_Balancer\_DNS\_Name | Update the Fyde Access Proxy in the Console with this DNS name |
| Security\_Group\_for\_Resources | Use this group to allow Fyde Access Proxy access to internal resources |
9 changes: 9 additions & 0 deletions modules/aws-asg/data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# Data
#

data "aws_caller_identity" "current" {}

data "aws_subnet" "vpc_from_first_subnet" {
id = var.nlb_subnets[0]
}
24 changes: 24 additions & 0 deletions modules/aws-asg/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Locals
#

locals {

common_tags_map = {
application = "fyde-access-proxy"
"module_version" = var.module_version
"disclaimer" = "Created by terraform"
}

common_tags_asg = null_resource.tags_as_list_of_maps.*.triggers
}

resource "null_resource" "tags_as_list_of_maps" {
count = length(keys(local.common_tags_map))

triggers = {
"key" = keys(local.common_tags_map)[count.index]
"value" = values(local.common_tags_map)[count.index]
"propagate_at_launch" = true
}
}
Loading

0 comments on commit b56089d

Please sign in to comment.