Skip to content

Commit

Permalink
Merge pull request #19 from rackspace-infrastructure-automation/add_e…
Browse files Browse the repository at this point in the history
…bs_volume_tags_param

Add module parameter for 'volume_tags' resource parameter
  • Loading branch information
Michael Cardenas authored Oct 8, 2018
2 parents 2172902 + 3735a36 commit 4d3c674
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 22 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
| cw_cpu_high_threshold | The value against which the specified statistic is compared. | string | `90` | no |
| detailed_monitoring | Enable Detailed Monitoring? true or false | string | `true` | no |
| disable_api_termination | Specifies that an instance should not be able to be deleted via the API. true or false. This option must be toggled to false to allow Terraform to destroy the resource. | string | `false` | no |
| ebs_volume_tags | (Optional) A mapping of tags to assign to the devices created by the instance at launch time. | map | `<map>` | no |
| ec2_os | Intended Operating System/Distribution of Instance. Valid inputs are ('amazon', 'rhel6', 'rhel7', 'centos6', 'centos7', 'ubuntu14', 'ubuntu16', 'windows') | string | - | yes |
| ec2_subnet | Subnet ID for EC2 Instance | string | - | yes |
| eip_allocation_id_count | A count of supplied eip allocation IDs in variable eip_allocation_id_list | string | `0` | no |
Expand Down
4 changes: 4 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ resource "aws_instance" "mod_ec2_instance_no_secondary_ebs" {
iops = "${var.primary_ebs_volume_iops}"
}

volume_tags = "${var.ebs_volume_tags}"

timeouts {
create = "${var.creation_policy_timeout}"
}
Expand Down Expand Up @@ -424,6 +426,8 @@ resource "aws_instance" "mod_ec2_instance_with_secondary_ebs" {
iops = "${var.primary_ebs_volume_iops}"
}

volume_tags = "${var.ebs_volume_tags}"

ebs_block_device {
device_name = "${lookup(local.ebs_device_map, var.ec2_os)}"
volume_type = "${var.secondary_ebs_volume_type}"
Expand Down
51 changes: 29 additions & 22 deletions tests/test1/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -117,28 +117,35 @@ resource "aws_eip" "test_eip_2" {
}

module "ec2_ar_centos7_no_codedeploy" {
source = "../../module"
ec2_os = "centos7"
instance_count = "3"
ec2_subnet = "${element(module.vpc.public_subnets, 0)}"
security_group_list = ["${module.vpc.default_sg}"]
image_id = "${data.aws_ami.amazon_centos_7.image_id}"
key_pair = "CircleCI"
instance_type = "t2.micro"
resource_name = "ec2_ar_centos7_no_codedeploy"
install_codedeploy_agent = false
enable_ebs_optimization = "False"
tenancy = "default"
backup_tag_value = "False"
detailed_monitoring = "True"
ssm_patching_group = "Group1Patching"
primary_ebs_volume_size = "60"
primary_ebs_volume_iops = "0"
primary_ebs_volume_type = "gp2"
secondary_ebs_volume_size = "60"
secondary_ebs_volume_iops = "0"
secondary_ebs_volume_type = "gp2"
encrypt_secondary_ebs_volume = "False"
source = "../../module"
ec2_os = "centos7"
instance_count = "3"
ec2_subnet = "${element(module.vpc.public_subnets, 0)}"
security_group_list = ["${module.vpc.default_sg}"]
image_id = "${data.aws_ami.amazon_centos_7.image_id}"
key_pair = "CircleCI"
instance_type = "t2.micro"
resource_name = "ec2_ar_centos7_no_codedeploy"
install_codedeploy_agent = false
enable_ebs_optimization = "False"
tenancy = "default"
backup_tag_value = "False"
detailed_monitoring = "True"
ssm_patching_group = "Group1Patching"
primary_ebs_volume_size = "60"
primary_ebs_volume_iops = "0"
primary_ebs_volume_type = "gp2"
secondary_ebs_volume_size = "60"
secondary_ebs_volume_iops = "0"
secondary_ebs_volume_type = "gp2"
encrypt_secondary_ebs_volume = "False"

ebs_volume_tags = {
MyTag1 = "MyValue1"
MyTag2 = "MyValue2"
MyTag3 = "MyValue3"
}

environment = "Development"
instance_role_managed_policy_arns = ["arn:aws:iam::aws:policy/AmazonEC2FullAccess", "arn:aws:iam::aws:policy/service-role/AmazonEC2SpotFleetRole", "arn:aws:iam::aws:policy/CloudWatchActionsEC2Access"]
perform_ssm_inventory_tag = "True"
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ variable "backup_tag_value" {
default = "False"
}

variable "ebs_volume_tags" {
description = "(Optional) A mapping of tags to assign to the devices created by the instance at launch time."
type = "map"
default = {}
}

variable "enable_ebs_optimization" {
description = "Use EBS Optimized? true or false"
type = "string"
Expand Down

0 comments on commit 4d3c674

Please sign in to comment.