Skip to content

Commit

Permalink
Add travis.yml. Fix typos (cloudposse#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
aknysh committed May 14, 2018
1 parent 80f304d commit fd354b6
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 39 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.tfstate
*.tfstate.backup
**/.terraform
**/.terraform
.idea
*.iml
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
addons:
apt:
packages:
- git
- make
- curl

install:
- make init

script:
- make terraform/install
- make terraform/get-plugins
- make terraform/get-modules
- make terraform/lint
- make terraform/validate
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2018 Cloud Posse, LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ SHELL := /bin/bash
-include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness)

lint:
$(SELF) terraform:install terraform:get-modules terraform:get-plugins terraform:lint terraform:validate
$(SELF) terraform/install terraform/get-modules terraform/get-plugins terraform/lint terraform/validate
45 changes: 24 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
## terraform-terraform-label [![Build Status](https://travis-ci.org/cloudposse/terraform-terraform-label.svg)](https://travis-ci.org/cloudposse/terraform-terraform-label)
<!---
--- This file was automatically generated by the `build-harness`
--- Make changes instead to `.README.md` and rebuild.
--->
## terraform-terraform-label [![Build Status](https://travis-ci.org/cloudposse/terraform-terraform-label.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-terraform-label)

Terraform module designed to generate consistent label names and tags for resources. Use `terraform-terraform-label` to implement a strict naming convention.

#### terraform-terraform-label is a fork of terraform-null-label which uses only the core Terraform provider.

#### `terraform-terraform-label` is a fork of [terraform-null-label](https://github.com/cloudposse/terraform-null-label) which uses only the core Terraform provider.

A label follows the following convention: `{namespace}-{stage}-{name}-{attributes}`. The delimiter (e.g. `-`) is interchangeable.

