Skip to content

Commit

Permalink
make module standard
Browse files Browse the repository at this point in the history
  • Loading branch information
anmolnagpal committed Jun 18, 2020
1 parent ec7c2b3 commit adbcb2d
Show file tree
Hide file tree
Showing 11 changed files with 238 additions and 19 deletions.
9 changes: 5 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
repos:
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.12.0
rev: v1.30.0
hooks:
- id: terraform_fmt
- id: terraform_fmt
- id: terraform_tflint

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.0.0
rev: v3.1.0
hooks:
- id: check-merge-conflict
- id: trailing-whitespace
- id: check-yaml
- id: check-added-large-files
- id: check-added-large-files
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Cloud Drove
Copyright (c) 2020 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
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export GENIE_PATH ?= $(shell 'pwd')/../../../genie
include $(GENIE_PATH)/Makefile
include $(GENIE_PATH)/Makefile
163 changes: 161 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,161 @@
# terraform-aws-efs
EFS Filesystem
<!-- This file was automatically generated by the `geine`. Make all changes to `README.yaml` and run `make readme` to rebuild this file. -->

<p align="center"> <img src="https://user-images.githubusercontent.com/50652676/62349836-882fef80-b51e-11e9-99e3-7b974309c7e3.png" width="100" height="100"></p>


<h1 align="center">
Terraform AWS EFS
</h1>

<p align="center" style="font-size: 1.2rem;">
Terraform module to create or deploy EFS on AWS.
</p>

<p align="center">

<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-efs'>
<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+EFS&url=https://github.com/clouddrove/terraform-aws-efs'>
<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+EFS&url=https://github.com/clouddrove/terraform-aws-efs'>
<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 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.

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


### Simple Example
Here is an example of how you can use this module in your inventory structure:
```hcl
module "efs" {
source = "git::https://github.com/clouddrove/terraform-aws-efs.git?ref=tags/0.12.0"
name = "efs"
application = var.application
environment = var.environment
label_order = var.label_order
creation_token = var.token
region = var.region
availability_zones = ["${var.region}b", "${var.region}c"]
vpc_id = module.vpc.vpc_id
subnets = module.subnets.private_subnet_id
security_groups = ["sg-xxxxxxxxxxxx"]
}
```






## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| application | Application name, e.g. `cd` or `CloudDrove` | string | n/a | yes |
| attributes | Additional attributes \(e.g. `1`\) | list(string) | `<list>` | no |
| availability\_zones | Availability Zone IDs | list(string) | n/a | yes |
| creation\_token | A unique name \(a maximum of 64 characters are allowed\) used as reference when creating the EFS | string | n/a | yes |
| delimiter | Delimiter to be used between `namespace`, `stage`, `name` and `attributes` | string | `"-"` | no |
| efs\_enabled | Set to false to prevent the module from creating any resources | bool | `"true"` | no |
| encrypted | If true, the file system will be encrypted | bool | `"false"` | no |
| environment | Environment, e.g. `prod`, `staging`, `dev`, or `test` | string | n/a | yes |
| label\_order | label order, e.g. `name`,`application` | list | `<list>` | no |
| managedby | ManagedBy, eg 'CloudDrove' or 'AnmolNagpal'. | string | `"anmol@clouddrove.com"` | no |
| mount\_target\_ip\_address | The address \(within the address range of the specified subnet\) at which the file system may be mounted via the mount target | string | `""` | no |
| name | Solution name, e.g. `app` | string | n/a | yes |
| performance\_mode | The file system performance mode. Can be either `generalPurpose` or `maxIO` | string | `"generalPurpose"` | no |
| provisioned\_throughput\_in\_mibps | The throughput, measured in MiB/s, that you want to provision for the file system. Only applicable with `throughput\_mode` set to provisioned | string | `"0"` | no |
| region | AWS Region | string | n/a | yes |
| security\_groups | Security group IDs to allow access to the EFS | list(string) | n/a | yes |
| subnets | Subnet IDs | list(string) | n/a | yes |
| tags | Additional tags \(e.g. `\{ BusinessUnit = "XYZ" \}` | map(string) | `<map>` | no |
| throughput\_mode | Throughput mode for the file system. Defaults to bursting. Valid values: `bursting`, `provisioned`. When using `provisioned`, also set `provisioned\_throughput\_in\_mibps` | string | `"bursting"` | no |
| vpc\_id | VPC ID | string | n/a | yes |
| zone\_id | Route53 DNS zone ID | string | `""` | no |

## Outputs

| Name | Description |
|------|-------------|
| arn | EFS ARN |
| id | EFS ID |
| mount\_target\_ids | List of EFS mount target IDs \(one per Availability Zone\) |
| mount\_target\_ips | List of EFS mount target IPs \(one per Availability Zone\) |
| network\_interface\_ids | List of mount target network interface IDs |




## 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-efs/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-efs)!

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

# Name of this project
name : Terraform AWS EFS

# License of this project
license: "MIT"

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

# 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: |-
Terraform module to create or deploy EFS 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 "efs" {
source = "git::https://github.com/clouddrove/terraform-aws-efs.git?ref=tags/0.12.0"
name = "efs"
application = var.application
environment = var.environment
label_order = var.label_order
creation_token = var.token
region = var.region
availability_zones = ["${var.region}b", "${var.region}c"]
vpc_id = module.vpc.vpc_id
subnets = module.subnets.private_subnet_id
security_groups = ["sg-xxxxxxxxxxxx"]
}
```
8 changes: 4 additions & 4 deletions _example/complete/example.tf → _example/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ provider "aws" {
}

module "vpc" {
source = "git::https://github.com/clouddrove/terraform-aws-vpc.git"
source = "git::https://github.com/clouddrove/terraform-aws-vpc.git?ref=tags/0.12.4"

name = "vpc"
application = var.application
Expand All @@ -14,7 +14,7 @@ module "vpc" {
}

module "subnets" {
source = "git::https://github.com/clouddrove/terraform-aws-subnet.git"
source = "git::https://github.com/clouddrove/terraform-aws-subnet.git?ref=tags/0.12.4"

name = "subnet"
application = var.application
Expand All @@ -30,7 +30,7 @@ module "subnets" {
}

module "efs" {
source = "git::https://github.com/clouddrove/terraform-aws-efs.git"
source = "./.."

name = "efs"
application = var.application
Expand All @@ -42,5 +42,5 @@ module "efs" {
availability_zones = ["${var.region}b", "${var.region}c"]
vpc_id = module.vpc.vpc_id
subnets = module.subnets.private_subnet_id
security_groups = module.vpc.vpc_default_security_group_id
security_groups = [module.vpc.vpc_default_security_group_id]
}
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions _test/efs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestEFS(t *testing.T) {

terraformOptions := &terraform.Options{
// Source path of Terraform directory.
TerraformDir: "../_example/complete",
TerraformDir: "../_example",
Upgrade: true,
}

Expand All @@ -30,5 +30,5 @@ func TestEFS(t *testing.T) {
keyArn := terraform.Output(t, terraformOptions, "efs_arn")

// Verify we're getting back the outputs we expect
assert.Contains(t, keyArn, "arn:aws:elasticfilesystem:us-east-1:866067750630:file-system/")
assert.Contains(t, keyArn, "arn:aws:elasticfilesystem")
}
12 changes: 7 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
#Description : Terraform module to create consistent naming for multiple names.

module "label" {
source = "git::https://github.com/clouddrove/terraform-labels"
name = "label"
application = "clouddrove"
environment = "test"
label_order = ["name", "application", "environment"]
source = "git::https://github.com/clouddrove/terraform-labels.git?ref=tags/0.12.0"
name = var.name
application = var.application
environment = var.environment
label_order = var.label_order
managedby = var.managedby
enabled = var.efs_enabled
}

#Module : EFS
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ variable "label_order" {
description = "label order, e.g. `name`,`application`"
}

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

# Module : EFS
# Description : Terraform EFS module variables.
variable "security_groups" {
Expand Down

0 comments on commit adbcb2d

Please sign in to comment.