-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from lgallard/feature/advanced_security_options
Feature/advanced security options
- Loading branch information
Showing
19 changed files
with
325 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
examples/advanced_security_options/master_user_arn/datasources.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Use this data source to get the access to the effective Account ID in which | ||
# Terraform is working. | ||
data "aws_caller_identity" "current" {} | ||
|
||
# To obtain the name of the AWS region configured on the provider | ||
data "aws_region" "current" {} | ||
|
||
|
59 changes: 59 additions & 0 deletions
59
examples/advanced_security_options/master_user_arn/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
module "aws_es" { | ||
|
||
source = "lgallard/elasticsearch/aws" | ||
|
||
domain_name = var.es_domain_name | ||
elasticsearch_version = var.es_version | ||
|
||
cluster_config = { | ||
dedicated_master_enabled = "true" | ||
instance_count = "3" | ||
instance_type = "r5.large.elasticsearch" | ||
zone_awareness_enabled = "true" | ||
availability_zone_count = "3" | ||
} | ||
|
||
advanced_security_options = { | ||
enabled = true | ||
internal_user_database_enabled = true | ||
master_user_options = { | ||
master_user_arn = "arn:aws:iam::123456789101:user/lgallard" | ||
} | ||
} | ||
|
||
ebs_options = { | ||
ebs_enabled = "true" | ||
volume_size = "25" | ||
} | ||
|
||
encrypt_at_rest = { | ||
enabled = "true" | ||
kms_key_id = "alias/aws/es" | ||
} | ||
|
||
|
||
log_publishing_options = { | ||
enabled = "true" | ||
} | ||
|
||
advanced_options = { | ||
"rest.action.multi.allow_explicit_index" = "true" | ||
} | ||
|
||
access_policies = templatefile("${path.module}/whitelits.tpl", { | ||
region = data.aws_region.current.name, | ||
account = data.aws_caller_identity.current.account_id, | ||
domain_name = var.es_domain_name, | ||
whitelist = "${jsonencode(var.whitelist)}" | ||
}) | ||
|
||
node_to_node_encryption_enabled = "true" | ||
snapshot_options_automated_snapshot_start_hour = "23" | ||
|
||
#timeouts_update = "90m" | ||
|
||
tags = { | ||
Owner = "sysops" | ||
env = "dev" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
examples/advanced_security_options/master_user_arn/provider.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
provider "aws" { | ||
region = var.region | ||
profile = var.profile | ||
} | ||
|
5 changes: 5 additions & 0 deletions
5
examples/advanced_security_options/master_user_arn/terraform.tfvars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
region = "us-east-1" | ||
profile = "default" | ||
es_domain_name = "elasticsearch-public" | ||
es_version = "7.1" | ||
whitelist = ["1.1.1.1", "2.2.2.2"] |
15 changes: 15 additions & 0 deletions
15
examples/advanced_security_options/master_user_arn/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Provider | ||
variable "region" {} | ||
variable "profile" {} | ||
|
||
|
||
# AWS Elasticsearch | ||
variable "es_domain_name" {} | ||
variable "es_version" {} | ||
|
||
|
||
# Whitelist (allow public IPs) | ||
variable "whitelist" { | ||
default = [] | ||
} | ||
|
4 changes: 4 additions & 0 deletions
4
examples/advanced_security_options/master_user_arn/versions.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
terraform { | ||
required_version = ">= 0.12" | ||
} |
19 changes: 19 additions & 0 deletions
19
examples/advanced_security_options/master_user_arn/whitelits.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Sid": "", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"AWS": "*" | ||
}, | ||
"Action": "es:*", | ||
"Resource": "arn:aws:es:${region}:${account}:domain/${domain_name}/*", | ||
"Condition": { | ||
"IpAddress": { | ||
"aws:SourceIp": ${whitelist} | ||
} | ||
} | ||
} | ||
] | ||
} |
8 changes: 8 additions & 0 deletions
8
examples/advanced_security_options/master_user_name_pasword/datasources.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Use this data source to get the access to the effective Account ID in which | ||
# Terraform is working. | ||
data "aws_caller_identity" "current" {} | ||
|
||
# To obtain the name of the AWS region configured on the provider | ||
data "aws_region" "current" {} | ||
|
||
|
60 changes: 60 additions & 0 deletions
60
examples/advanced_security_options/master_user_name_pasword/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
module "aws_es" { | ||
|
||
source = "lgallard/elasticsearch/aws" | ||
|
||
domain_name = var.es_domain_name | ||
elasticsearch_version = var.es_version | ||
|
||
cluster_config = { | ||
dedicated_master_enabled = "true" | ||
instance_count = "3" | ||
instance_type = "r5.large.elasticsearch" | ||
zone_awareness_enabled = "true" | ||
availability_zone_count = "3" | ||
} | ||
|
||
advanced_security_options = { | ||
enabled = true | ||
internal_user_database_enabled = true | ||
master_user_options = { | ||
master_user_name = "username" | ||
master_user_password = "topsecret" | ||
} | ||
} | ||
|
||
ebs_options = { | ||
ebs_enabled = "true" | ||
volume_size = "25" | ||
} | ||
|
||
encrypt_at_rest = { | ||
enabled = "true" | ||
kms_key_id = "alias/aws/es" | ||
} | ||
|
||
|
||
log_publishing_options = { | ||
enabled = "true" | ||
} | ||
|
||
advanced_options = { | ||
"rest.action.multi.allow_explicit_index" = "true" | ||
} | ||
|
||
access_policies = templatefile("${path.module}/whitelits.tpl", { | ||
region = data.aws_region.current.name, | ||
account = data.aws_caller_identity.current.account_id, | ||
domain_name = var.es_domain_name, | ||
whitelist = "${jsonencode(var.whitelist)}" | ||
}) | ||
|
||
node_to_node_encryption_enabled = "true" | ||
snapshot_options_automated_snapshot_start_hour = "23" | ||
|
||
#timeouts_update = "90m" | ||
|
||
tags = { | ||
Owner = "sysops" | ||
env = "dev" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
examples/advanced_security_options/master_user_name_pasword/provider.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
provider "aws" { | ||
region = var.region | ||
profile = var.profile | ||
} | ||
|
5 changes: 5 additions & 0 deletions
5
examples/advanced_security_options/master_user_name_pasword/terraform.tfvars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
region = "us-east-1" | ||
profile = "default" | ||
es_domain_name = "elasticsearch-public" | ||
es_version = "7.1" | ||
whitelist = ["1.1.1.1", "2.2.2.2"] |
15 changes: 15 additions & 0 deletions
15
examples/advanced_security_options/master_user_name_pasword/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Provider | ||
variable "region" {} | ||
variable "profile" {} | ||
|
||
|
||
# AWS Elasticsearch | ||
variable "es_domain_name" {} | ||
variable "es_version" {} | ||
|
||
|
||
# Whitelist (allow public IPs) | ||
variable "whitelist" { | ||
default = [] | ||
} | ||
|
4 changes: 4 additions & 0 deletions
4
examples/advanced_security_options/master_user_name_pasword/versions.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
terraform { | ||
required_version = ">= 0.12" | ||
} |
19 changes: 19 additions & 0 deletions
19
examples/advanced_security_options/master_user_name_pasword/whitelits.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Sid": "", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"AWS": "*" | ||
}, | ||
"Action": "es:*", | ||
"Resource": "arn:aws:es:${region}:${account}:domain/${domain_name}/*", | ||
"Condition": { | ||
"IpAddress": { | ||
"aws:SourceIp": ${whitelist} | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.