Expand All @@ -16,7 +13,8 @@ However, if you have multiple different kinds of resources (e.g. instances, secu

All [Cloud Posse modules](https://github.com/cloudposse?utf8=%E2%9C%93&q=tf_&type=&language=) use this module to ensure resources can be instantiated multiple times within an account and without conflict.

-**NOTE:** The `terraform` refers to the primary Terraform provider used in this module.
**NOTE:** The second `terraform` word in `terraform-terraform-label` refers to the primary Terraform provider used in this module.


## Usage

Expand Down Expand Up @@ -127,30 +125,28 @@ resource "aws_instance" "eg_prod_bastion_xyz" {

## Input

<!--------------------------------REQUIRE POSTPROCESSING-------------------------------->
| Name | Default | Description |
|:------|:---------:|:--------------:|
| attributes |[] |Additional attributes (e.g. `policy` or `role`)|
| delimiter |"-" |Delimiter to be used between `name`, `namespace`, `stage`, etc.|
| attributes |[] |Additional attributes, e.g. `1`|
| delimiter |"-" |Delimiter to be used between `namespace`, `name`, `stage` and `attributes`|
| enabled |"true" |Set to false to prevent the module from creating any resources|
| name |__REQUIRED__ |Solution name, e.g. 'app' or 'jenkins'|
| namespace |__REQUIRED__ |Namespace, which could be your organization name, e.g. 'cp' or 'cloudposse'|
| stage |__REQUIRED__ |Stage, e.g. 'prod', 'staging', 'dev', or 'test'|
| name |__REQUIRED__ |Solution name, e.g. 'app'|
| namespace |__REQUIRED__ |Namespace, which could be your organization name, e.g. `cp` or `cloudposse`|
| stage |__REQUIRED__ |Stage, e.g. `prod`, `staging`, `dev`, or `test`|
| tags |{} |Additional tags (e.g. `map('BusinessUnit`,`XYZ`)|

**WARNING** Any tags passed as an input to this module will *override* the tags generated by this module.

## Output

<!--------------------------------REQUIRE POSTPROCESSING-------------------------------->
| Name | Description |
|:------|:------------:|
| attributes | Normalized attributes |
| id | Disambiguated ID |
| name | Normalized name |
| namespace | Normalized namespace |
| stage | Normalized stage |
| tags | 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 | Normalized Tag map |


## Help
Expand Down Expand Up @@ -179,9 +175,10 @@ In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.

**NOTE:** Be sure to merge the latest from "upstream" before making a pull request!


## License

[APACHE 2.0](LICENSE) © 2017 [Cloud Posse, LLC](https://cloudposse.com)
[APACHE 2.0](LICENSE) © 2018 [Cloud Posse, LLC](https://cloudposse.com)

See [LICENSE](LICENSE) for full details.

Expand All @@ -202,20 +199,26 @@ See [LICENSE](LICENSE) for full details.
specific language governing permissions and limitations
under the License.


## About

This project is maintained and funded by [Cloud Posse, LLC][website]. Like it? Please let us know at <hello@cloudposse.com>
`terraform-terraform-label` is maintained and funded by [Cloud Posse, LLC][website].

![Cloud Posse](https://cloudposse.com/logo-300x69.png)

Like it? Please let us know at <hello@cloudposse.com>

We love [Open Source Software](https://github.com/cloudposse/)!

See [our other projects][community]
or [hire us][hire] to help build your next cloud-platform.
or [hire us][hire] to help build your next cloud platform.

[website]: http://cloudposse.com/
[website]: https://cloudposse.com/
[community]: https://github.com/cloudposse/
[hire]: http://cloudposse.com/contact/
[hire]: https://cloudposse.com/contact/


### Contributors
## Contributors

|[![Jamie Nelson][bitflight_img]][bitflight_web]<br/>[Jamie Nelson][bitflight_web] |[![Erik Osterman][erik_img]][erik_web]<br/>[Erik Osterman][erik_web] |[![Igor Rodionov][igor_img]][igor_web]<br/>[Igor Rodionov][igor_img] |[![Konstantin B][konstantin_img]][konstantin_web]<br/>[Konstantin B][konstantin_web] |[![Andriy Knysh][andriy_img]][andriy_web]<br/>[Andriy Knysh][andriy_web] |[![Sergey Vasilyev][sergey_img]][sergey_web]<br/>[Sergey Vasilyev][sergey_web] |
|---|---|---|---|---|---|
Expand Down
12 changes: 7 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
locals {
enabled = "${var.enabled == "true" ? true : false }"
id = "${local.enabled ? lower(join(var.delimiter, compact(concat(list(var.namespace, var.stage, var.name), var.attributes)))) : ""}"
name = "${local.enabled ? lower(format("%v", var.name)) : ""}"
namespace = "${local.enabled ? lower(format("%v", var.namespace)) : ""}"
stage = "${local.enabled ? lower(format("%v", var.stage)) : ""}"
attributes = "${local.enabled ? lower(format("%v", join(var.delimiter, compact(var.attributes)))) : ""}"
id = "${local.enabled == "true" ? lower(join(var.delimiter, compact(concat(list(var.namespace, var.stage, var.name), var.attributes)))) : ""}"
name = "${local.enabled == "true" ? lower(format("%v", var.name)) : ""}"
namespace = "${local.enabled == "true" ? lower(format("%v", var.namespace)) : ""}"
stage = "${local.enabled == "true" ? lower(format("%v", var.stage)) : ""}"
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(
Expand Down
5 changes: 1 addition & 4 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ output "attributes" {
description = "Normalized 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`
output "tags" {
value = "${local.tags}"

value = "${local.tags}"
description = "Normalized Tag map"
}
12 changes: 6 additions & 6 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
variable "namespace" {
description = "Namespace, which could be your organization name, e.g. 'cp' or 'cloudposse'"
description = "Namespace, which could be your organization name, e.g. `cp` or `cloudposse`"
}

variable "stage" {
description = "Stage, e.g. 'prod', 'staging', 'dev', or 'test'"
description = "Stage, e.g. `prod`, `staging`, `dev`, or `test`"
}

variable "name" {
description = "Solution name, e.g. 'app' or 'jenkins'"
description = "Solution name, e.g. `app`"
}

variable "enabled" {
Expand All @@ -18,17 +18,17 @@ variable "enabled" {
variable "delimiter" {
type = "string"
default = "-"
description = "Delimiter to be used between `name`, `namespace`, `stage`, etc."
description = "Delimiter to be used between `namespace`, `name`, `stage` and `attributes`"
}

variable "attributes" {
type = "list"
default = []
description = "Additional attributes (e.g. `policy` or `role`)"
description = "Additional attributes, e.g. `1`"
}

variable "tags" {
type = "map"
default = {}
description = "Additional tags (e.g. `map('BusinessUnit`,`XYZ`)"
description = "Additional tags (e.g. `map(`BusinessUnit`,`XYZ`)"
}

0 comments on commit fd354b6

Please sign in to comment.