diff --git a/.README.md b/.README.md deleted file mode 100644 index fe202f3..0000000 --- a/.README.md +++ /dev/null @@ -1,146 +0,0 @@ -## {{ (datasource "git").name }} [![Build Status](https://travis-ci.org/cloudposse/terraform-null-label.svg)](https://travis-ci.org/cloudposse/terraform-null-label) -{{ (datasource "section").warning }} - -Terraform module designed to generate consistent label names and tags for resources. Use `terraform-null-label` to implement a strict naming convention. - -A label follows the following convention: `{namespace}-{stage}-{name}-{attributes}`. The delimiter (e.g. `-`) is interchangeable. - -It's recommended to use one `terraform-null-label` module for every unique resource of a given resource type. -For example, if you have 10 instances, there should be 10 different labels. -However, if you have multiple different kinds of resources (e.g. instances, security groups, file systems, and elastic ips), then they can all share the same label assuming they are logically related. - -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 `null` refers to the primary Terraform [provider](https://www.terraform.io/docs/providers/null/index.html) used in this module. - -## Usage - -### Simple Example - -Include this repository as a module in your existing terraform code: - -```hcl -module "eg_prod_bastion_label" { - source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=master" - namespace = "eg" - stage = "prod" - name = "bastion" - attributes = ["public"] - delimiter = "-" - tags = "${map("BusinessUnit", "XYZ", "Snapshot", "true")}" -} -``` - -This will create an `id` with the value of `eg-prod-bastion-public`. - -Now reference the label when creating an instance (for example): - -```hcl -resource "aws_instance" "eg_prod_bastion_public" { - instance_type = "t1.micro" - tags = "${module.eg_prod_bastion_label.tags}" -} -``` - -Or define a security group: - -```hcl -resource "aws_security_group" "eg_prod_bastion_public" { - vpc_id = "${var.vpc_id}" - name = "${module.eg_prod_bastion_label.id}" - tags = "${module.eg_prod_bastion_label.tags}" - egress { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - } -} -``` - - -### Advanced Example - -Here is a more complex example with two instances using two different labels. Note how efficiently the tags are defined for both the instance and the security group. - -```hcl -module "eg_prod_bastion_abc_label" { - source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=master" - namespace = "eg" - stage = "prod" - name = "bastion" - attributes = ["abc"] - delimiter = "-" - tags = "${map("BusinessUnit", "ABC")}" -} - -resource "aws_security_group" "eg_prod_bastion_abc" { - name = "${module.eg_prod_bastion_abc_label.id}" - tags = "${module.eg_prod_bastion_abc_label.tags}" - ingress { - from_port = 22 - to_port = 22 - protocol = "tcp" - cidr_blocks = ["0.0.0.0/0"] - } -} - -resource "aws_instance" "eg_prod_bastion_abc" { - instance_type = "t1.micro" - tags = "${module.eg_prod_bastion_abc_label.tags}" - vpc_security_group_ids = ["${aws_security_group.eg_prod_bastion_abc.id"}] -} - -module "eg_prod_bastion_xyz_label" { - source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=master" - namespace = "eg" - stage = "prod" - name = "bastion" - attributes = ["xyz"] - delimiter = "-" - tags = "${map("BusinessUnit", "XYZ")}" -} - -resource "aws_security_group" "eg_prod_bastion_xyz" { - name = "module.eg_prod_bastion_xyz_label.id" - tags = "${module.eg_prod_bastion_xyz_label.tags}" - ingress { - from_port = 22 - to_port = 22 - protocol = "tcp" - cidr_blocks = ["0.0.0.0/0"] - } -} - -resource "aws_instance" "eg_prod_bastion_xyz" { - instance_type = "t1.micro" - tags = "${module.eg_prod_bastion_xyz_label.tags}" - vpc_security_group_ids = ["${aws_security_group.eg_prod_bastion_xyz.id}"] -} -``` - -{{ (datasource "terraform").input }} - -**WARNING** Any tags passed as an input to this module will *override* the tags generated by this module. - -{{ (datasource "terraform").output }} - -{{ (datasource "section").help }} - -{{ (datasource "section").contributing }} - -{{ (datasource "license").apache2 }} - -{{ (datasource "section").about }} - -### Contributors - -| -{{- (datasource "contributor").erik }} | -{{- (datasource "contributor").igor }} | -{{- (datasource "contributor").konstantin }} | -{{- (datasource "contributor").andrew }} | -{{- (datasource "contributor").sergey }} | -|---|---|---|---|---| - -{{ (datasource "contributor")._links }} diff --git a/Makefile b/Makefile index d002c7d..655f630 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,10 @@ SHELL := /bin/bash +# List of targets the `readme` target should call before generating the readme +export README_DEPS ?= docs/targets.md docs/terraform.md + -include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness) +## Lint terraform code 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 \ No newline at end of file diff --git a/README.md b/README.md index dc89d37..a16906f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,9 @@ -## terraform-null-label [![Build Status](https://travis-ci.org/cloudposse/terraform-null-label.svg)](https://travis-ci.org/cloudposse/terraform-null-label) + + +[![Cloud Posse](https://cloudposse.com/logo-300x69.png)](https://cloudposse.com) + +# terraform-null-label [![Build Status](https://travis-ci.org/cloudposse/terraform-null-label.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-null-label-cloudtrail) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-null-label.svg)](https://travis-ci.org/cloudposse/terraform-null-label-cloudtrail/releases) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) + Terraform module designed to generate consistent label names and tags for resources. Use `terraform-null-label` to implement a strict naming convention. @@ -13,6 +18,16 @@ All [Cloud Posse modules](https://github.com/cloudposse?utf8=%E2%9C%93&q=terrafo **NOTE:** The `null` refers to the primary Terraform [provider](https://www.terraform.io/docs/providers/null/index.html) used in this module. +--- + +This project is part of our comprehensive ["SweetOps"](https://docs.cloudposse.com) approach towards DevOps. + + +It's 100% Open Source and licensed under the [APACHE2](LICENSE). + + + + ## Usage ### Simple Example @@ -200,46 +215,85 @@ resource "aws_autoscaling_group" "default" { id = "${aws_launch_template.default.id}" version = "$$Latest" } - + # terraform-null-label example used here: Set tags on ASG and EC2 Servers tags = ["${module.label.tags_as_list_of_maps}"] } ``` -## Input -| Name | Default | Description | -|:------|:---------:|:--------------:| -| attributes |[] |Additional attributes (e.g. `policy` or `role`)| -| delimiter |"-" |Delimiter to be used between `name`, `namespace`, `stage`, etc.| -| 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'| -| tags |{} |Additional tags (e.g. `map('BusinessUnit`,`XYZ`)| -| additional_tag_map | {} | additional tags that get appended to each map in the list of maps, for the output `tags_as_list_of_maps` | -**WARNING** Any tags passed as an input to this module will *override* the tags generated by this module. -## Output -| Name | Description | -|:------|:------------:| -| attributes | Normalized attributes | -| id | Disambiguated ID | -| name | Normalized name | -| namespace | Normalized namespace | -| stage | Normalized stage | -| tags | Normalized Tag map | +## Makefile Targets +``` +Available targets: + + help This help screen + help/all Display help for all targets + lint Lint terraform code + +``` + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|:----:|:-----:|:-----:| +| additional_tag_map | Additional tags for appending to each tag map. | map | `` | no | +| attributes | Additional attributes (e.g. `policy` or `role`) | list | `` | no | +| delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | no | +| enabled | Set to false to prevent the module from creating any resources | string | `true` | no | +| name | Solution name, e.g. 'app' or 'jenkins' | string | - | yes | +| namespace | Namespace, which could be your organization name, e.g. 'cp' or 'cloudposse' | string | - | yes | +| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | string | - | yes | +| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | map | `` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| attributes | Normalized attributes | +| id | Disambiguated ID | +| name | Normalized name | +| namespace | Normalized namespace | +| stage | Normalized stage | +| tags | Normalized Tag map | | tags_as_list_of_maps | Additional tags as a list of maps, which can be used in several AWS resources | + + +## Related Projects + +Check out these related projects. + +- [terraform-terraform-label](https://github.com/cloudposse/terraform-terraform-label) - Terraform Module to define a consistent naming convention by (namespace, stage, name, [attributes]) + + ## Help **Got a question?** -File a GitHub [issue](https://github.com/cloudposse/terraform-null-label/issues), send us an [email](mailto:hello@cloudposse.com) or reach out to us on [Gitter](https://gitter.im/cloudposse/). +File a GitHub [issue](https://github.com/cloudposse/terraform-null-label/issues), send us an [email][email] or join our [Slack Community][slack]. + +## Commerical Support + +Work directly with our team of DevOps experts via email, slack, and video conferencing. + +We provide *commercial support* for all of our [Open Source][github] projects. As a *Dedicated Support* customer, you have access to our team of subject matter experts at a fraction of the cost of a fulltime engineer. + +- **Questions.** We'll use a Shared Slack channel between your team and ours. +- **Troubleshooting.** We'll help you triage why things aren't working. +- **Code Reviews.** We'll review your Pull Requests and provide constructive feedback. +- **Bug Fixes.** We'll rapidly work to fix any bugs in our projects. +- **Build New Terraform Modules.** We'll develop original modules to provision infrastructure. +- **Cloud Architecture.** We'll assist with your cloud strategy and design. +- **Implementation.** We'll provide hands on support to implement our reference architectures. + +## Community Forum + +Get access to our [Open Source Community Forum][slack] on Slack. It's **FREE** to join for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build *sweet* infrastructure. ## Contributing @@ -249,7 +303,7 @@ Please use the [issue tracker](https://github.com/cloudposse/terraform-null-labe ### Developing -If you are interested in being a contributor and want to get involved in developing `terraform-null-label`, we would love to hear from you! Shoot us an [email](mailto:hello@cloudposse.com). +If you are interested in being a contributor and want to get involved in developing this project or [help out](https://github.com/orgs/cloudposse/projects/3) with our other projects, we would love to hear from you! Shoot us an [email](mailto:hello@cloudposse.com). In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. @@ -257,14 +311,18 @@ In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. 2. **Clone** the project to your own machine 3. **Commit** changes to your own branch 4. **Push** your work back up to your fork - 5. Submit a **Pull request** so that we can review your changes + 5. Submit a **Pull Request** so that we can review your changes + +**NOTE:** Be sure to merge the latest changes from "upstream" before making a pull request! + +## Copyright -**NOTE:** Be sure to merge the latest from "upstream" before making a pull request! +Copyright © 2017-2018 [Cloud Posse, LLC](https://cloudposse.com) -## License +## License -[APACHE 2.0](LICENSE) © 2017-2018 [Cloud Posse, LLC](https://cloudposse.com) +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) See [LICENSE](LICENSE) for full details. @@ -276,7 +334,7 @@ See [LICENSE](LICENSE) for full details. "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an @@ -286,47 +344,53 @@ See [LICENSE](LICENSE) for full details. under the License. -## About +## Trademarks -This project is maintained and funded by [Cloud Posse, LLC][website]. Like it? Please let us know at +All other trademarks referenced herein are the property of their respective owners. -![Cloud Posse](https://cloudposse.com/logo-300x69.png) - -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. +## About - [website]: http://cloudposse.com/ - [community]: https://github.com/cloudposse/ - [hire]: http://cloudposse.com/contact/ +This project is maintained and funded by [Cloud Posse, LLC][website]. Like it? Please let us know at +[![Cloud Posse](https://cloudposse.com/logo-300x69.png)](https://cloudposse.com) -## Contributors +We're a [DevOps Professional Services][hire] company based in Los Angeles, CA. We love [Open Source Software](https://github.com/cloudposse/)! -|[![Erik Osterman][erik_img]][erik_web]
[Erik Osterman][erik_web] |[![Igor Rodionov][igor_img]][igor_web]
[Igor Rodionov][igor_img] |[![Konstantin B][konstantin_img]][konstantin_web]
[Konstantin B][konstantin_web] |[![Andriy Knysh][andriy_img]][andriy_web]
[Andriy Knysh][andriy_web] |[![Sergey Vasilyev][sergey_img]][sergey_web]
[Sergey Vasilyev][sergey_web] | [![Jamie Nelson][bitflight_img]][bitflight_web]
[Jamie Nelson][bitflight_web] | -|---|---|---|---|---|---| +We offer paid support on all of our projects. -[andriy_img]: https://avatars0.githubusercontent.com/u/7356997?v=4&u=ed9ce1c9151d552d985bdf5546772e14ef7ab617&s=144 -[andriy_web]: https://github.com/aknysh/ +Check out [our other projects][github], [apply for a job][jobs], or [hire us][hire] to help with your cloud strategy and implementation. -[erik_img]: http://s.gravatar.com/avatar/88c480d4f73b813904e00a5695a454cb?s=144 -[erik_web]: https://github.com/osterman/ + [docs]: https://docs.cloudposse.com/ + [website]: https://cloudposse.com/ + [github]: https://github.com/cloudposse/ + [jobs]: https://cloudposse.com/jobs/ + [hire]: https://cloudposse.com/contact/ + [slack]: https://slack.cloudposse.com/ + [linkedin]: https://www.linkedin.com/company/cloudposse + [twitter]: https://twitter.com/cloudposse/ + [email]: mailto:hello@cloudposse.com -[igor_img]: http://s.gravatar.com/avatar/bc70834d32ed4517568a1feb0b9be7e2?s=144 -[igor_web]: https://github.com/goruha/ -[konstantin_img]: https://avatars1.githubusercontent.com/u/11299538?v=4&u=ed9ce1c9151d552d985bdf5546772e14ef7ab617&s=144 -[konstantin_web]: https://github.com/comeanother/ +### Contributors -[sergey_img]: https://avatars1.githubusercontent.com/u/1134449?v=4&u=ed9ce1c9151d552d985bdf5546772e14ef7ab617&s=144 -[sergey_web]: https://github.com/s2504s/ +| [![Erik Osterman][osterman_avatar]](osterman_homepage)
[Erik Osterman][osterman_homepage] | [![Andriy Knysh][aknysh_avatar]](aknysh_homepage)
[Andriy Knysh][aknysh_homepage] | [![Igor Rodionov][goruha_avatar]](goruha_homepage)
[Igor Rodionov][goruha_homepage] | [![Sergey Vasilyev][s2504s_avatar]](s2504s_homepage)
[Sergey Vasilyev][s2504s_homepage] | [![Michael Pereira][MichaelPereira_avatar]](MichaelPereira_homepage)
[Michael Pereira][MichaelPereira_homepage] | [![Jamie Nelson][Jamie-BitFlight_avatar]](Jamie-BitFlight_homepage)
[Jamie Nelson][Jamie-BitFlight_homepage] | [![Vladimir][SweetOps_avatar]](SweetOps_homepage)
[Vladimir][SweetOps_homepage] | [![Daren Desjardins][darend_avatar]](darend_homepage)
[Daren Desjardins][darend_homepage] | +|---|---|---|---|---|---|---|---| -[valeriy_img]: https://avatars1.githubusercontent.com/u/10601658?v=4&u=ed9ce1c9151d552d985bdf5546772e14ef7ab617&s=144 -[valeriy_web]: https://github.com/drama17/ + [osterman_homepage]: https://github.com/osterman + [osterman_avatar]: http://s.gravatar.com/avatar/88c480d4f73b813904e00a5695a454cb?s=144 + [aknysh_homepage]: https://github.com/aknysh + [aknysh_avatar]: https://avatars0.githubusercontent.com/u/7356997?v=4&u=ed9ce1c9151d552d985bdf5546772e14ef7ab617&s=144 + [goruha_homepage]: https://github.com/goruha + [goruha_avatar]: http://s.gravatar.com/avatar/bc70834d32ed4517568a1feb0b9be7e2?s=144 + [s2504s_homepage]: https://github.com/s2504s + [s2504s_avatar]: https://avatars0.githubusercontent.com/u/1134449?s=460&v=4 + [MichaelPereira_homepage]: https://github.com/MichaelPereira + [MichaelPereira_avatar]: https://avatars2.githubusercontent.com/u/431374?s=460&v=4 + [Jamie-BitFlight_homepage]: https://github.com/Jamie-BitFlight + [Jamie-BitFlight_avatar]: https://avatars2.githubusercontent.com/u/25075504?s=460&v=4 + [SweetOps_homepage]: https://github.com/SweetOps + [SweetOps_avatar]: https://avatars1.githubusercontent.com/u/26582191?s=400&v=4 + [darend_homepage]: https://github.com/darend + [darend_avatar]: https://avatars0.githubusercontent.com/u/1302480?s=460&v=4 -[vladimir_img]: https://avatars1.githubusercontent.com/u/26582191?v=4&u=ed9ce1c9151d552d985bdf5546772e14ef7ab617&s=144 -[vladimir_web]: https://github.com/SweetOps/ -[bitflight_img]: https://avatars0.githubusercontent.com/u/25075504?s=144&u=ac7e53bda3706cb9d51907808574b6d342703b3e&v=4 -[bitflight_web]: https://github.com/Jamie-BitFlight diff --git a/README.yaml b/README.yaml new file mode 100644 index 0000000..bf63c8c --- /dev/null +++ b/README.yaml @@ -0,0 +1,280 @@ +--- +# +# This is the canonical configuration for the `README.md` +# Run `make readme` to rebuild the `README.md` +# + +# Name of this project +name: terraform-null-label + +# Logo for this project +#logo: docs/logo.png + +# License of this project +license: "APACHE2" + +# Canonical GitHub repo +github_repo: cloudposse/terraform-null-label + +# Badges to display +badges: + - name: "Build Status" + image: "https://travis-ci.org/cloudposse/terraform-null-label.svg?branch=master" + url: "https://travis-ci.org/cloudposse/terraform-null-label-cloudtrail" + - name: "Latest Release" + image: "https://img.shields.io/github/release/cloudposse/terraform-null-label.svg" + url: "https://travis-ci.org/cloudposse/terraform-null-label-cloudtrail/releases" + - name: "Slack Community" + image: "https://slack.cloudposse.com/badge.svg" + url: "https://slack.cloudposse.com" + +related: + - name: "terraform-terraform-label" + description: "Terraform Module to define a consistent naming convention by (namespace, stage, name, [attributes])" + url: "https://github.com/cloudposse/terraform-terraform-label" + +# Short description of this project +description: |- + Terraform module designed to generate consistent label names and tags for resources. Use `terraform-null-label` to implement a strict naming convention. + + A label follows the following convention: `{namespace}-{stage}-{name}-{attributes}`. The delimiter (e.g. `-`) is interchangeable. + + It's recommended to use one `terraform-null-label` module for every unique resource of a given resource type. + For example, if you have 10 instances, there should be 10 different labels. + However, if you have multiple different kinds of resources (e.g. instances, security groups, file systems, and elastic ips), then they can all share the same label assuming they are logically related. + + All [Cloud Posse modules](https://github.com/cloudposse?utf8=%E2%9C%93&q=terraform-&type=&language=) use this module to ensure resources can be instantiated multiple times within an account and without conflict. + + **NOTE:** The `null` refers to the primary Terraform [provider](https://www.terraform.io/docs/providers/null/index.html) used in this module. + +# How to use this project +usage: |- + ### Simple Example + + ```hcl + module "eg_prod_bastion_label" { + source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=master" + namespace = "eg" + stage = "prod" + name = "bastion" + attributes = ["public"] + delimiter = "-" + tags = "${map("BusinessUnit", "XYZ", "Snapshot", "true")}" + } + ``` + + This will create an `id` with the value of `eg-prod-bastion-public`. + + Now reference the label when creating an instance: + + ```hcl + resource "aws_instance" "eg_prod_bastion_public" { + instance_type = "t1.micro" + tags = "${module.eg_prod_bastion_label.tags}" + } + ``` + + Or define a security group: + + ```hcl + resource "aws_security_group" "eg_prod_bastion_public" { + vpc_id = "${var.vpc_id}" + name = "${module.eg_prod_bastion_label.id}" + tags = "${module.eg_prod_bastion_label.tags}" + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + } + } + ``` + + + ### Advanced Example + + Here is a more complex example with two instances using two different labels. Note how efficiently the tags are defined for both the instance and the security group. + + ```hcl + module "eg_prod_bastion_abc_label" { + source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=master" + namespace = "eg" + stage = "prod" + name = "bastion" + attributes = ["abc"] + delimiter = "-" + tags = "${map("BusinessUnit", "ABC")}" + } + + resource "aws_security_group" "eg_prod_bastion_abc" { + name = "${module.eg_prod_bastion_abc_label.id}" + tags = "${module.eg_prod_bastion_abc_label.tags}" + ingress { + from_port = 22 + to_port = 22 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + } + + resource "aws_instance" "eg_prod_bastion_abc" { + instance_type = "t1.micro" + tags = "${module.eg_prod_bastion_abc_label.tags}" +   vpc_security_group_ids = ["${aws_security_group.eg_prod_bastion_abc.id}"] + } + + module "eg_prod_bastion_xyz_label" { + source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=master" + namespace = "eg" + stage = "prod" + name = "bastion" + attributes = ["xyz"] + delimiter = "-" + tags = "${map("BusinessUnit", "XYZ")}" + } + + resource "aws_security_group" "eg_prod_bastion_xyz" { + name = "${module.eg_prod_bastion_xyz_label.id}" + tags = "${module.eg_prod_bastion_xyz_label.tags}" + ingress { + from_port = 22 + to_port = 22 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + } + + resource "aws_instance" "eg_prod_bastion_xyz" { + instance_type = "t1.micro" + tags = "${module.eg_prod_bastion_xyz_label.tags}" + vpc_security_group_ids = ["${aws_security_group.eg_prod_bastion_xyz.id}"] + } + ``` + + ### Advanced Example 2 + + Here is a more complex example with an autoscaling group that has a different tagging schema than other resources and requires its tags to be in this format, which this module can generate: + + ```hcl + tags = [ + { + key = Name, + propagate_at_launch = 1, + value = namespace-stage-name + }, + { + key = Namespace, + propagate_at_launch = 1, + value = namespace + }, + { + key = Stage, + propagate_at_launch = 1, + value = stage + } + ] + ``` + + Autoscaling group using propagating tagging below (full example: [autoscalinggroup](examples/autoscalinggroup/main.tf)) + + ```hcl + ################################ + # terraform-null-label example # + ################################ + module "label" { + source = "../../" + namespace = "cp" + stage = "prod" + name = "app" + + tags = { + BusinessUnit = "Finance" + ManagedBy = "Terraform" + } + + additional_tag_map = { + propagate_at_launch = "true" + } + } + + ####################### + # Launch template # + ####################### + resource "aws_launch_template" "default" { + # terraform-null-label example used here: Set template name prefix + name_prefix = "${module.label.id}-" + image_id = "${data.aws_ami.amazon_linux.id}" + instance_type = "t2.micro" + instance_initiated_shutdown_behavior = "terminate" + + vpc_security_group_ids = ["${data.aws_security_group.default.id}"] + + monitoring { + enabled = false + } + # terraform-null-label example used here: Set tags on volumes + tag_specifications { + resource_type = "volume" + tags = "${module.label.tags}" + } + } + + ###################### + # Autoscaling group # + ###################### + resource "aws_autoscaling_group" "default" { + # terraform-null-label example used here: Set ASG name prefix + name_prefix = "${module.label.id}-" + vpc_zone_identifier = ["${data.aws_subnet_ids.all.ids}"] + max_size = "1" + min_size = "1" + desired_capacity = "1" + + launch_template = { + id = "${aws_launch_template.default.id}" + version = "$$Latest" + } + + # terraform-null-label example used here: Set tags on ASG and EC2 Servers + tags = ["${module.label.tags_as_list_of_maps}"] + } + ``` + +include: + - "docs/targets.md" + - "docs/terraform.md" + +# Contributors to this project +contributors: + - name: "Erik Osterman" + homepage: "https://github.com/osterman" + avatar: "http://s.gravatar.com/avatar/88c480d4f73b813904e00a5695a454cb?s=144" + github: "osterman" + - name: "Andriy Knysh" + homepage: "https://github.com/aknysh" + avatar: "https://avatars0.githubusercontent.com/u/7356997?v=4&u=ed9ce1c9151d552d985bdf5546772e14ef7ab617&s=144" + github: "aknysh" + - name: "Igor Rodionov" + homepage: "https://github.com/goruha" + avatar: "http://s.gravatar.com/avatar/bc70834d32ed4517568a1feb0b9be7e2?s=144" + github: "goruha" + - name: "Sergey Vasilyev" + homepage: "https://github.com/s2504s" + avatar: "https://avatars0.githubusercontent.com/u/1134449?s=460&v=4" + github: "s2504s" + - name: "Michael Pereira" + homepage: "https://github.com/MichaelPereira" + avatar: "https://avatars2.githubusercontent.com/u/431374?s=460&v=4" + github: "MichaelPereira" + - name: "Jamie Nelson" + homepage: "https://github.com/Jamie-BitFlight" + avatar: "https://avatars2.githubusercontent.com/u/25075504?s=460&v=4" + github: "Jamie-BitFlight" + - name: "Vladimir" + homepage: "https://github.com/SweetOps" + avatar: "https://avatars1.githubusercontent.com/u/26582191?s=400&v=4" + github: "SweetOps" + - name: "Daren Desjardins" + homepage: "https://github.com/darend" + avatar: "https://avatars0.githubusercontent.com/u/1302480?s=460&v=4" + github: "darend" \ No newline at end of file diff --git a/docs/targets.md b/docs/targets.md new file mode 100644 index 0000000..09c39cd --- /dev/null +++ b/docs/targets.md @@ -0,0 +1,9 @@ +## Makefile Targets +``` +Available targets: + + help This help screen + help/all Display help for all targets + lint Lint terraform code + +``` diff --git a/docs/terraform.md b/docs/terraform.md new file mode 100644 index 0000000..4b43a92 --- /dev/null +++ b/docs/terraform.md @@ -0,0 +1,26 @@ + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|:----:|:-----:|:-----:| +| additional_tag_map | Additional tags for appending to each tag map. | map | `` | no | +| attributes | Additional attributes (e.g. `policy` or `role`) | list | `` | no | +| delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | no | +| enabled | Set to false to prevent the module from creating any resources | string | `true` | no | +| name | Solution name, e.g. 'app' or 'jenkins' | string | - | yes | +| namespace | Namespace, which could be your organization name, e.g. 'cp' or 'cloudposse' | string | - | yes | +| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | string | - | yes | +| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | map | `` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| attributes | Normalized attributes | +| id | Disambiguated ID | +| name | Normalized name | +| namespace | Normalized namespace | +| stage | Normalized stage | +| tags | Normalized Tag map | +| tags_as_list_of_maps | Additional tags as a list of maps, which can be used in several AWS resources | +