From 8353c1ef893cc4d1ca6267e230b3155f15a19832 Mon Sep 17 00:00:00 2001 From: Adam Crews Date: Sun, 5 Jan 2020 21:20:32 -0800 Subject: [PATCH] Use the latest label module to support the environment attribute (#46) --- README.md | 15 ++++++++------- docs/terraform.md | 13 +++++++------ main.tf | 17 +++++++++-------- variables.tf | 31 +++++++++++++++++++------------ 4 files changed, 43 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index d93a320a..6b43c268 100644 --- a/README.md +++ b/README.md @@ -383,11 +383,12 @@ Available targets: | aws_eks_update_kubeconfig_additional_arguments | Additional arguments for `aws eks update-kubeconfig` command, e.g. `--role-arn xxxxxxxxx`. For more info, see https://docs.aws.amazon.com/cli/latest/reference/eks/update-kubeconfig.html | string | `` | no | | configmap_auth_file | Path to `configmap_auth_file` | string | `` | no | | configmap_auth_template_file | Path to `config_auth_template_file` | string | `` | no | -| delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | no | -| enabled | Whether to create the resources. Set to `false` to prevent the module from creating any resources | bool | `true` | no | +| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes` | string | `-` | no | +| enabled | Set to false to prevent the module from creating any resources | bool | `true` | no | | enabled_cluster_log_types | A list of the desired control plane logging to enable. For more information, see https://docs.aws.amazon.com/en_us/eks/latest/userguide/control-plane-logs.html. Possible values [`api`, `audit`, `authenticator`, `controllerManager`, `scheduler`] | list(string) | `` | no | | endpoint_private_access | Indicates whether or not the Amazon EKS private API server endpoint is enabled. Default to AWS EKS resource and it is false | bool | `false` | no | | endpoint_public_access | Indicates whether or not the Amazon EKS public API server endpoint is enabled. Default to AWS EKS resource and it is true | bool | `true` | no | +| environment | Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT' | string | `` | no | | external_packages_install_path | Path to install external packages, e.g. AWS CLI and `kubectl`. Used when the module is provisioned on workstations where the external packages are not installed by default, e.g. Terraform Cloud workers | string | `` | no | | install_aws_cli | Set to `true` to install AWS CLI if the module is provisioned on workstations where AWS CLI is not installed by default, e.g. Terraform Cloud workers | bool | `false` | no | | install_kubectl | Set to `true` to install `kubectl` if the module is provisioned on workstations where `kubectl` is not installed by default, e.g. Terraform Cloud workers | bool | `false` | no | @@ -399,13 +400,13 @@ Available targets: | map_additional_aws_accounts | Additional AWS account numbers to add to `config-map-aws-auth` ConfigMap | list(string) | `` | no | | map_additional_iam_roles | Additional IAM roles to add to `config-map-aws-auth` ConfigMap | object | `` | no | | map_additional_iam_users | Additional IAM users to add to `config-map-aws-auth` ConfigMap | object | `` | no | -| name | Solution name, e.g. 'app' or 'cluster' | string | - | yes | -| namespace | Namespace, which could be your organization name, e.g. 'eg' or 'cp' | string | `` | no | +| name | Solution name, e.g. 'app' or 'jenkins' | string | `` | no | +| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | string | `` | no | | oidc_provider_enabled | Create an IAM OIDC identity provider for the cluster, then you can create IAM roles to associate with a service account in the cluster, instead of using kiam or kube2iam. For more information, see https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html | bool | `false` | no | | region | AWS Region | string | - | yes | -| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | string | `` | no | +| stage | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | string | `` | no | | subnet_ids | A list of subnet IDs to launch the cluster in | list(string) | - | yes | -| tags | Additional tags (e.g. `map('BusinessUnit`,`XYZ`) | map(string) | `` | no | +| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | map(string) | `` | no | | vpc_id | VPC ID for the EKS cluster | string | - | yes | | workers_role_arns | List of Role ARNs of the worker nodes | list(string) | - | yes | | workers_security_group_ids | Security Group IDs of the worker nodes | list(string) | - | yes | @@ -519,7 +520,7 @@ In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. ## Copyright -Copyright © 2017-2019 [Cloud Posse, LLC](https://cpco.io/copyright) +Copyright © 2017-2020 [Cloud Posse, LLC](https://cpco.io/copyright) diff --git a/docs/terraform.md b/docs/terraform.md index 75312340..a0cda930 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -12,11 +12,12 @@ | aws_eks_update_kubeconfig_additional_arguments | Additional arguments for `aws eks update-kubeconfig` command, e.g. `--role-arn xxxxxxxxx`. For more info, see https://docs.aws.amazon.com/cli/latest/reference/eks/update-kubeconfig.html | string | `` | no | | configmap_auth_file | Path to `configmap_auth_file` | string | `` | no | | configmap_auth_template_file | Path to `config_auth_template_file` | string | `` | no | -| delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | no | -| enabled | Whether to create the resources. Set to `false` to prevent the module from creating any resources | bool | `true` | no | +| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes` | string | `-` | no | +| enabled | Set to false to prevent the module from creating any resources | bool | `true` | no | | enabled_cluster_log_types | A list of the desired control plane logging to enable. For more information, see https://docs.aws.amazon.com/en_us/eks/latest/userguide/control-plane-logs.html. Possible values [`api`, `audit`, `authenticator`, `controllerManager`, `scheduler`] | list(string) | `` | no | | endpoint_private_access | Indicates whether or not the Amazon EKS private API server endpoint is enabled. Default to AWS EKS resource and it is false | bool | `false` | no | | endpoint_public_access | Indicates whether or not the Amazon EKS public API server endpoint is enabled. Default to AWS EKS resource and it is true | bool | `true` | no | +| environment | Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT' | string | `` | no | | external_packages_install_path | Path to install external packages, e.g. AWS CLI and `kubectl`. Used when the module is provisioned on workstations where the external packages are not installed by default, e.g. Terraform Cloud workers | string | `` | no | | install_aws_cli | Set to `true` to install AWS CLI if the module is provisioned on workstations where AWS CLI is not installed by default, e.g. Terraform Cloud workers | bool | `false` | no | | install_kubectl | Set to `true` to install `kubectl` if the module is provisioned on workstations where `kubectl` is not installed by default, e.g. Terraform Cloud workers | bool | `false` | no | @@ -28,13 +29,13 @@ | map_additional_aws_accounts | Additional AWS account numbers to add to `config-map-aws-auth` ConfigMap | list(string) | `` | no | | map_additional_iam_roles | Additional IAM roles to add to `config-map-aws-auth` ConfigMap | object | `` | no | | map_additional_iam_users | Additional IAM users to add to `config-map-aws-auth` ConfigMap | object | `` | no | -| name | Solution name, e.g. 'app' or 'cluster' | string | - | yes | -| namespace | Namespace, which could be your organization name, e.g. 'eg' or 'cp' | string | `` | no | +| name | Solution name, e.g. 'app' or 'jenkins' | string | `` | no | +| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | string | `` | no | | oidc_provider_enabled | Create an IAM OIDC identity provider for the cluster, then you can create IAM roles to associate with a service account in the cluster, instead of using kiam or kube2iam. For more information, see https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html | bool | `false` | no | | region | AWS Region | string | - | yes | -| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | string | `` | no | +| stage | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | string | `` | no | | subnet_ids | A list of subnet IDs to launch the cluster in | list(string) | - | yes | -| tags | Additional tags (e.g. `map('BusinessUnit`,`XYZ`) | map(string) | `` | no | +| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | map(string) | `` | no | | vpc_id | VPC ID for the EKS cluster | string | - | yes | | workers_role_arns | List of Role ARNs of the worker nodes | list(string) | - | yes | | workers_security_group_ids | Security Group IDs of the worker nodes | list(string) | - | yes | diff --git a/main.tf b/main.tf index bbf0b594..c58e73bf 100644 --- a/main.tf +++ b/main.tf @@ -1,12 +1,13 @@ module "label" { - source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.16.0" - namespace = var.namespace - stage = var.stage - name = var.name - delimiter = var.delimiter - attributes = compact(concat(var.attributes, ["cluster"])) - tags = var.tags - enabled = var.enabled + source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.16.0" + namespace = var.namespace + stage = var.stage + environment = var.environment + name = var.name + delimiter = var.delimiter + attributes = compact(concat(var.attributes, ["cluster"])) + tags = var.tags + enabled = var.enabled } data "aws_iam_policy_document" "assume_role" { diff --git a/variables.tf b/variables.tf index f7e4ebef..cf5aff56 100644 --- a/variables.tf +++ b/variables.tf @@ -1,29 +1,37 @@ -variable "region" { +variable "namespace" { type = string - description = "AWS Region" + default = "" + description = "Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp'" } -variable "namespace" { +variable "environment" { type = string - description = "Namespace, which could be your organization name, e.g. 'eg' or 'cp'" default = "" + description = "Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT'" } variable "stage" { type = string - description = "Stage, e.g. 'prod', 'staging', 'dev', or 'test'" default = "" + description = "Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release'" } variable "name" { type = string - description = "Solution name, e.g. 'app' or 'cluster'" + default = "" + description = "Solution name, e.g. 'app' or 'jenkins'" +} + +variable "enabled" { + type = bool + default = true + description = "Set to false to prevent the module from creating any resources" } variable "delimiter" { type = string default = "-" - description = "Delimiter to be used between `name`, `namespace`, `stage`, etc." + description = "Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`" } variable "attributes" { @@ -35,13 +43,12 @@ variable "attributes" { variable "tags" { type = map(string) default = {} - description = "Additional tags (e.g. `map('BusinessUnit`,`XYZ`)" + description = "Additional tags (e.g. `map('BusinessUnit','XYZ')`" } -variable "enabled" { - type = bool - description = "Whether to create the resources. Set to `false` to prevent the module from creating any resources" - default = true +variable "region" { + type = string + description = "AWS Region" } variable "vpc_id" {