Skip to content

Commit

Permalink
Fix disabled. Output all available data. Other fixes and cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Nemetz committed Dec 15, 2017
1 parent 09efbc3 commit 2c9355d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 30 deletions.
17 changes: 4 additions & 13 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
# https://www.terraform.io/docs/providers/aws/r/efs_mount_target.html

# Define composite variables for resources
data "aws_region" "default" {
count = "${var.enabled ? 1 : 0}"
current = "true"
}

locals {
region = "${length(var.region) > 0 ? var.region : element(concat(data.aws_region.default.*.name, list("")),0)}"
}

module "label" {
source = "devops-workflow/label/local"
version = "0.1.0"
Expand Down Expand Up @@ -45,7 +36,7 @@ resource "aws_efs_mount_target" "default" {
resource "aws_security_group" "default" {
count = "${var.enabled ? 1 : 0}"
name = "${module.label.id}"
description = "EFS"
description = "EFS Access"
vpc_id = "${var.vpc_id}"
tags = "${module.label.tags}"
lifecycle {
Expand Down Expand Up @@ -73,13 +64,13 @@ resource "aws_security_group_rule" "egress" {
security_group_id = "${aws_security_group.default.id}"
}

# TODO: use alias module instead. This does CNAME
module "dns" {
source = "cloudposse/route53-cluster-hostname/aws"
version = "0.2.1"
name = "${module.label.id}"
name = "${module.label.name}"
ttl = "${var.dns_ttl}"
zone_id = "${var.zone_id}"
#records = ["${aws_efs_file_system.default.id}.efs.${local.region}.amazonaws.com"]
records = ["${element(concat(aws_efs_file_system.default.*.id, list("")),0)}.efs.${local.region}.amazonaws.com"]
records = ["${element(concat(aws_efs_file_system.default.*.dns_name, list("")),0)}"]
enabled = "${var.enabled ? (length(var.zone_id) > 0 ? "true" : "false") : "false"}"
}
42 changes: 31 additions & 11 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
// EFS File System outputs
output "dns_name" {
description = ""
value = "${element(concat(aws_efs_file_system.default.*.dns_name, list("")),0)}"
}
output "id" {
description = "ID of EFS"
value = "${element(concat(aws_efs_file_system.default.*.id, list("")),0)}"
}
/*
output "host" {
description = "Assigned DNS-record for the EFS"
value = "${module.dns.hostname}"
}
*/
output "dns_name" {
output "kms_key_id" {
description = ""
value = "${element(concat(aws_efs_file_system.default.*.id, list("")),0)}.efs.${local.region}.amazonaws.com"
value = "${element(concat(aws_efs_file_system.default.*.kms_key_id, list("")),0)}"
}
output "security_group" {
description = ""
value = "${element(concat(aws_security_group.default.*.id, list("")),0)}"

// EFS Mount Target outputs
/*
# Same as EFS mount_target_dns_names
output "mount_target_dns_names" {
description = "List of DNS names of the EFS mount targets"
value = ["${aws_efs_mount_target.default.*.dns_name}"]
}
*/
output "mount_target_ids" {
description = "List of IDs of the EFS mount targets"
value = ["${aws_efs_mount_target.default.*.id}"]
Expand All @@ -24,3 +28,19 @@ output "mount_target_ips" {
description = "List of IPs of the EFS mount targets"
value = ["${aws_efs_mount_target.default.*.ip_address}"]
}
output "mount_target_net_intf_ids" {
description = "List of network interface IDs of the EFS mount targets"
value = ["${aws_efs_mount_target.default.*.id}"]
}

// Other resources
output "security_group" {
description = ""
value = "${element(concat(aws_security_group.default.*.id, list("")),0)}"
}

// Submodules output
output "host" {
description = "Assigned DNS-record for the EFS"
value = "${element(concat(list(module.dns.hostname), list("")),0)}"
}
12 changes: 6 additions & 6 deletions test/main.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module "efs" {
source = "../"
name = "CapMe"
environment = "Dev"
#organization = "CorpXyZ"
name = "efs-vol"
environment = "testing"
organization = ""
#attributes = ["role", "policy", "use", ""]
#tags = "${map("Key", "Value")}"
zone_id = ""
zone_id = "ZURF67XJUWC5A" # one
security_groups = []
subnets = []
vpc_id = ""
subnets = ["subnet-857efce3","subnet-0852f140","subnet-6395c038"]
vpc_id = "vpc-417c0027" # one
#enabled = false
}

Expand Down

0 comments on commit 2c9355d

Please sign in to comment.