Skip to content

Commit

Permalink
Merge pull request #30 from swhitaker90/stevew/fixes_enabled_flag
Browse files Browse the repository at this point in the history
Fixes a couple of issues related to enabled flag
  • Loading branch information
swhitaker90 authored Mar 25, 2019
2 parents 23f19b5 + cbd600f commit 1fdaffd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -277,20 +277,20 @@ data "aws_iam_policy_document" "monitoring-rds-assume-role-policy" {
}

resource "aws_iam_role" "rds-enhanced-monitoring" {
count = "${var.monitoring_interval > 0 ? 1 : 0}"
count = "${var.enabled && var.monitoring_interval > 0 ? 1 : 0}"
name_prefix = "rds-enhanced-mon-${var.envname}-"
assume_role_policy = "${data.aws_iam_policy_document.monitoring-rds-assume-role-policy.json}"
}

resource "aws_iam_role_policy_attachment" "rds-enhanced-monitoring-policy-attach" {
count = "${var.monitoring_interval > 0 ? 1 : 0}"
count = "${var.enabled && var.monitoring_interval > 0 ? 1 : 0}"
role = "${aws_iam_role.rds-enhanced-monitoring.name}"
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole"
}

// Autoscaling
resource "aws_appautoscaling_target" "autoscaling" {
count = "${var.replica_scale_enabled ? 1 : 0}"
count = "${var.enabled && var.replica_scale_enabled ? 1 : 0}"
max_capacity = "${var.replica_scale_max}"
min_capacity = "${var.replica_scale_min}"
resource_id = "cluster:${aws_rds_cluster.default.cluster_identifier}"
Expand All @@ -299,7 +299,7 @@ resource "aws_appautoscaling_target" "autoscaling" {
}

resource "aws_appautoscaling_policy" "autoscaling" {
count = "${var.replica_scale_enabled ? 1 : 0}"
count = "${var.enabled && var.replica_scale_enabled ? 1 : 0}"
depends_on = ["aws_appautoscaling_target.autoscaling"]
name = "target-metric"
policy_type = "TargetTrackingScaling"
Expand Down
2 changes: 1 addition & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ output "cluster_endpoint" {

// Comma separated list of all DB instance endpoints running in cluster
output "all_instance_endpoints_list" {
value = ["${aws_rds_cluster_instance.cluster_instance_0.endpoint}", "${aws_rds_cluster_instance.cluster_instance_n.*.endpoint}"]
value = ["${concat(aws_rds_cluster_instance.cluster_instance_0.*.endpoint, aws_rds_cluster_instance.cluster_instance_n.*.endpoint)}"]
}

// A read-only endpoint for the Aurora cluster, automatically load-balanced across replicas
Expand Down

0 comments on commit 1fdaffd

Please sign in to comment.