Skip to content

Commit 1f5af40

Browse files
Merge pull request #14 from fvazquez-caylent/CA-10-Tag-based-authorization
Ca 10 tag based authorization
2 parents b74f18f + c477ca5 commit 1f5af40

File tree

11 files changed

+37
-8
lines changed

11 files changed

+37
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Tamr Terraform AWS Elasticsearch Repo
22

3+
## v2.1.0 - July 12nd 2021
4+
* Adds new variable `tags` to set tags for all resources
5+
* Deprecates `es_tags` in favor of `tags`
6+
37
## v2.0.0 - October 13th 2020
48
* New input variables for the main module:
59
* `security_group_ids`

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ No provider.
4040
| enable\_http | If set to true, enables SSH | `bool` | `true` | no |
4141
| enable\_https | If set to true, enables SSH | `bool` | `true` | no |
4242
| enforce\_https | Whether or not to require HTTPS on the domain endpoint | `bool` | `true` | no |
43-
| es\_tags | Additional tags to be attached to the ES domain | `map(string)` | `{}` | no |
43+
| es\_tags | [DEPRECATED: Use `tags` instead] Additional tags to be attached to the ES domain and associated resources. | `map(string)` | `{}` | no |
4444
| es\_version | Version of ES to deploy | `string` | `"6.8"` | no |
4545
| ingress\_cidr\_blocks | CIDR blocks to attach to security groups for ingress | `list(string)` | `[]` | no |
4646
| ingress\_security\_groups | Existing security groups to attch to new security groups for ingress | `list(string)` | `[]` | no |
@@ -54,6 +54,7 @@ No provider.
5454
| sg\_name | Security Group to create | `string` | `"es-security-group"` | no |
5555
| sg\_tags | Additional tags to be attached to the security group | `map(string)` | `{}` | no |
5656
| snapshot\_start\_hour | Hour when an automated daily snapshot of the indices is taken | `number` | `0` | no |
57+
| tags | A map of tags to add to all resources. Replaces `es_tags`. | `map(string)` | `{}` | no |
5758
| tls\_security\_policy | The name of the TLS security policy that needs to be applied to the HTTPS endpoint.<br> Valid values: Policy-Min-TLS-1-0-2019-07 and Policy-Min-TLS-1-2-2019-07. | `string` | `"Policy-Min-TLS-1-2-2019-07"` | no |
5859

5960
## Outputs

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.0
1+
2.1.0

examples/minimal/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ No requirements.
1414
| Name | Description | Type | Default | Required |
1515
|------|-------------|------|---------|:--------:|
1616
| name-prefix | A string to prepend to names of resources created by this example | `any` | n/a | yes |
17+
| tags | A map of tags to add to all resources created by this example. | `map(string)` | <pre>{<br> "Author": "Tamr",<br> "Environment": "Example"<br>}</pre> | no |
1718

1819
## Outputs
1920

examples/minimal/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
resource "aws_vpc" "es_vpc" {
22
cidr_block = "1.2.3.0/24"
3+
tags = var.tags
34
}
45

56
resource "aws_subnet" "es_subnet" {
67
vpc_id = aws_vpc.es_vpc.id
78
cidr_block = "1.2.3.0/24"
9+
tags = var.tags
810
}
911

1012
module "sg-ports" {
@@ -23,6 +25,7 @@ module "aws-sg" {
2325
]
2426
ingress_ports = module.sg-ports.ingress_ports
2527
sg_name_prefix = var.name-prefix
28+
tags = var.tags
2629
}
2730

2831
module "tamr-es-cluster" {
@@ -33,4 +36,5 @@ module "tamr-es-cluster" {
3336
# Only needed once per account, so may need to set this to false
3437
create_new_service_role = true
3538
security_group_ids = module.aws-sg.security_group_ids
39+
tags = var.tags
3640
}

examples/minimal/variables.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
variable "name-prefix" {
22
description = "A string to prepend to names of resources created by this example"
33
}
4+
variable "tags" {
5+
type = map(string)
6+
description = "A map of tags to add to all resources created by this example."
7+
default = {
8+
Author = "Tamr"
9+
Environment = "Example"
10+
}
11+
}
12+

main.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
locals {
2+
effective_tags = length(var.tags) > 0 ? var.tags : var.es_tags
3+
}
4+
15
module "tamr-es-cluster" {
26
source = "./modules/aws-es"
37
domain_name = var.domain_name
@@ -11,7 +15,7 @@ module "tamr-es-cluster" {
1115
ebs_iops = var.ebs_iops
1216
ebs_volume_size = var.ebs_volume_size
1317
ebs_volume_type = var.ebs_volume_type
14-
additional_tags = var.es_tags
18+
tags = local.effective_tags
1519
aws_region = var.aws_region
1620
create_new_service_role = var.create_new_service_role
1721
kms_key_id = var.kms_key_id

modules/aws-es/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ This modules creates:
3636
| Name | Description | Type | Default | Required |
3737
|------|-------------|------|---------|:--------:|
3838
| subnet\_ids | List of subnet IDs for the ES domain to be created in | `list(string)` | n/a | yes |
39-
| additional\_tags | Additional tags to be attached to the ES domain | `map(string)` | `{}` | no |
4039
| arn\_partition | The partition in which the resource is located. A partition is a group of AWS Regions.<br> Each AWS account is scoped to one partition.<br> The following are the supported partitions:<br> aws -AWS Regions<br> aws-cn - China Regions<br> aws-us-gov - AWS GovCloud (US) Regions | `string` | `"aws"` | no |
4140
| aws\_region | AWS region to launch in | `string` | `"us-east-1"` | no |
4241
| create\_new\_service\_role | Whether to create a new IAM service linked role for ES. This only needs to happen once per account. If false, linked\_service\_role is required | `bool` | `"true"` | no |
@@ -54,6 +53,7 @@ This modules creates:
5453
| node\_to\_node\_encryption\_enabled | Whether to enable node-to-node encryption | `bool` | `true` | no |
5554
| security\_group\_ids | List of security group IDs to be applied to the ES domain | `list(string)` | `[]` | no |
5655
| snapshot\_start\_hour | Hour when an automated daily snapshot of the indices is taken | `number` | `0` | no |
56+
| tags | A map of tags to add to all resources. | `map(string)` | `{}` | no |
5757
| tls\_security\_policy | The name of the TLS security policy that needs to be applied to the HTTPS endpoint.<br> Valid values: Policy-Min-TLS-1-0-2019-07 and Policy-Min-TLS-1-2-2019-07. | `string` | `"Policy-Min-TLS-1-2-2019-07"` | no |
5858

5959
## Outputs

modules/aws-es/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ resource "aws_elasticsearch_domain" "tamr-es-cluster" {
3939
}
4040

4141

42-
tags = var.additional_tags
42+
tags = var.tags
4343

4444
depends_on = [
4545
var.linked_service_role,

modules/aws-es/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ variable "ebs_volume_type" {
6666
description = "The type of EBS volumes attached to data nodes"
6767
}
6868

69-
variable "additional_tags" {
69+
variable "tags" {
7070
default = {}
7171
type = map(string)
72-
description = "Additional tags to be attached to the ES domain"
72+
description = "A map of tags to add to all resources."
7373
}
7474

7575
variable "aws_region" {

0 commit comments

Comments
 (0)