Skip to content

Commit

Permalink
add enable count in all resources
Browse files Browse the repository at this point in the history
  • Loading branch information
anmolnagpal committed Jan 23, 2020
1 parent 054092e commit 66c687c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ resource "aws_instance" "default" {
#Module : EIP
#Description : Provides an Elastic IP resource.
resource "aws_eip" "default" {
count = var.assign_eip_address == true ? var.instance_count : 0
count = var.instance_enabled == true && var.assign_eip_address == true ? var.instance_count : 0

network_interface = element(aws_instance.default.*.primary_network_interface_id, count.index)
vpc = true
Expand All @@ -99,7 +99,7 @@ resource "aws_eip" "default" {
#Module : EBS VOLUME
#Description : Manages a single EBS volume.
resource "aws_ebs_volume" "default" {
count = var.ebs_volume_enabled == true ? var.instance_count : 0
count = var.instance_enabled == true && var.ebs_volume_enabled == true ? var.instance_count : 0

availability_zone = element(aws_instance.default.*.availability_zone, count.index)
size = var.ebs_volume_size
Expand All @@ -117,7 +117,7 @@ resource "aws_ebs_volume" "default" {
#Module : VOLUME ATTACHMENT
#Description : Provides an AWS EBS Volume Attachment as a top level resource, to attach and detach volumes from AWS Instances.
resource "aws_volume_attachment" "default" {
count = var.ebs_volume_enabled == true ? var.instance_count : 0
count = var.instance_enabled == true && var.ebs_volume_enabled == true ? var.instance_count : 0

device_name = element(var.ebs_device_name, count.index)
volume_id = element(aws_ebs_volume.default.*.id, count.index)
Expand All @@ -127,15 +127,15 @@ resource "aws_volume_attachment" "default" {
#Module : IAM INSTANCE PROFILE
#Description : Provides an IAM instance profile.
resource "aws_iam_instance_profile" "default" {
count = var.instance_profile_enabled ? 1 : 0
count = var.instance_enabled == true && var.instance_profile_enabled ? 1 : 0
name = format("%s%sinstance-profile", module.labels.id, var.delimiter)
role = var.iam_instance_profile
}

#Module : ROUTE53
#Description : Provides a Route53 record resource.
resource "aws_route53_record" "default" {
count = var.dns_enabled ? var.instance_count : 0
count = var.instance_enabled == true && var.dns_enabled ? var.instance_count : 0
zone_id = var.dns_zone_id
name = format("%s%s%s", var.hostname, var.delimiter, (count.index))
type = var.type
Expand Down

0 comments on commit 66c687c

Please sign in to comment.