-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kamlesh
committed
Aug 12, 2019
0 parents
commit b2f8780
Showing
6 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Anmol Nagpal | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|:----:|:-----:|:-----:| | ||
| attributes | Additional attributes, e.g. `1` | list | `<list>` | no | | ||
| delimiter | Delimiter to be used between `organization`, `name`, `environment` and `attributes` | string | `-` | no | | ||
| enabled | Set to false to prevent the module from creating any resources | string | `true` | no | | ||
| name | Solution name, e.g. `app` | string | - | yes | | ||
| organization | organization, which could be your organization name, e.g. `cp` or `anmolnagpal` | string | - | yes | | ||
| environment | environment, e.g. `prod`, `staging`, `dev`, or `test` | string | - | yes | | ||
| tags | Additional tags (e.g. `map(`BusinessUnit`,`XYZ`) | map | `<map>` | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| attributes | Normalized attributes | | ||
| id | Disambiguated ID | | ||
| name | Normalized name | | ||
| organization | Normalized organization | | ||
| environment | Normalized environment | | ||
| tags | Normalized Tag map | | ||
|
||
## 👬 Contribution | ||
- Open pull request with improvements | ||
- Discuss ideas in issues | ||
|
||
- Reach out with any feedback [![Twitter URL](https://img.shields.io/twitter/url/https/twitter.com/anmol_nagpal.svg?style=social&label=Follow%20%40anmol_nagpal)](https://twitter.com/anmol_nagpal) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module "label" { | ||
source = "../" | ||
name = "label" | ||
application = "clouddrove" | ||
environment = "test" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
## Managed By : CloudDrove | ||
## Copyright @ CloudDrove. All Right Reserved. | ||
|
||
#Module : locals | ||
#Description : Terraform module to create consistent naming for multiple names. | ||
locals { | ||
enabled = "${var.enabled == "true" ? true : false }" | ||
id = "${local.enabled == true ? lower(join(var.delimiter, compact(concat(list(var.environment, var.name), var.attributes)))) : ""}" | ||
name = "${local.enabled == true ? lower(format("%v", var.name)) : ""}" | ||
application = "${local.enabled == true ? lower(format("%v", var.application)) : ""}" | ||
environment = "${local.enabled == true ? lower(format("%v", var.environment)) : ""}" | ||
createdby = "${local.enabled == true ? lower(format("%v", var.createdby)) : ""}" | ||
managedby = "${local.enabled == true ? lower(format("%v", var.managedby)) : ""}" | ||
attributes = "${local.enabled == true ? lower(format("%v", join(var.delimiter, compact(var.attributes)))) : ""}" | ||
|
||
# Merge input tags with our tags. | ||
# Note: `Name` has a special meaning in AWS and we need to disamgiuate it by using the computed `id` | ||
tags = "${ | ||
merge( | ||
map( | ||
"Name", "${local.id}", | ||
"Applicatoin", "${local.application}", | ||
"Environment", "${local.environment}", | ||
"CreatedBy", "${local.createdby}", | ||
"ManagedBy", "${local.managedby}" | ||
), var.tags | ||
) | ||
}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
output "id" { | ||
value = "${local.id}" | ||
description = "Disambiguated ID" | ||
} | ||
|
||
output "name" { | ||
value = "${local.name}" | ||
description = "Normalized name" | ||
} | ||
|
||
output "application" { | ||
value = "${local.application}" | ||
description = "Normalized namespace" | ||
} | ||
|
||
output "environment" { | ||
value = "${local.environment}" | ||
description = "Normalized stage" | ||
} | ||
|
||
output "attributes" { | ||
value = "${local.attributes}" | ||
description = "Normalized attributes" | ||
} | ||
|
||
output "tags" { | ||
value = "${local.tags}" | ||
description = "Normalized Tag map" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
variable "name" { | ||
description = "Solution name, e.g. `app`" | ||
} | ||
|
||
variable "application" { | ||
description = "Application name, e.g. `dw` or `CloudDrove`" | ||
} | ||
|
||
variable "environment" { | ||
description = "Environment, e.g. `prod`, `staging`, `dev`, or `test`" | ||
} | ||
|
||
variable "createdby" { | ||
description = "CreatedBy, eg 'terraform'" | ||
default = "terraform" | ||
} | ||
|
||
variable "managedby" { | ||
description = "ManagedBy, eg 'CloudDrove' or 'AnmolNagpal'" | ||
default = "anmol@clouddrove.com" | ||
} | ||
|
||
variable "enabled" { | ||
description = "Set to false to prevent the module from creating any resources" | ||
default = "true" | ||
} | ||
|
||
variable "delimiter" { | ||
type = "string" | ||
default = "-" | ||
description = "Delimiter to be used between `organization`, `name`, `environment` and `attributes`" | ||
} | ||
|
||
variable "attributes" { | ||
type = "list" | ||
default = [] | ||
description = "Additional attributes, e.g. `1`" | ||
} | ||
|
||
variable "tags" { | ||
type = "map" | ||
default = {} | ||
description = "Additional tags (e.g. `map(`BusinessUnit`,`XYZ`)" | ||
} |