Skip to content

Commit bc943d4

Browse files
authored
Merge pull request #10 from souza-dan/security-group-refactor
DEV-14582 - Security group refactor
2 parents a929543 + c20f0b4 commit bc943d4

File tree

18 files changed

+118
-206
lines changed

18 files changed

+118
-206
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# .tfstate files
55
*.tfstate
66
*.tfstate.*
7+
.terraform.lock.hcl
78

89
# Crash log files
910
crash.log

CHANGELOG.md

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

3+
## v2.0.0 - October 13th 2020
4+
* New input variables for the main module:
5+
* `security_group_ids`
6+
* Removed input variables from the main module:
7+
* `ingress_cidr_blocks`
8+
* `ingress_security_groups`
9+
* `egress_cidr_blocks`
10+
* `egress_security_groups`
11+
* `ports`
12+
* `security_group_tags`
13+
* `sg_name`
14+
* Outputs changed in main module
15+
* `es_security_group_id` -> `es_security_group_ids`
16+
* Removes the security groups module
17+
* Adds a new ports module
18+
* Updates example with security group creation and new variable `name-prefix`
19+
320
## v1.0.1 - April 13th 2021
421
* Fixes a deprecation warning about interpolation-only expressions
522

README.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@
22
This terraform module creates an Elasticsearch (ES) domain on AWS.
33

44
# Examples
5-
## Basic
6-
Inline example implementation of the module. This is the most basic example of what it would look like to use this module.
7-
```
8-
module "tamr-es-cluster" {
9-
source = "git::https://github.com/Datatamer/terraform-aws-es?ref=1.0.1"
10-
vpc_id = "vpc-id"
11-
subnet_ids = ["subnet-id"]
12-
}
13-
```
145
## Minimal
156
Smallest complete fully working example. This example might require extra resources to run the example.
167
- [Minimal](https://github.com/Datatamer/terraform-aws-es/tree/master/examples/minimal)
@@ -19,7 +10,6 @@ Smallest complete fully working example. This example might require extra resour
1910
This module creates:
2011
* a new Elasticsearch domain in AWS
2112
* optionally, a new IAM service linked role for ES on the AWS account
22-
* a security group to attach to the ES domain, with HTTP and/or HTTPS enabled
2313

2414
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2515
## Requirements
@@ -70,7 +60,7 @@ No provider.
7060

7161
| Name | Description |
7262
|------|-------------|
73-
| es\_security\_group\_id | ID of the security group created |
63+
| es\_security\_group\_ids | List of security group IDs of the security groups used by ES |
7464
| tamr\_es\_domain\_endpoint | Endpoint of ES domain created |
7565
| tamr\_es\_domain\_id | ID of the ES domain created |
7666

VERSION

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

examples/minimal/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ No requirements.
1111

1212
## Inputs
1313

14-
No input.
14+
| Name | Description | Type | Default | Required |
15+
|------|-------------|------|---------|:--------:|
16+
| name-prefix | A string to prepend to names of resources created by this example | `any` | n/a | yes |
1517

1618
## Outputs
1719

examples/minimal/main.tf

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,30 @@ resource "aws_subnet" "es_subnet" {
77
cidr_block = "1.2.3.0/24"
88
}
99

10+
module "sg-ports" {
11+
#source = "git::https://github.com/Datatamer/terraform-aws-es.git//modules/es-ports?ref=2.0.0"
12+
source = "../../modules/es-ports"
13+
}
14+
15+
module "aws-sg" {
16+
source = "git::[email protected]:Datatamer/terraform-aws-security-groups.git?ref=0.1.0"
17+
vpc_id = aws_vpc.es_vpc.id
18+
ingress_cidr_blocks = [
19+
"1.2.3.0/24"
20+
]
21+
egress_cidr_blocks = [
22+
"0.0.0.0/0"
23+
]
24+
ingress_ports = module.sg-ports.ingress_ports
25+
sg_name_prefix = var.name-prefix
26+
}
27+
1028
module "tamr-es-cluster" {
1129
source = "../../"
1230
vpc_id = aws_vpc.es_vpc.id
13-
domain_name = "minimal-example-es-cluster"
31+
domain_name = format("%s-elasticsearch", var.name-prefix)
1432
subnet_ids = [aws_subnet.es_subnet.id]
1533
# Only needed once per account, so may need to set this to false
1634
create_new_service_role = true
35+
security_group_ids = module.aws-sg.security_group_ids
1736
}

examples/minimal/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ output "tamr_es_domain_endpoint" {
99
}
1010

1111
output "es_security_group_id" {
12-
value = module.tamr-es-cluster.es_security_group_id
12+
value = module.tamr-es-cluster.es_security_group_ids
1313
description = "ID of the ES domain created"
1414
}
1515

examples/minimal/variables.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
variable "name-prefix" {
2+
description = "A string to prepend to names of resources created by this example"
3+
}

main.tf

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module "tamr-es-cluster" {
55
instance_count = var.instance_count
66
instance_type = var.instance_type
77
subnet_ids = var.subnet_ids
8-
security_group_ids = [module.elasticsearch-sg.es_security_group_id]
8+
security_group_ids = var.security_group_ids
99
snapshot_start_hour = var.snapshot_start_hour
1010
ebs_enabled = var.ebs_enabled
1111
ebs_iops = var.ebs_iops
@@ -20,15 +20,3 @@ module "tamr-es-cluster" {
2020
node_to_node_encryption_enabled = var.node_to_node_encryption_enabled
2121
arn_partition = var.arn_partition
2222
}
23-
24-
module "elasticsearch-sg" {
25-
source = "./modules/es-security-group"
26-
sg_name = var.sg_name
27-
vpc_id = var.vpc_id
28-
revoke_rules_on_delete = var.revoke_rules_on_delete
29-
additional_tags = var.sg_tags
30-
ingress_cidr_blocks = var.ingress_cidr_blocks
31-
ingress_security_groups = var.ingress_security_groups
32-
enable_https = var.enable_https
33-
enable_http = var.enable_http
34-
}

modules/es-ports/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Tamr AWS ES Ports Module
2+
This module returns a list of ports used by the Elasticsearch Service on AWS.
3+
4+
# Examples
5+
## Basic
6+
Inline example implementation of the module. This is the most basic example of what it would look like to use this module.
7+
```
8+
module "tamr-es-cluster" {
9+
source = "git::https://github.com/Datatamer/terraform-aws-es//modules/es-ports?ref=2.0.0"
10+
}
11+
```
12+
13+
# Resources Created
14+
This modules creates no resources.
15+
16+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
17+
## Requirements
18+
19+
No requirements.
20+
21+
## Providers
22+
23+
No provider.
24+
25+
## Inputs
26+
27+
| Name | Description | Type | Default | Required |
28+
|------|-------------|------|---------|:--------:|
29+
| additional\_ports | Additional ports to add to the output of this module | `list(number)` | `[]` | no |
30+
| ports | Ports used by the Elasticsearch | `list(number)` | <pre>[<br> 80,<br> 443<br>]</pre> | no |
31+
32+
## Outputs
33+
34+
| Name | Description |
35+
|------|-------------|
36+
| ingress\_ports | List of ingress ports |
37+
38+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
39+
40+
# References
41+
This repo is based on:
42+
* [terraform standard module structure](https://www.terraform.io/docs/modules/index.html#standard-module-structure)
43+
* [templated terraform module](https://github.com/tmknom/template-terraform-module)
44+
45+
# License
46+
Apache 2 Licensed. See LICENSE for full details.

0 commit comments

Comments
 (0)