Skip to content

Commit

Permalink
Fixed outputs for #36
Browse files Browse the repository at this point in the history
  • Loading branch information
antonbabenko committed Jan 31, 2018
1 parent c8e3590 commit 5ed286f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
3 changes: 3 additions & 0 deletions examples/complete/mysql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ module "db" {

identifier = "demodb"

create_db_instance = false
create_db_subnet_group = false

# All available versions: http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_MySQL.html#MySQL.Concepts.VersionMgmt
engine = "mysql"
engine_version = "5.7.19"
Expand Down
24 changes: 12 additions & 12 deletions modules/db_instance/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
# DB instance
output "this_db_instance_address" {
description = "The address of the RDS instance"
value = "${element(concat(aws_db_instance.this.address, list("")), 0)}"
value = "${element(concat(aws_db_instance.this.*.address, list("")), 0)}"
}

output "this_db_instance_arn" {
description = "The ARN of the RDS instance"
value = "${element(concat(aws_db_instance.this.arn, list("")), 0)}"
value = "${element(concat(aws_db_instance.this.*.arn, list("")), 0)}"
}

output "this_db_instance_availability_zone" {
description = "The availability zone of the RDS instance"
value = "${element(concat(aws_db_instance.this.availability_zone, list("")), 0)}"
value = "${element(concat(aws_db_instance.this.*.availability_zone, list("")), 0)}"
}

output "this_db_instance_endpoint" {
description = "The connection endpoint"
value = "${element(concat(aws_db_instance.this.endpoint, list("")), 0)}"
value = "${element(concat(aws_db_instance.this.*.endpoint, list("")), 0)}"
}

output "this_db_instance_hosted_zone_id" {
description = "The canonical hosted zone ID of the DB instance (to be used in a Route 53 Alias record)"
value = "${element(concat(aws_db_instance.this.hosted_zone_id, list("")), 0)}"
value = "${element(concat(aws_db_instance.this.*.hosted_zone_id, list("")), 0)}"
}

output "this_db_instance_id" {
description = "The RDS instance ID"
value = "${element(concat(aws_db_instance.this.id, list("")), 0)}"
value = "${element(concat(aws_db_instance.this.*.id, list("")), 0)}"
}

output "this_db_instance_resource_id" {
description = "The RDS Resource ID of this instance"
value = "${element(concat(aws_db_instance.this.resource_id, list("")), 0)}"
value = "${element(concat(aws_db_instance.this.*.resource_id, list("")), 0)}"
}

output "this_db_instance_status" {
description = "The RDS instance status"
value = "${element(concat(aws_db_instance.this.status, list("")), 0)}"
value = "${element(concat(aws_db_instance.this.*.status, list("")), 0)}"
}

output "this_db_instance_name" {
description = "The database name"
value = "${element(concat(aws_db_instance.this.name, list("")), 0)}"
value = "${element(concat(aws_db_instance.this.*.name, list("")), 0)}"
}

output "this_db_instance_username" {
description = "The master username for the database"
value = "${element(concat(aws_db_instance.this.username, list("")), 0)}"
value = "${element(concat(aws_db_instance.this.*.username, list("")), 0)}"
}

output "this_db_instance_password" {
description = "The database password (this password may be old, because Terraform doesn't track it after initial creation)"
value = "${element(concat(var.password, list("")), 0)}"
value = "${var.password}"
}

output "this_db_instance_port" {
description = "The database port"
value = "${element(concat(aws_db_instance.this.port, list("")), 0)}"
value = "${element(concat(aws_db_instance.this.*.port, list("")), 0)}"
}
12 changes: 6 additions & 6 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,16 @@ variable "parameters" {
}

variable "create_db_subnet_group" {
description = "Create a database subnet group"
default = 1
description = "Whether to create a database subnet group"
default = true
}

variable "create_db_parameter_group" {
description = "Create a database parameter group"
default = 1
description = "Whether to create a database parameter group"
default = true
}

variable "create_db_instance" {
description = "Create a database instance"
default = 1
description = "Whether to create a database instance"
default = true
}

0 comments on commit 5ed286f

Please sign in to comment.