From caccdf265416ffb00a3dfd34849c9185ba8360cc Mon Sep 17 00:00:00 2001 From: Samuel CHNIBER Date: Tue, 19 Jul 2022 16:52:31 +0200 Subject: [PATCH 01/12] fix bug for capacity reservation id assignment --- main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.tf b/main.tf index b4eb9d3b..5d0ec624 100644 --- a/main.tf +++ b/main.tf @@ -42,7 +42,7 @@ resource "aws_instance" "this" { dynamic "capacity_reservation_target" { for_each = lookup(capacity_reservation_specification.value, "capacity_reservation_target", []) content { - capacity_reservation_id = lookup(capacity_reservation_target.value, "capacity_reservation_id", null) + capacity_reservation_id = lookup(capacity_reservation_target, "capacity_reservation_id", null) } } } From f6eb088b234f799925bd80541d818c2936e9da09 Mon Sep 17 00:00:00 2001 From: Samuel CHNIBER Date: Tue, 19 Jul 2022 17:47:42 +0200 Subject: [PATCH 02/12] addition of test case --- examples/complete/main.tf | 24 +++ examples/complete/outputs.tf | 408 +++++++++++++++++------------------ 2 files changed, 228 insertions(+), 204 deletions(-) diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 257ff71c..16195713 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -328,3 +328,27 @@ module "ec2_spot_instance" { tags = local.tags } + +################################################################################ +# EC2 Module - Capacity Reservation +################################################################################ + +module "ec2_capacity_reservation" { + source = "../../" + + name = "${local.name}-capacity-reservation" + + ami = data.aws_ami.amazon_linux.id + instance_type = "u-6tb1.56xlarge" + subnet_id = element(module.vpc.private_subnets, 0) + vpc_security_group_ids = [module.security_group.security_group_id] + associate_public_ip_address = true + + capacity_reservation_specification = { + capacity_reservation_target = { + capacity_reservation_id = "cr-00000000000000000" + } + } + + tags = local.tags +} \ No newline at end of file diff --git a/examples/complete/outputs.tf b/examples/complete/outputs.tf index e87dfe82..5ebf00ea 100644 --- a/examples/complete/outputs.tf +++ b/examples/complete/outputs.tf @@ -1,204 +1,204 @@ -# EC2 Complete -output "ec2_complete_id" { - description = "The ID of the instance" - value = module.ec2_complete.id -} - -output "ec2_complete_arn" { - description = "The ARN of the instance" - value = module.ec2_complete.arn -} - -output "ec2_complete_capacity_reservation_specification" { - description = "Capacity reservation specification of the instance" - value = module.ec2_complete.capacity_reservation_specification -} - -output "ec2_complete_instance_state" { - description = "The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped`" - value = module.ec2_complete.instance_state -} - -output "ec2_complete_primary_network_interface_id" { - description = "The ID of the instance's primary network interface" - value = module.ec2_complete.primary_network_interface_id -} - -output "ec2_complete_private_dns" { - description = "The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC" - value = module.ec2_complete.private_dns -} - -output "ec2_complete_public_dns" { - description = "The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC" - value = module.ec2_complete.public_dns -} - -output "ec2_complete_public_ip" { - description = "The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached" - value = module.ec2_complete.public_ip -} - -output "ec2_complete_tags_all" { - description = "A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block" - value = module.ec2_complete.tags_all -} - -# EC2 T2 Unlimited -output "ec2_t2_unlimited_id" { - description = "The ID of the instance" - value = module.ec2_t2_unlimited.id -} - -output "ec2_t2_unlimited_arn" { - description = "The ARN of the instance" - value = module.ec2_t2_unlimited.arn -} - -output "ec2_t2_unlimited_capacity_reservation_specification" { - description = "Capacity reservation specification of the instance" - value = module.ec2_t2_unlimited.capacity_reservation_specification -} - -output "ec2_t2_unlimited_instance_state" { - description = "The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped`" - value = module.ec2_t2_unlimited.instance_state -} - -output "ec2_t2_unlimited_primary_network_interface_id" { - description = "The ID of the instance's primary network interface" - value = module.ec2_t2_unlimited.primary_network_interface_id -} - -output "ec2_t2_unlimited_private_dns" { - description = "The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC" - value = module.ec2_t2_unlimited.private_dns -} - -output "ec2_t2_unlimited_public_dns" { - description = "The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC" - value = module.ec2_t2_unlimited.public_dns -} - -output "ec2_t2_unlimited_public_ip" { - description = "The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached" - value = module.ec2_t2_unlimited.public_ip -} - -output "ec2_t2_unlimited_tags_all" { - description = "A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block" - value = module.ec2_t2_unlimited.tags_all -} - -# EC2 T3 Unlimited -output "ec2_t3_unlimited_id" { - description = "The ID of the instance" - value = module.ec2_t3_unlimited.id -} - -output "ec2_t3_unlimited_arn" { - description = "The ARN of the instance" - value = module.ec2_t3_unlimited.arn -} - -output "ec2_t3_unlimited_capacity_reservation_specification" { - description = "Capacity reservation specification of the instance" - value = module.ec2_t3_unlimited.capacity_reservation_specification -} - -output "ec2_t3_unlimited_instance_state" { - description = "The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped`" - value = module.ec2_t3_unlimited.instance_state -} - -output "ec2_t3_unlimited_primary_network_interface_id" { - description = "The ID of the instance's primary network interface" - value = module.ec2_t3_unlimited.primary_network_interface_id -} - -output "ec2_t3_unlimited_private_dns" { - description = "The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC" - value = module.ec2_t3_unlimited.private_dns -} - -output "ec2_t3_unlimited_public_dns" { - description = "The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC" - value = module.ec2_t3_unlimited.public_dns -} - -output "ec2_t3_unlimited_public_ip" { - description = "The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached" - value = module.ec2_t3_unlimited.public_ip -} - -output "ec2_t3_unlimited_tags_all" { - description = "A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block" - value = module.ec2_t3_unlimited.tags_all -} - -# EC2 Multiple -output "ec2_multiple" { - description = "The full output of the `ec2_module` module" - value = module.ec2_multiple -} - -# EC2 Spot Instance -output "ec2_spot_instance_id" { - description = "The ID of the instance" - value = module.ec2_spot_instance.id -} - -output "ec2_spot_instance_arn" { - description = "The ARN of the instance" - value = module.ec2_spot_instance.arn -} - -output "ec2_spot_instance_capacity_reservation_specification" { - description = "Capacity reservation specification of the instance" - value = module.ec2_spot_instance.capacity_reservation_specification -} - -output "ec2_spot_instance_instance_state" { - description = "The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped`" - value = module.ec2_spot_instance.instance_state -} - -output "ec2_spot_instance_primary_network_interface_id" { - description = "The ID of the instance's primary network interface" - value = module.ec2_spot_instance.primary_network_interface_id -} - -output "ec2_spot_instance_private_dns" { - description = "The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC" - value = module.ec2_spot_instance.private_dns -} - -output "ec2_spot_instance_public_dns" { - description = "The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC" - value = module.ec2_spot_instance.public_dns -} - -output "ec2_spot_instance_public_ip" { - description = "The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached" - value = module.ec2_spot_instance.public_ip -} - -output "ec2_spot_instance_tags_all" { - description = "A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block" - value = module.ec2_spot_instance.tags_all -} - -output "spot_bid_status" { - description = "The current bid status of the Spot Instance Request" - value = module.ec2_spot_instance.spot_bid_status -} - -output "spot_request_state" { - description = "The current request state of the Spot Instance Request" - value = module.ec2_spot_instance.spot_request_state -} - -output "spot_instance_id" { - description = "The Instance ID (if any) that is currently fulfilling the Spot Instance request" - value = module.ec2_spot_instance.spot_instance_id -} +# # EC2 Complete +# output "ec2_complete_id" { +# description = "The ID of the instance" +# value = module.ec2_complete.id +# } + +# output "ec2_complete_arn" { +# description = "The ARN of the instance" +# value = module.ec2_complete.arn +# } + +# output "ec2_complete_capacity_reservation_specification" { +# description = "Capacity reservation specification of the instance" +# value = module.ec2_complete.capacity_reservation_specification +# } + +# output "ec2_complete_instance_state" { +# description = "The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped`" +# value = module.ec2_complete.instance_state +# } + +# output "ec2_complete_primary_network_interface_id" { +# description = "The ID of the instance's primary network interface" +# value = module.ec2_complete.primary_network_interface_id +# } + +# output "ec2_complete_private_dns" { +# description = "The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC" +# value = module.ec2_complete.private_dns +# } + +# output "ec2_complete_public_dns" { +# description = "The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC" +# value = module.ec2_complete.public_dns +# } + +# output "ec2_complete_public_ip" { +# description = "The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached" +# value = module.ec2_complete.public_ip +# } + +# output "ec2_complete_tags_all" { +# description = "A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block" +# value = module.ec2_complete.tags_all +# } + +# # EC2 T2 Unlimited +# output "ec2_t2_unlimited_id" { +# description = "The ID of the instance" +# value = module.ec2_t2_unlimited.id +# } + +# output "ec2_t2_unlimited_arn" { +# description = "The ARN of the instance" +# value = module.ec2_t2_unlimited.arn +# } + +# output "ec2_t2_unlimited_capacity_reservation_specification" { +# description = "Capacity reservation specification of the instance" +# value = module.ec2_t2_unlimited.capacity_reservation_specification +# } + +# output "ec2_t2_unlimited_instance_state" { +# description = "The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped`" +# value = module.ec2_t2_unlimited.instance_state +# } + +# output "ec2_t2_unlimited_primary_network_interface_id" { +# description = "The ID of the instance's primary network interface" +# value = module.ec2_t2_unlimited.primary_network_interface_id +# } + +# output "ec2_t2_unlimited_private_dns" { +# description = "The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC" +# value = module.ec2_t2_unlimited.private_dns +# } + +# output "ec2_t2_unlimited_public_dns" { +# description = "The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC" +# value = module.ec2_t2_unlimited.public_dns +# } + +# output "ec2_t2_unlimited_public_ip" { +# description = "The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached" +# value = module.ec2_t2_unlimited.public_ip +# } + +# output "ec2_t2_unlimited_tags_all" { +# description = "A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block" +# value = module.ec2_t2_unlimited.tags_all +# } + +# # EC2 T3 Unlimited +# output "ec2_t3_unlimited_id" { +# description = "The ID of the instance" +# value = module.ec2_t3_unlimited.id +# } + +# output "ec2_t3_unlimited_arn" { +# description = "The ARN of the instance" +# value = module.ec2_t3_unlimited.arn +# } + +# output "ec2_t3_unlimited_capacity_reservation_specification" { +# description = "Capacity reservation specification of the instance" +# value = module.ec2_t3_unlimited.capacity_reservation_specification +# } + +# output "ec2_t3_unlimited_instance_state" { +# description = "The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped`" +# value = module.ec2_t3_unlimited.instance_state +# } + +# output "ec2_t3_unlimited_primary_network_interface_id" { +# description = "The ID of the instance's primary network interface" +# value = module.ec2_t3_unlimited.primary_network_interface_id +# } + +# output "ec2_t3_unlimited_private_dns" { +# description = "The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC" +# value = module.ec2_t3_unlimited.private_dns +# } + +# output "ec2_t3_unlimited_public_dns" { +# description = "The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC" +# value = module.ec2_t3_unlimited.public_dns +# } + +# output "ec2_t3_unlimited_public_ip" { +# description = "The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached" +# value = module.ec2_t3_unlimited.public_ip +# } + +# output "ec2_t3_unlimited_tags_all" { +# description = "A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block" +# value = module.ec2_t3_unlimited.tags_all +# } + +# # EC2 Multiple +# output "ec2_multiple" { +# description = "The full output of the `ec2_module` module" +# value = module.ec2_multiple +# } + +# # EC2 Spot Instance +# output "ec2_spot_instance_id" { +# description = "The ID of the instance" +# value = module.ec2_spot_instance.id +# } + +# output "ec2_spot_instance_arn" { +# description = "The ARN of the instance" +# value = module.ec2_spot_instance.arn +# } + +# output "ec2_spot_instance_capacity_reservation_specification" { +# description = "Capacity reservation specification of the instance" +# value = module.ec2_spot_instance.capacity_reservation_specification +# } + +# output "ec2_spot_instance_instance_state" { +# description = "The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped`" +# value = module.ec2_spot_instance.instance_state +# } + +# output "ec2_spot_instance_primary_network_interface_id" { +# description = "The ID of the instance's primary network interface" +# value = module.ec2_spot_instance.primary_network_interface_id +# } + +# output "ec2_spot_instance_private_dns" { +# description = "The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC" +# value = module.ec2_spot_instance.private_dns +# } + +# output "ec2_spot_instance_public_dns" { +# description = "The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC" +# value = module.ec2_spot_instance.public_dns +# } + +# output "ec2_spot_instance_public_ip" { +# description = "The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached" +# value = module.ec2_spot_instance.public_ip +# } + +# output "ec2_spot_instance_tags_all" { +# description = "A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block" +# value = module.ec2_spot_instance.tags_all +# } + +# output "spot_bid_status" { +# description = "The current bid status of the Spot Instance Request" +# value = module.ec2_spot_instance.spot_bid_status +# } + +# output "spot_request_state" { +# description = "The current request state of the Spot Instance Request" +# value = module.ec2_spot_instance.spot_request_state +# } + +# output "spot_instance_id" { +# description = "The Instance ID (if any) that is currently fulfilling the Spot Instance request" +# value = module.ec2_spot_instance.spot_instance_id +# } From 144e839223bbefc4240bba5d2f2955927ec6e653 Mon Sep 17 00:00:00 2001 From: Samuel CHNIBER Date: Tue, 19 Jul 2022 17:49:43 +0200 Subject: [PATCH 03/12] revert of outputs in complete test case --- examples/complete/outputs.tf | 408 +++++++++++++++++------------------ 1 file changed, 204 insertions(+), 204 deletions(-) diff --git a/examples/complete/outputs.tf b/examples/complete/outputs.tf index 5ebf00ea..e87dfe82 100644 --- a/examples/complete/outputs.tf +++ b/examples/complete/outputs.tf @@ -1,204 +1,204 @@ -# # EC2 Complete -# output "ec2_complete_id" { -# description = "The ID of the instance" -# value = module.ec2_complete.id -# } - -# output "ec2_complete_arn" { -# description = "The ARN of the instance" -# value = module.ec2_complete.arn -# } - -# output "ec2_complete_capacity_reservation_specification" { -# description = "Capacity reservation specification of the instance" -# value = module.ec2_complete.capacity_reservation_specification -# } - -# output "ec2_complete_instance_state" { -# description = "The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped`" -# value = module.ec2_complete.instance_state -# } - -# output "ec2_complete_primary_network_interface_id" { -# description = "The ID of the instance's primary network interface" -# value = module.ec2_complete.primary_network_interface_id -# } - -# output "ec2_complete_private_dns" { -# description = "The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC" -# value = module.ec2_complete.private_dns -# } - -# output "ec2_complete_public_dns" { -# description = "The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC" -# value = module.ec2_complete.public_dns -# } - -# output "ec2_complete_public_ip" { -# description = "The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached" -# value = module.ec2_complete.public_ip -# } - -# output "ec2_complete_tags_all" { -# description = "A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block" -# value = module.ec2_complete.tags_all -# } - -# # EC2 T2 Unlimited -# output "ec2_t2_unlimited_id" { -# description = "The ID of the instance" -# value = module.ec2_t2_unlimited.id -# } - -# output "ec2_t2_unlimited_arn" { -# description = "The ARN of the instance" -# value = module.ec2_t2_unlimited.arn -# } - -# output "ec2_t2_unlimited_capacity_reservation_specification" { -# description = "Capacity reservation specification of the instance" -# value = module.ec2_t2_unlimited.capacity_reservation_specification -# } - -# output "ec2_t2_unlimited_instance_state" { -# description = "The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped`" -# value = module.ec2_t2_unlimited.instance_state -# } - -# output "ec2_t2_unlimited_primary_network_interface_id" { -# description = "The ID of the instance's primary network interface" -# value = module.ec2_t2_unlimited.primary_network_interface_id -# } - -# output "ec2_t2_unlimited_private_dns" { -# description = "The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC" -# value = module.ec2_t2_unlimited.private_dns -# } - -# output "ec2_t2_unlimited_public_dns" { -# description = "The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC" -# value = module.ec2_t2_unlimited.public_dns -# } - -# output "ec2_t2_unlimited_public_ip" { -# description = "The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached" -# value = module.ec2_t2_unlimited.public_ip -# } - -# output "ec2_t2_unlimited_tags_all" { -# description = "A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block" -# value = module.ec2_t2_unlimited.tags_all -# } - -# # EC2 T3 Unlimited -# output "ec2_t3_unlimited_id" { -# description = "The ID of the instance" -# value = module.ec2_t3_unlimited.id -# } - -# output "ec2_t3_unlimited_arn" { -# description = "The ARN of the instance" -# value = module.ec2_t3_unlimited.arn -# } - -# output "ec2_t3_unlimited_capacity_reservation_specification" { -# description = "Capacity reservation specification of the instance" -# value = module.ec2_t3_unlimited.capacity_reservation_specification -# } - -# output "ec2_t3_unlimited_instance_state" { -# description = "The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped`" -# value = module.ec2_t3_unlimited.instance_state -# } - -# output "ec2_t3_unlimited_primary_network_interface_id" { -# description = "The ID of the instance's primary network interface" -# value = module.ec2_t3_unlimited.primary_network_interface_id -# } - -# output "ec2_t3_unlimited_private_dns" { -# description = "The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC" -# value = module.ec2_t3_unlimited.private_dns -# } - -# output "ec2_t3_unlimited_public_dns" { -# description = "The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC" -# value = module.ec2_t3_unlimited.public_dns -# } - -# output "ec2_t3_unlimited_public_ip" { -# description = "The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached" -# value = module.ec2_t3_unlimited.public_ip -# } - -# output "ec2_t3_unlimited_tags_all" { -# description = "A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block" -# value = module.ec2_t3_unlimited.tags_all -# } - -# # EC2 Multiple -# output "ec2_multiple" { -# description = "The full output of the `ec2_module` module" -# value = module.ec2_multiple -# } - -# # EC2 Spot Instance -# output "ec2_spot_instance_id" { -# description = "The ID of the instance" -# value = module.ec2_spot_instance.id -# } - -# output "ec2_spot_instance_arn" { -# description = "The ARN of the instance" -# value = module.ec2_spot_instance.arn -# } - -# output "ec2_spot_instance_capacity_reservation_specification" { -# description = "Capacity reservation specification of the instance" -# value = module.ec2_spot_instance.capacity_reservation_specification -# } - -# output "ec2_spot_instance_instance_state" { -# description = "The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped`" -# value = module.ec2_spot_instance.instance_state -# } - -# output "ec2_spot_instance_primary_network_interface_id" { -# description = "The ID of the instance's primary network interface" -# value = module.ec2_spot_instance.primary_network_interface_id -# } - -# output "ec2_spot_instance_private_dns" { -# description = "The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC" -# value = module.ec2_spot_instance.private_dns -# } - -# output "ec2_spot_instance_public_dns" { -# description = "The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC" -# value = module.ec2_spot_instance.public_dns -# } - -# output "ec2_spot_instance_public_ip" { -# description = "The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached" -# value = module.ec2_spot_instance.public_ip -# } - -# output "ec2_spot_instance_tags_all" { -# description = "A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block" -# value = module.ec2_spot_instance.tags_all -# } - -# output "spot_bid_status" { -# description = "The current bid status of the Spot Instance Request" -# value = module.ec2_spot_instance.spot_bid_status -# } - -# output "spot_request_state" { -# description = "The current request state of the Spot Instance Request" -# value = module.ec2_spot_instance.spot_request_state -# } - -# output "spot_instance_id" { -# description = "The Instance ID (if any) that is currently fulfilling the Spot Instance request" -# value = module.ec2_spot_instance.spot_instance_id -# } +# EC2 Complete +output "ec2_complete_id" { + description = "The ID of the instance" + value = module.ec2_complete.id +} + +output "ec2_complete_arn" { + description = "The ARN of the instance" + value = module.ec2_complete.arn +} + +output "ec2_complete_capacity_reservation_specification" { + description = "Capacity reservation specification of the instance" + value = module.ec2_complete.capacity_reservation_specification +} + +output "ec2_complete_instance_state" { + description = "The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped`" + value = module.ec2_complete.instance_state +} + +output "ec2_complete_primary_network_interface_id" { + description = "The ID of the instance's primary network interface" + value = module.ec2_complete.primary_network_interface_id +} + +output "ec2_complete_private_dns" { + description = "The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC" + value = module.ec2_complete.private_dns +} + +output "ec2_complete_public_dns" { + description = "The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC" + value = module.ec2_complete.public_dns +} + +output "ec2_complete_public_ip" { + description = "The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached" + value = module.ec2_complete.public_ip +} + +output "ec2_complete_tags_all" { + description = "A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block" + value = module.ec2_complete.tags_all +} + +# EC2 T2 Unlimited +output "ec2_t2_unlimited_id" { + description = "The ID of the instance" + value = module.ec2_t2_unlimited.id +} + +output "ec2_t2_unlimited_arn" { + description = "The ARN of the instance" + value = module.ec2_t2_unlimited.arn +} + +output "ec2_t2_unlimited_capacity_reservation_specification" { + description = "Capacity reservation specification of the instance" + value = module.ec2_t2_unlimited.capacity_reservation_specification +} + +output "ec2_t2_unlimited_instance_state" { + description = "The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped`" + value = module.ec2_t2_unlimited.instance_state +} + +output "ec2_t2_unlimited_primary_network_interface_id" { + description = "The ID of the instance's primary network interface" + value = module.ec2_t2_unlimited.primary_network_interface_id +} + +output "ec2_t2_unlimited_private_dns" { + description = "The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC" + value = module.ec2_t2_unlimited.private_dns +} + +output "ec2_t2_unlimited_public_dns" { + description = "The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC" + value = module.ec2_t2_unlimited.public_dns +} + +output "ec2_t2_unlimited_public_ip" { + description = "The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached" + value = module.ec2_t2_unlimited.public_ip +} + +output "ec2_t2_unlimited_tags_all" { + description = "A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block" + value = module.ec2_t2_unlimited.tags_all +} + +# EC2 T3 Unlimited +output "ec2_t3_unlimited_id" { + description = "The ID of the instance" + value = module.ec2_t3_unlimited.id +} + +output "ec2_t3_unlimited_arn" { + description = "The ARN of the instance" + value = module.ec2_t3_unlimited.arn +} + +output "ec2_t3_unlimited_capacity_reservation_specification" { + description = "Capacity reservation specification of the instance" + value = module.ec2_t3_unlimited.capacity_reservation_specification +} + +output "ec2_t3_unlimited_instance_state" { + description = "The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped`" + value = module.ec2_t3_unlimited.instance_state +} + +output "ec2_t3_unlimited_primary_network_interface_id" { + description = "The ID of the instance's primary network interface" + value = module.ec2_t3_unlimited.primary_network_interface_id +} + +output "ec2_t3_unlimited_private_dns" { + description = "The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC" + value = module.ec2_t3_unlimited.private_dns +} + +output "ec2_t3_unlimited_public_dns" { + description = "The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC" + value = module.ec2_t3_unlimited.public_dns +} + +output "ec2_t3_unlimited_public_ip" { + description = "The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached" + value = module.ec2_t3_unlimited.public_ip +} + +output "ec2_t3_unlimited_tags_all" { + description = "A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block" + value = module.ec2_t3_unlimited.tags_all +} + +# EC2 Multiple +output "ec2_multiple" { + description = "The full output of the `ec2_module` module" + value = module.ec2_multiple +} + +# EC2 Spot Instance +output "ec2_spot_instance_id" { + description = "The ID of the instance" + value = module.ec2_spot_instance.id +} + +output "ec2_spot_instance_arn" { + description = "The ARN of the instance" + value = module.ec2_spot_instance.arn +} + +output "ec2_spot_instance_capacity_reservation_specification" { + description = "Capacity reservation specification of the instance" + value = module.ec2_spot_instance.capacity_reservation_specification +} + +output "ec2_spot_instance_instance_state" { + description = "The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped`" + value = module.ec2_spot_instance.instance_state +} + +output "ec2_spot_instance_primary_network_interface_id" { + description = "The ID of the instance's primary network interface" + value = module.ec2_spot_instance.primary_network_interface_id +} + +output "ec2_spot_instance_private_dns" { + description = "The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC" + value = module.ec2_spot_instance.private_dns +} + +output "ec2_spot_instance_public_dns" { + description = "The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC" + value = module.ec2_spot_instance.public_dns +} + +output "ec2_spot_instance_public_ip" { + description = "The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached" + value = module.ec2_spot_instance.public_ip +} + +output "ec2_spot_instance_tags_all" { + description = "A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block" + value = module.ec2_spot_instance.tags_all +} + +output "spot_bid_status" { + description = "The current bid status of the Spot Instance Request" + value = module.ec2_spot_instance.spot_bid_status +} + +output "spot_request_state" { + description = "The current request state of the Spot Instance Request" + value = module.ec2_spot_instance.spot_request_state +} + +output "spot_instance_id" { + description = "The Instance ID (if any) that is currently fulfilling the Spot Instance request" + value = module.ec2_spot_instance.spot_instance_id +} From f42d393a8048e9bc9c48631b01714a6d6d247747 Mon Sep 17 00:00:00 2001 From: Samuel CHNIBER Date: Tue, 19 Jul 2022 18:01:43 +0200 Subject: [PATCH 04/12] fix formatting and tfdocs --- README.md | 17 ----------------- examples/complete/main.tf | 6 +++--- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 0b9c423e..cec1ad19 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -# AWS EC2 Instance Terraform module - Terraform module which creates an EC2 instance on AWS. [![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md) @@ -265,18 +263,3 @@ No modules. | [spot\_instance\_id](#output\_spot\_instance\_id) | The Instance ID (if any) that is currently fulfilling the Spot Instance request | | [spot\_request\_state](#output\_spot\_request\_state) | The current request state of the Spot Instance Request | | [tags\_all](#output\_tags\_all) | A map of tags assigned to the resource, including those inherited from the provider default\_tags configuration block | - - -## Authors - -Module is maintained by [Anton Babenko](https://github.com/antonbabenko) with help from [these awesome contributors](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/graphs/contributors). - -## License - -Apache 2 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/tree/master/LICENSE) for full details. - -## Additional information for users from Russia and Belarus - -* Russia has [illegally annexed Crimea in 2014](https://en.wikipedia.org/wiki/Annexation_of_Crimea_by_the_Russian_Federation) and [brought the war in Donbas](https://en.wikipedia.org/wiki/War_in_Donbas) followed by [full-scale invasion of Ukraine in 2022](https://en.wikipedia.org/wiki/2022_Russian_invasion_of_Ukraine). -* Russia has brought sorrow and devastations to millions of Ukrainians, killed hundreds of innocent people, damaged thousands of buildings, and forced several million people to flee. -* [Putin khuylo!](https://en.wikipedia.org/wiki/Putin_khuylo!) diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 16195713..d6c446db 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -345,10 +345,10 @@ module "ec2_capacity_reservation" { associate_public_ip_address = true capacity_reservation_specification = { - capacity_reservation_target = { - capacity_reservation_id = "cr-00000000000000000" - } + capacity_reservation_target = { + capacity_reservation_id = "cr-00000000000000000" } + } tags = local.tags } \ No newline at end of file From b3ecfc9501e6da5e70eb9047aae1ac45f4f8e219 Mon Sep 17 00:00:00 2001 From: Samuel CHNIBER Date: Tue, 19 Jul 2022 18:02:58 +0200 Subject: [PATCH 05/12] fix formatting and tfdocs --- examples/complete/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/complete/README.md b/examples/complete/README.md index 9455766e..b058811a 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -26,12 +26,13 @@ Note that this example may create resources which can cost money. Run `terraform | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 4.7 | +| [aws](#provider\_aws) | 4.22.0 | ## Modules | Name | Source | Version | |------|--------|---------| +| [ec2\_capacity\_reservation](#module\_ec2\_capacity\_reservation) | ../../ | n/a | | [ec2\_complete](#module\_ec2\_complete) | ../../ | n/a | | [ec2\_disabled](#module\_ec2\_disabled) | ../../ | n/a | | [ec2\_metadata\_options](#module\_ec2\_metadata\_options) | ../../ | n/a | @@ -100,4 +101,3 @@ No inputs. | [spot\_bid\_status](#output\_spot\_bid\_status) | The current bid status of the Spot Instance Request | | [spot\_instance\_id](#output\_spot\_instance\_id) | The Instance ID (if any) that is currently fulfilling the Spot Instance request | | [spot\_request\_state](#output\_spot\_request\_state) | The current request state of the Spot Instance Request | - From 0fa3739501ec4623743c008f9dc1cefedc0420f0 Mon Sep 17 00:00:00 2001 From: Samuel CHNIBER Date: Tue, 19 Jul 2022 18:08:52 +0200 Subject: [PATCH 06/12] run of pre-commit hooks --- README.md | 102 ------------------------------------ examples/complete/README.md | 86 ------------------------------ examples/complete/main.tf | 2 +- 3 files changed, 1 insertion(+), 189 deletions(-) diff --git a/README.md b/README.md index cec1ad19..eab40a2e 100644 --- a/README.md +++ b/README.md @@ -161,105 +161,3 @@ The following combinations are supported to conditionally create resources: - In regards to spot instances, you must grant the `AWSServiceRoleForEC2Spot` service-linked role access to any custom KMS keys, otherwise your spot request and instances will fail with `bad parameters`. You can see more details about why the request failed by using the awscli and `aws ec2 describe-spot-instance-requests` -## Requirements - -| Name | Version | -|------|---------| -| [terraform](#requirement\_terraform) | >= 0.13.1 | -| [aws](#requirement\_aws) | >= 4.20.0 | - -## Providers - -| Name | Version | -|------|---------| -| [aws](#provider\_aws) | >= 4.20.0 | - -## Modules - -No modules. - -## Resources - -| Name | Type | -|------|------| -| [aws_instance.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance) | resource | -| [aws_spot_instance_request.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/spot_instance_request) | resource | - -## Inputs - -| Name | Description | Type | Default | Required | -|------|-------------|------|---------|:--------:| -| [ami](#input\_ami) | ID of AMI to use for the instance | `string` | `""` | no | -| [associate\_public\_ip\_address](#input\_associate\_public\_ip\_address) | Whether to associate a public IP address with an instance in a VPC | `bool` | `null` | no | -| [availability\_zone](#input\_availability\_zone) | AZ to start the instance in | `string` | `null` | no | -| [capacity\_reservation\_specification](#input\_capacity\_reservation\_specification) | Describes an instance's Capacity Reservation targeting option | `any` | `null` | no | -| [cpu\_core\_count](#input\_cpu\_core\_count) | Sets the number of CPU cores for an instance. | `number` | `null` | no | -| [cpu\_credits](#input\_cpu\_credits) | The credit option for CPU usage (unlimited or standard) | `string` | `null` | no | -| [cpu\_threads\_per\_core](#input\_cpu\_threads\_per\_core) | Sets the number of CPU threads per core for an instance (has no effect unless cpu\_core\_count is also set). | `number` | `null` | no | -| [create](#input\_create) | Whether to create an instance | `bool` | `true` | no | -| [create\_spot\_instance](#input\_create\_spot\_instance) | Depicts if the instance is a spot instance | `bool` | `false` | no | -| [disable\_api\_stop](#input\_disable\_api\_stop) | If true, enables EC2 Instance Stop Protection. | `bool` | `null` | no | -| [disable\_api\_termination](#input\_disable\_api\_termination) | If true, enables EC2 Instance Termination Protection | `bool` | `null` | no | -| [ebs\_block\_device](#input\_ebs\_block\_device) | Additional EBS block devices to attach to the instance | `list(map(string))` | `[]` | no | -| [ebs\_optimized](#input\_ebs\_optimized) | If true, the launched EC2 instance will be EBS-optimized | `bool` | `null` | no | -| [enable\_volume\_tags](#input\_enable\_volume\_tags) | Whether to enable volume tags (if enabled it conflicts with root\_block\_device tags) | `bool` | `true` | no | -| [enclave\_options\_enabled](#input\_enclave\_options\_enabled) | Whether Nitro Enclaves will be enabled on the instance. Defaults to `false` | `bool` | `null` | no | -| [ephemeral\_block\_device](#input\_ephemeral\_block\_device) | Customize Ephemeral (also known as Instance Store) volumes on the instance | `list(map(string))` | `[]` | no | -| [get\_password\_data](#input\_get\_password\_data) | If true, wait for password data to become available and retrieve it. | `bool` | `null` | no | -| [hibernation](#input\_hibernation) | If true, the launched EC2 instance will support hibernation | `bool` | `null` | no | -| [host\_id](#input\_host\_id) | ID of a dedicated host that the instance will be assigned to. Use when an instance is to be launched on a specific dedicated host | `string` | `null` | no | -| [iam\_instance\_profile](#input\_iam\_instance\_profile) | IAM Instance Profile to launch the instance with. Specified as the name of the Instance Profile | `string` | `null` | no | -| [instance\_initiated\_shutdown\_behavior](#input\_instance\_initiated\_shutdown\_behavior) | Shutdown behavior for the instance. Amazon defaults this to stop for EBS-backed instances and terminate for instance-store instances. Cannot be set on instance-store instance | `string` | `null` | no | -| [instance\_type](#input\_instance\_type) | The type of instance to start | `string` | `"t3.micro"` | no | -| [ipv6\_address\_count](#input\_ipv6\_address\_count) | A number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet | `number` | `null` | no | -| [ipv6\_addresses](#input\_ipv6\_addresses) | Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface | `list(string)` | `null` | no | -| [key\_name](#input\_key\_name) | Key name of the Key Pair to use for the instance; which can be managed using the `aws_key_pair` resource | `string` | `null` | no | -| [launch\_template](#input\_launch\_template) | Specifies a Launch Template to configure the instance. Parameters configured on this resource will override the corresponding parameters in the Launch Template | `map(string)` | `null` | no | -| [metadata\_options](#input\_metadata\_options) | Customize the metadata options of the instance | `map(string)` | `{}` | no | -| [monitoring](#input\_monitoring) | If true, the launched EC2 instance will have detailed monitoring enabled | `bool` | `false` | no | -| [name](#input\_name) | Name to be used on EC2 instance created | `string` | `""` | no | -| [network\_interface](#input\_network\_interface) | Customize network interfaces to be attached at instance boot time | `list(map(string))` | `[]` | no | -| [placement\_group](#input\_placement\_group) | The Placement Group to start the instance in | `string` | `null` | no | -| [private\_ip](#input\_private\_ip) | Private IP address to associate with the instance in a VPC | `string` | `null` | no | -| [putin\_khuylo](#input\_putin\_khuylo) | Do you agree that Putin doesn't respect Ukrainian sovereignty and territorial integrity? More info: https://en.wikipedia.org/wiki/Putin_khuylo! | `bool` | `true` | no | -| [root\_block\_device](#input\_root\_block\_device) | Customize details about the root block device of the instance. See Block Devices below for details | `list(any)` | `[]` | no | -| [secondary\_private\_ips](#input\_secondary\_private\_ips) | A list of secondary private IPv4 addresses to assign to the instance's primary network interface (eth0) in a VPC. Can only be assigned to the primary network interface (eth0) attached at instance creation, not a pre-existing network interface i.e. referenced in a `network_interface block` | `list(string)` | `null` | no | -| [source\_dest\_check](#input\_source\_dest\_check) | Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs. | `bool` | `true` | no | -| [spot\_block\_duration\_minutes](#input\_spot\_block\_duration\_minutes) | The required duration for the Spot instances, in minutes. This value must be a multiple of 60 (60, 120, 180, 240, 300, or 360) | `number` | `null` | no | -| [spot\_instance\_interruption\_behavior](#input\_spot\_instance\_interruption\_behavior) | Indicates Spot instance behavior when it is interrupted. Valid values are `terminate`, `stop`, or `hibernate` | `string` | `null` | no | -| [spot\_launch\_group](#input\_spot\_launch\_group) | A launch group is a group of spot instances that launch together and terminate together. If left empty instances are launched and terminated individually | `string` | `null` | no | -| [spot\_price](#input\_spot\_price) | The maximum price to request on the spot market. Defaults to on-demand price | `string` | `null` | no | -| [spot\_type](#input\_spot\_type) | If set to one-time, after the instance is terminated, the spot request will be closed. Default `persistent` | `string` | `null` | no | -| [spot\_valid\_from](#input\_spot\_valid\_from) | The start date and time of the request, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ) | `string` | `null` | no | -| [spot\_valid\_until](#input\_spot\_valid\_until) | The end date and time of the request, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ) | `string` | `null` | no | -| [spot\_wait\_for\_fulfillment](#input\_spot\_wait\_for\_fulfillment) | If set, Terraform will wait for the Spot Request to be fulfilled, and will throw an error if the timeout of 10m is reached | `bool` | `null` | no | -| [subnet\_id](#input\_subnet\_id) | The VPC Subnet ID to launch in | `string` | `null` | no | -| [tags](#input\_tags) | A mapping of tags to assign to the resource | `map(string)` | `{}` | no | -| [tenancy](#input\_tenancy) | The tenancy of the instance (if the instance is running in a VPC). Available values: default, dedicated, host. | `string` | `null` | no | -| [timeouts](#input\_timeouts) | Define maximum timeout for creating, updating, and deleting EC2 instance resources | `map(string)` | `{}` | no | -| [user\_data](#input\_user\_data) | The user data to provide when launching the instance. Do not pass gzip-compressed data via this argument; see user\_data\_base64 instead. | `string` | `null` | no | -| [user\_data\_base64](#input\_user\_data\_base64) | Can be used instead of user\_data to pass base64-encoded binary data directly. Use this instead of user\_data whenever the value is not a valid UTF-8 string. For example, gzip-encoded user data must be base64-encoded and passed via this argument to avoid corruption. | `string` | `null` | no | -| [user\_data\_replace\_on\_change](#input\_user\_data\_replace\_on\_change) | When used in combination with user\_data or user\_data\_base64 will trigger a destroy and recreate when set to true. Defaults to false if not set. | `bool` | `false` | no | -| [volume\_tags](#input\_volume\_tags) | A mapping of tags to assign to the devices created by the instance at launch time | `map(string)` | `{}` | no | -| [vpc\_security\_group\_ids](#input\_vpc\_security\_group\_ids) | A list of security group IDs to associate with | `list(string)` | `null` | no | - -## Outputs - -| Name | Description | -|------|-------------| -| [arn](#output\_arn) | The ARN of the instance | -| [capacity\_reservation\_specification](#output\_capacity\_reservation\_specification) | Capacity reservation specification of the instance | -| [id](#output\_id) | The ID of the instance | -| [instance\_state](#output\_instance\_state) | The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped` | -| [ipv6\_addresses](#output\_ipv6\_addresses) | The IPv6 address assigned to the instance, if applicable. | -| [outpost\_arn](#output\_outpost\_arn) | The ARN of the Outpost the instance is assigned to | -| [password\_data](#output\_password\_data) | Base-64 encoded encrypted password data for the instance. Useful for getting the administrator password for instances running Microsoft Windows. This attribute is only exported if `get_password_data` is true | -| [primary\_network\_interface\_id](#output\_primary\_network\_interface\_id) | The ID of the instance's primary network interface | -| [private\_dns](#output\_private\_dns) | The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC | -| [private\_ip](#output\_private\_ip) | The private IP address assigned to the instance. | -| [public\_dns](#output\_public\_dns) | The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC | -| [public\_ip](#output\_public\_ip) | The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws\_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached | -| [spot\_bid\_status](#output\_spot\_bid\_status) | The current bid status of the Spot Instance Request | -| [spot\_instance\_id](#output\_spot\_instance\_id) | The Instance ID (if any) that is currently fulfilling the Spot Instance request | -| [spot\_request\_state](#output\_spot\_request\_state) | The current request state of the Spot Instance Request | -| [tags\_all](#output\_tags\_all) | A map of tags assigned to the resource, including those inherited from the provider default\_tags configuration block | diff --git a/examples/complete/README.md b/examples/complete/README.md index b058811a..aa32df11 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -15,89 +15,3 @@ $ terraform apply Note that this example may create resources which can cost money. Run `terraform destroy` when you don't need these resources. -## Requirements - -| Name | Version | -|------|---------| -| [terraform](#requirement\_terraform) | >= 0.13.1 | -| [aws](#requirement\_aws) | >= 4.7 | - -## Providers - -| Name | Version | -|------|---------| -| [aws](#provider\_aws) | 4.22.0 | - -## Modules - -| Name | Source | Version | -|------|--------|---------| -| [ec2\_capacity\_reservation](#module\_ec2\_capacity\_reservation) | ../../ | n/a | -| [ec2\_complete](#module\_ec2\_complete) | ../../ | n/a | -| [ec2\_disabled](#module\_ec2\_disabled) | ../../ | n/a | -| [ec2\_metadata\_options](#module\_ec2\_metadata\_options) | ../../ | n/a | -| [ec2\_multiple](#module\_ec2\_multiple) | ../../ | n/a | -| [ec2\_network\_interface](#module\_ec2\_network\_interface) | ../../ | n/a | -| [ec2\_spot\_instance](#module\_ec2\_spot\_instance) | ../../ | n/a | -| [ec2\_t2\_unlimited](#module\_ec2\_t2\_unlimited) | ../../ | n/a | -| [ec2\_t3\_unlimited](#module\_ec2\_t3\_unlimited) | ../../ | n/a | -| [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 | -| [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 3.0 | - -## Resources - -| Name | Type | -|------|------| -| [aws_kms_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource | -| [aws_network_interface.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/network_interface) | resource | -| [aws_placement_group.web](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/placement_group) | resource | -| [aws_ami.amazon_linux](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source | - -## Inputs - -No inputs. - -## Outputs - -| Name | Description | -|------|-------------| -| [ec2\_complete\_arn](#output\_ec2\_complete\_arn) | The ARN of the instance | -| [ec2\_complete\_capacity\_reservation\_specification](#output\_ec2\_complete\_capacity\_reservation\_specification) | Capacity reservation specification of the instance | -| [ec2\_complete\_id](#output\_ec2\_complete\_id) | The ID of the instance | -| [ec2\_complete\_instance\_state](#output\_ec2\_complete\_instance\_state) | The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped` | -| [ec2\_complete\_primary\_network\_interface\_id](#output\_ec2\_complete\_primary\_network\_interface\_id) | The ID of the instance's primary network interface | -| [ec2\_complete\_private\_dns](#output\_ec2\_complete\_private\_dns) | The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC | -| [ec2\_complete\_public\_dns](#output\_ec2\_complete\_public\_dns) | The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC | -| [ec2\_complete\_public\_ip](#output\_ec2\_complete\_public\_ip) | The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws\_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached | -| [ec2\_complete\_tags\_all](#output\_ec2\_complete\_tags\_all) | A map of tags assigned to the resource, including those inherited from the provider default\_tags configuration block | -| [ec2\_multiple](#output\_ec2\_multiple) | The full output of the `ec2_module` module | -| [ec2\_spot\_instance\_arn](#output\_ec2\_spot\_instance\_arn) | The ARN of the instance | -| [ec2\_spot\_instance\_capacity\_reservation\_specification](#output\_ec2\_spot\_instance\_capacity\_reservation\_specification) | Capacity reservation specification of the instance | -| [ec2\_spot\_instance\_id](#output\_ec2\_spot\_instance\_id) | The ID of the instance | -| [ec2\_spot\_instance\_instance\_state](#output\_ec2\_spot\_instance\_instance\_state) | The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped` | -| [ec2\_spot\_instance\_primary\_network\_interface\_id](#output\_ec2\_spot\_instance\_primary\_network\_interface\_id) | The ID of the instance's primary network interface | -| [ec2\_spot\_instance\_private\_dns](#output\_ec2\_spot\_instance\_private\_dns) | The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC | -| [ec2\_spot\_instance\_public\_dns](#output\_ec2\_spot\_instance\_public\_dns) | The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC | -| [ec2\_spot\_instance\_public\_ip](#output\_ec2\_spot\_instance\_public\_ip) | The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws\_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached | -| [ec2\_spot\_instance\_tags\_all](#output\_ec2\_spot\_instance\_tags\_all) | A map of tags assigned to the resource, including those inherited from the provider default\_tags configuration block | -| [ec2\_t2\_unlimited\_arn](#output\_ec2\_t2\_unlimited\_arn) | The ARN of the instance | -| [ec2\_t2\_unlimited\_capacity\_reservation\_specification](#output\_ec2\_t2\_unlimited\_capacity\_reservation\_specification) | Capacity reservation specification of the instance | -| [ec2\_t2\_unlimited\_id](#output\_ec2\_t2\_unlimited\_id) | The ID of the instance | -| [ec2\_t2\_unlimited\_instance\_state](#output\_ec2\_t2\_unlimited\_instance\_state) | The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped` | -| [ec2\_t2\_unlimited\_primary\_network\_interface\_id](#output\_ec2\_t2\_unlimited\_primary\_network\_interface\_id) | The ID of the instance's primary network interface | -| [ec2\_t2\_unlimited\_private\_dns](#output\_ec2\_t2\_unlimited\_private\_dns) | The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC | -| [ec2\_t2\_unlimited\_public\_dns](#output\_ec2\_t2\_unlimited\_public\_dns) | The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC | -| [ec2\_t2\_unlimited\_public\_ip](#output\_ec2\_t2\_unlimited\_public\_ip) | The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws\_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached | -| [ec2\_t2\_unlimited\_tags\_all](#output\_ec2\_t2\_unlimited\_tags\_all) | A map of tags assigned to the resource, including those inherited from the provider default\_tags configuration block | -| [ec2\_t3\_unlimited\_arn](#output\_ec2\_t3\_unlimited\_arn) | The ARN of the instance | -| [ec2\_t3\_unlimited\_capacity\_reservation\_specification](#output\_ec2\_t3\_unlimited\_capacity\_reservation\_specification) | Capacity reservation specification of the instance | -| [ec2\_t3\_unlimited\_id](#output\_ec2\_t3\_unlimited\_id) | The ID of the instance | -| [ec2\_t3\_unlimited\_instance\_state](#output\_ec2\_t3\_unlimited\_instance\_state) | The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped` | -| [ec2\_t3\_unlimited\_primary\_network\_interface\_id](#output\_ec2\_t3\_unlimited\_primary\_network\_interface\_id) | The ID of the instance's primary network interface | -| [ec2\_t3\_unlimited\_private\_dns](#output\_ec2\_t3\_unlimited\_private\_dns) | The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC | -| [ec2\_t3\_unlimited\_public\_dns](#output\_ec2\_t3\_unlimited\_public\_dns) | The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC | -| [ec2\_t3\_unlimited\_public\_ip](#output\_ec2\_t3\_unlimited\_public\_ip) | The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws\_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached | -| [ec2\_t3\_unlimited\_tags\_all](#output\_ec2\_t3\_unlimited\_tags\_all) | A map of tags assigned to the resource, including those inherited from the provider default\_tags configuration block | -| [spot\_bid\_status](#output\_spot\_bid\_status) | The current bid status of the Spot Instance Request | -| [spot\_instance\_id](#output\_spot\_instance\_id) | The Instance ID (if any) that is currently fulfilling the Spot Instance request | -| [spot\_request\_state](#output\_spot\_request\_state) | The current request state of the Spot Instance Request | diff --git a/examples/complete/main.tf b/examples/complete/main.tf index d6c446db..6857216a 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -351,4 +351,4 @@ module "ec2_capacity_reservation" { } tags = local.tags -} \ No newline at end of file +} From 647540a4379222a61aa62c9642f00a6e612822fa Mon Sep 17 00:00:00 2001 From: Samuel CHNIBER Date: Thu, 21 Jul 2022 15:33:13 +0200 Subject: [PATCH 07/12] fix README --- README.md | 119 ++++++++++++++++++++++++++++++++++++ examples/complete/README.md | 86 ++++++++++++++++++++++++++ 2 files changed, 205 insertions(+) diff --git a/README.md b/README.md index eab40a2e..0b9c423e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +# AWS EC2 Instance Terraform module + Terraform module which creates an EC2 instance on AWS. [![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md) @@ -161,3 +163,120 @@ The following combinations are supported to conditionally create resources: - In regards to spot instances, you must grant the `AWSServiceRoleForEC2Spot` service-linked role access to any custom KMS keys, otherwise your spot request and instances will fail with `bad parameters`. You can see more details about why the request failed by using the awscli and `aws ec2 describe-spot-instance-requests` +## Requirements + +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | >= 0.13.1 | +| [aws](#requirement\_aws) | >= 4.20.0 | + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | >= 4.20.0 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_instance.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance) | resource | +| [aws_spot_instance_request.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/spot_instance_request) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [ami](#input\_ami) | ID of AMI to use for the instance | `string` | `""` | no | +| [associate\_public\_ip\_address](#input\_associate\_public\_ip\_address) | Whether to associate a public IP address with an instance in a VPC | `bool` | `null` | no | +| [availability\_zone](#input\_availability\_zone) | AZ to start the instance in | `string` | `null` | no | +| [capacity\_reservation\_specification](#input\_capacity\_reservation\_specification) | Describes an instance's Capacity Reservation targeting option | `any` | `null` | no | +| [cpu\_core\_count](#input\_cpu\_core\_count) | Sets the number of CPU cores for an instance. | `number` | `null` | no | +| [cpu\_credits](#input\_cpu\_credits) | The credit option for CPU usage (unlimited or standard) | `string` | `null` | no | +| [cpu\_threads\_per\_core](#input\_cpu\_threads\_per\_core) | Sets the number of CPU threads per core for an instance (has no effect unless cpu\_core\_count is also set). | `number` | `null` | no | +| [create](#input\_create) | Whether to create an instance | `bool` | `true` | no | +| [create\_spot\_instance](#input\_create\_spot\_instance) | Depicts if the instance is a spot instance | `bool` | `false` | no | +| [disable\_api\_stop](#input\_disable\_api\_stop) | If true, enables EC2 Instance Stop Protection. | `bool` | `null` | no | +| [disable\_api\_termination](#input\_disable\_api\_termination) | If true, enables EC2 Instance Termination Protection | `bool` | `null` | no | +| [ebs\_block\_device](#input\_ebs\_block\_device) | Additional EBS block devices to attach to the instance | `list(map(string))` | `[]` | no | +| [ebs\_optimized](#input\_ebs\_optimized) | If true, the launched EC2 instance will be EBS-optimized | `bool` | `null` | no | +| [enable\_volume\_tags](#input\_enable\_volume\_tags) | Whether to enable volume tags (if enabled it conflicts with root\_block\_device tags) | `bool` | `true` | no | +| [enclave\_options\_enabled](#input\_enclave\_options\_enabled) | Whether Nitro Enclaves will be enabled on the instance. Defaults to `false` | `bool` | `null` | no | +| [ephemeral\_block\_device](#input\_ephemeral\_block\_device) | Customize Ephemeral (also known as Instance Store) volumes on the instance | `list(map(string))` | `[]` | no | +| [get\_password\_data](#input\_get\_password\_data) | If true, wait for password data to become available and retrieve it. | `bool` | `null` | no | +| [hibernation](#input\_hibernation) | If true, the launched EC2 instance will support hibernation | `bool` | `null` | no | +| [host\_id](#input\_host\_id) | ID of a dedicated host that the instance will be assigned to. Use when an instance is to be launched on a specific dedicated host | `string` | `null` | no | +| [iam\_instance\_profile](#input\_iam\_instance\_profile) | IAM Instance Profile to launch the instance with. Specified as the name of the Instance Profile | `string` | `null` | no | +| [instance\_initiated\_shutdown\_behavior](#input\_instance\_initiated\_shutdown\_behavior) | Shutdown behavior for the instance. Amazon defaults this to stop for EBS-backed instances and terminate for instance-store instances. Cannot be set on instance-store instance | `string` | `null` | no | +| [instance\_type](#input\_instance\_type) | The type of instance to start | `string` | `"t3.micro"` | no | +| [ipv6\_address\_count](#input\_ipv6\_address\_count) | A number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet | `number` | `null` | no | +| [ipv6\_addresses](#input\_ipv6\_addresses) | Specify one or more IPv6 addresses from the range of the subnet to associate with the primary network interface | `list(string)` | `null` | no | +| [key\_name](#input\_key\_name) | Key name of the Key Pair to use for the instance; which can be managed using the `aws_key_pair` resource | `string` | `null` | no | +| [launch\_template](#input\_launch\_template) | Specifies a Launch Template to configure the instance. Parameters configured on this resource will override the corresponding parameters in the Launch Template | `map(string)` | `null` | no | +| [metadata\_options](#input\_metadata\_options) | Customize the metadata options of the instance | `map(string)` | `{}` | no | +| [monitoring](#input\_monitoring) | If true, the launched EC2 instance will have detailed monitoring enabled | `bool` | `false` | no | +| [name](#input\_name) | Name to be used on EC2 instance created | `string` | `""` | no | +| [network\_interface](#input\_network\_interface) | Customize network interfaces to be attached at instance boot time | `list(map(string))` | `[]` | no | +| [placement\_group](#input\_placement\_group) | The Placement Group to start the instance in | `string` | `null` | no | +| [private\_ip](#input\_private\_ip) | Private IP address to associate with the instance in a VPC | `string` | `null` | no | +| [putin\_khuylo](#input\_putin\_khuylo) | Do you agree that Putin doesn't respect Ukrainian sovereignty and territorial integrity? More info: https://en.wikipedia.org/wiki/Putin_khuylo! | `bool` | `true` | no | +| [root\_block\_device](#input\_root\_block\_device) | Customize details about the root block device of the instance. See Block Devices below for details | `list(any)` | `[]` | no | +| [secondary\_private\_ips](#input\_secondary\_private\_ips) | A list of secondary private IPv4 addresses to assign to the instance's primary network interface (eth0) in a VPC. Can only be assigned to the primary network interface (eth0) attached at instance creation, not a pre-existing network interface i.e. referenced in a `network_interface block` | `list(string)` | `null` | no | +| [source\_dest\_check](#input\_source\_dest\_check) | Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs. | `bool` | `true` | no | +| [spot\_block\_duration\_minutes](#input\_spot\_block\_duration\_minutes) | The required duration for the Spot instances, in minutes. This value must be a multiple of 60 (60, 120, 180, 240, 300, or 360) | `number` | `null` | no | +| [spot\_instance\_interruption\_behavior](#input\_spot\_instance\_interruption\_behavior) | Indicates Spot instance behavior when it is interrupted. Valid values are `terminate`, `stop`, or `hibernate` | `string` | `null` | no | +| [spot\_launch\_group](#input\_spot\_launch\_group) | A launch group is a group of spot instances that launch together and terminate together. If left empty instances are launched and terminated individually | `string` | `null` | no | +| [spot\_price](#input\_spot\_price) | The maximum price to request on the spot market. Defaults to on-demand price | `string` | `null` | no | +| [spot\_type](#input\_spot\_type) | If set to one-time, after the instance is terminated, the spot request will be closed. Default `persistent` | `string` | `null` | no | +| [spot\_valid\_from](#input\_spot\_valid\_from) | The start date and time of the request, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ) | `string` | `null` | no | +| [spot\_valid\_until](#input\_spot\_valid\_until) | The end date and time of the request, in UTC RFC3339 format(for example, YYYY-MM-DDTHH:MM:SSZ) | `string` | `null` | no | +| [spot\_wait\_for\_fulfillment](#input\_spot\_wait\_for\_fulfillment) | If set, Terraform will wait for the Spot Request to be fulfilled, and will throw an error if the timeout of 10m is reached | `bool` | `null` | no | +| [subnet\_id](#input\_subnet\_id) | The VPC Subnet ID to launch in | `string` | `null` | no | +| [tags](#input\_tags) | A mapping of tags to assign to the resource | `map(string)` | `{}` | no | +| [tenancy](#input\_tenancy) | The tenancy of the instance (if the instance is running in a VPC). Available values: default, dedicated, host. | `string` | `null` | no | +| [timeouts](#input\_timeouts) | Define maximum timeout for creating, updating, and deleting EC2 instance resources | `map(string)` | `{}` | no | +| [user\_data](#input\_user\_data) | The user data to provide when launching the instance. Do not pass gzip-compressed data via this argument; see user\_data\_base64 instead. | `string` | `null` | no | +| [user\_data\_base64](#input\_user\_data\_base64) | Can be used instead of user\_data to pass base64-encoded binary data directly. Use this instead of user\_data whenever the value is not a valid UTF-8 string. For example, gzip-encoded user data must be base64-encoded and passed via this argument to avoid corruption. | `string` | `null` | no | +| [user\_data\_replace\_on\_change](#input\_user\_data\_replace\_on\_change) | When used in combination with user\_data or user\_data\_base64 will trigger a destroy and recreate when set to true. Defaults to false if not set. | `bool` | `false` | no | +| [volume\_tags](#input\_volume\_tags) | A mapping of tags to assign to the devices created by the instance at launch time | `map(string)` | `{}` | no | +| [vpc\_security\_group\_ids](#input\_vpc\_security\_group\_ids) | A list of security group IDs to associate with | `list(string)` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [arn](#output\_arn) | The ARN of the instance | +| [capacity\_reservation\_specification](#output\_capacity\_reservation\_specification) | Capacity reservation specification of the instance | +| [id](#output\_id) | The ID of the instance | +| [instance\_state](#output\_instance\_state) | The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped` | +| [ipv6\_addresses](#output\_ipv6\_addresses) | The IPv6 address assigned to the instance, if applicable. | +| [outpost\_arn](#output\_outpost\_arn) | The ARN of the Outpost the instance is assigned to | +| [password\_data](#output\_password\_data) | Base-64 encoded encrypted password data for the instance. Useful for getting the administrator password for instances running Microsoft Windows. This attribute is only exported if `get_password_data` is true | +| [primary\_network\_interface\_id](#output\_primary\_network\_interface\_id) | The ID of the instance's primary network interface | +| [private\_dns](#output\_private\_dns) | The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC | +| [private\_ip](#output\_private\_ip) | The private IP address assigned to the instance. | +| [public\_dns](#output\_public\_dns) | The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC | +| [public\_ip](#output\_public\_ip) | The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws\_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached | +| [spot\_bid\_status](#output\_spot\_bid\_status) | The current bid status of the Spot Instance Request | +| [spot\_instance\_id](#output\_spot\_instance\_id) | The Instance ID (if any) that is currently fulfilling the Spot Instance request | +| [spot\_request\_state](#output\_spot\_request\_state) | The current request state of the Spot Instance Request | +| [tags\_all](#output\_tags\_all) | A map of tags assigned to the resource, including those inherited from the provider default\_tags configuration block | + + +## Authors + +Module is maintained by [Anton Babenko](https://github.com/antonbabenko) with help from [these awesome contributors](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/graphs/contributors). + +## License + +Apache 2 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/tree/master/LICENSE) for full details. + +## Additional information for users from Russia and Belarus + +* Russia has [illegally annexed Crimea in 2014](https://en.wikipedia.org/wiki/Annexation_of_Crimea_by_the_Russian_Federation) and [brought the war in Donbas](https://en.wikipedia.org/wiki/War_in_Donbas) followed by [full-scale invasion of Ukraine in 2022](https://en.wikipedia.org/wiki/2022_Russian_invasion_of_Ukraine). +* Russia has brought sorrow and devastations to millions of Ukrainians, killed hundreds of innocent people, damaged thousands of buildings, and forced several million people to flee. +* [Putin khuylo!](https://en.wikipedia.org/wiki/Putin_khuylo!) diff --git a/examples/complete/README.md b/examples/complete/README.md index aa32df11..b058811a 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -15,3 +15,89 @@ $ terraform apply Note that this example may create resources which can cost money. Run `terraform destroy` when you don't need these resources. +## Requirements + +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | >= 0.13.1 | +| [aws](#requirement\_aws) | >= 4.7 | + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | 4.22.0 | + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [ec2\_capacity\_reservation](#module\_ec2\_capacity\_reservation) | ../../ | n/a | +| [ec2\_complete](#module\_ec2\_complete) | ../../ | n/a | +| [ec2\_disabled](#module\_ec2\_disabled) | ../../ | n/a | +| [ec2\_metadata\_options](#module\_ec2\_metadata\_options) | ../../ | n/a | +| [ec2\_multiple](#module\_ec2\_multiple) | ../../ | n/a | +| [ec2\_network\_interface](#module\_ec2\_network\_interface) | ../../ | n/a | +| [ec2\_spot\_instance](#module\_ec2\_spot\_instance) | ../../ | n/a | +| [ec2\_t2\_unlimited](#module\_ec2\_t2\_unlimited) | ../../ | n/a | +| [ec2\_t3\_unlimited](#module\_ec2\_t3\_unlimited) | ../../ | n/a | +| [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 | +| [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 3.0 | + +## Resources + +| Name | Type | +|------|------| +| [aws_kms_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource | +| [aws_network_interface.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/network_interface) | resource | +| [aws_placement_group.web](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/placement_group) | resource | +| [aws_ami.amazon_linux](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source | + +## Inputs + +No inputs. + +## Outputs + +| Name | Description | +|------|-------------| +| [ec2\_complete\_arn](#output\_ec2\_complete\_arn) | The ARN of the instance | +| [ec2\_complete\_capacity\_reservation\_specification](#output\_ec2\_complete\_capacity\_reservation\_specification) | Capacity reservation specification of the instance | +| [ec2\_complete\_id](#output\_ec2\_complete\_id) | The ID of the instance | +| [ec2\_complete\_instance\_state](#output\_ec2\_complete\_instance\_state) | The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped` | +| [ec2\_complete\_primary\_network\_interface\_id](#output\_ec2\_complete\_primary\_network\_interface\_id) | The ID of the instance's primary network interface | +| [ec2\_complete\_private\_dns](#output\_ec2\_complete\_private\_dns) | The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC | +| [ec2\_complete\_public\_dns](#output\_ec2\_complete\_public\_dns) | The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC | +| [ec2\_complete\_public\_ip](#output\_ec2\_complete\_public\_ip) | The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws\_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached | +| [ec2\_complete\_tags\_all](#output\_ec2\_complete\_tags\_all) | A map of tags assigned to the resource, including those inherited from the provider default\_tags configuration block | +| [ec2\_multiple](#output\_ec2\_multiple) | The full output of the `ec2_module` module | +| [ec2\_spot\_instance\_arn](#output\_ec2\_spot\_instance\_arn) | The ARN of the instance | +| [ec2\_spot\_instance\_capacity\_reservation\_specification](#output\_ec2\_spot\_instance\_capacity\_reservation\_specification) | Capacity reservation specification of the instance | +| [ec2\_spot\_instance\_id](#output\_ec2\_spot\_instance\_id) | The ID of the instance | +| [ec2\_spot\_instance\_instance\_state](#output\_ec2\_spot\_instance\_instance\_state) | The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped` | +| [ec2\_spot\_instance\_primary\_network\_interface\_id](#output\_ec2\_spot\_instance\_primary\_network\_interface\_id) | The ID of the instance's primary network interface | +| [ec2\_spot\_instance\_private\_dns](#output\_ec2\_spot\_instance\_private\_dns) | The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC | +| [ec2\_spot\_instance\_public\_dns](#output\_ec2\_spot\_instance\_public\_dns) | The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC | +| [ec2\_spot\_instance\_public\_ip](#output\_ec2\_spot\_instance\_public\_ip) | The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws\_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached | +| [ec2\_spot\_instance\_tags\_all](#output\_ec2\_spot\_instance\_tags\_all) | A map of tags assigned to the resource, including those inherited from the provider default\_tags configuration block | +| [ec2\_t2\_unlimited\_arn](#output\_ec2\_t2\_unlimited\_arn) | The ARN of the instance | +| [ec2\_t2\_unlimited\_capacity\_reservation\_specification](#output\_ec2\_t2\_unlimited\_capacity\_reservation\_specification) | Capacity reservation specification of the instance | +| [ec2\_t2\_unlimited\_id](#output\_ec2\_t2\_unlimited\_id) | The ID of the instance | +| [ec2\_t2\_unlimited\_instance\_state](#output\_ec2\_t2\_unlimited\_instance\_state) | The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped` | +| [ec2\_t2\_unlimited\_primary\_network\_interface\_id](#output\_ec2\_t2\_unlimited\_primary\_network\_interface\_id) | The ID of the instance's primary network interface | +| [ec2\_t2\_unlimited\_private\_dns](#output\_ec2\_t2\_unlimited\_private\_dns) | The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC | +| [ec2\_t2\_unlimited\_public\_dns](#output\_ec2\_t2\_unlimited\_public\_dns) | The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC | +| [ec2\_t2\_unlimited\_public\_ip](#output\_ec2\_t2\_unlimited\_public\_ip) | The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws\_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached | +| [ec2\_t2\_unlimited\_tags\_all](#output\_ec2\_t2\_unlimited\_tags\_all) | A map of tags assigned to the resource, including those inherited from the provider default\_tags configuration block | +| [ec2\_t3\_unlimited\_arn](#output\_ec2\_t3\_unlimited\_arn) | The ARN of the instance | +| [ec2\_t3\_unlimited\_capacity\_reservation\_specification](#output\_ec2\_t3\_unlimited\_capacity\_reservation\_specification) | Capacity reservation specification of the instance | +| [ec2\_t3\_unlimited\_id](#output\_ec2\_t3\_unlimited\_id) | The ID of the instance | +| [ec2\_t3\_unlimited\_instance\_state](#output\_ec2\_t3\_unlimited\_instance\_state) | The state of the instance. One of: `pending`, `running`, `shutting-down`, `terminated`, `stopping`, `stopped` | +| [ec2\_t3\_unlimited\_primary\_network\_interface\_id](#output\_ec2\_t3\_unlimited\_primary\_network\_interface\_id) | The ID of the instance's primary network interface | +| [ec2\_t3\_unlimited\_private\_dns](#output\_ec2\_t3\_unlimited\_private\_dns) | The private DNS name assigned to the instance. Can only be used inside the Amazon EC2, and only available if you've enabled DNS hostnames for your VPC | +| [ec2\_t3\_unlimited\_public\_dns](#output\_ec2\_t3\_unlimited\_public\_dns) | The public DNS name assigned to the instance. For EC2-VPC, this is only available if you've enabled DNS hostnames for your VPC | +| [ec2\_t3\_unlimited\_public\_ip](#output\_ec2\_t3\_unlimited\_public\_ip) | The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws\_eip with your instance, you should refer to the EIP's address directly and not use `public_ip` as this field will change after the EIP is attached | +| [ec2\_t3\_unlimited\_tags\_all](#output\_ec2\_t3\_unlimited\_tags\_all) | A map of tags assigned to the resource, including those inherited from the provider default\_tags configuration block | +| [spot\_bid\_status](#output\_spot\_bid\_status) | The current bid status of the Spot Instance Request | +| [spot\_instance\_id](#output\_spot\_instance\_id) | The Instance ID (if any) that is currently fulfilling the Spot Instance request | +| [spot\_request\_state](#output\_spot\_request\_state) | The current request state of the Spot Instance Request | From 2f8fc874fa32cc7e6640af75c804c992dd42633a Mon Sep 17 00:00:00 2001 From: Samuel CHNIBER Date: Thu, 21 Jul 2022 15:37:33 +0200 Subject: [PATCH 08/12] fix README --- examples/complete/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/complete/README.md b/examples/complete/README.md index b058811a..d7454943 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -26,7 +26,7 @@ Note that this example may create resources which can cost money. Run `terraform | Name | Version | |------|---------| -| [aws](#provider\_aws) | 4.22.0 | +| [aws](#provider\_aws) | >= 4.7 | ## Modules @@ -101,3 +101,4 @@ No inputs. | [spot\_bid\_status](#output\_spot\_bid\_status) | The current bid status of the Spot Instance Request | | [spot\_instance\_id](#output\_spot\_instance\_id) | The Instance ID (if any) that is currently fulfilling the Spot Instance request | | [spot\_request\_state](#output\_spot\_request\_state) | The current request state of the Spot Instance Request | + From 9c3537d830400935d826fd17ece6c7c099c27e55 Mon Sep 17 00:00:00 2001 From: Samuel CHNIBER Date: Thu, 21 Jul 2022 17:38:28 +0200 Subject: [PATCH 09/12] fix example to be deployable --- examples/complete/main.tf | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 6857216a..5f5bdc93 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -73,9 +73,17 @@ resource "aws_network_interface" "this" { subnet_id = element(module.vpc.private_subnets, 0) } -################################################################################ -# EC2 Module -################################################################################ +resource "aws_ec2_capacity_reservation" "targeted" { + instance_type = "m6i.2xlarge" + instance_platform = "Linux/UNIX" + availability_zone = "${local.region}a" + instance_count = 1 + instance_match_criteria = "targeted" +} + +# ################################################################################ +# # EC2 Module +# ################################################################################ module "ec2_disabled" { source = "../../" @@ -339,14 +347,14 @@ module "ec2_capacity_reservation" { name = "${local.name}-capacity-reservation" ami = data.aws_ami.amazon_linux.id - instance_type = "u-6tb1.56xlarge" + instance_type = "m6i.2xlarge" subnet_id = element(module.vpc.private_subnets, 0) vpc_security_group_ids = [module.security_group.security_group_id] associate_public_ip_address = true capacity_reservation_specification = { capacity_reservation_target = { - capacity_reservation_id = "cr-00000000000000000" + capacity_reservation_id = aws_ec2_capacity_reservation.targeted.id } } From 08431c55a0c28b62ae0b2abe8f7d89c034b1b1a0 Mon Sep 17 00:00:00 2001 From: Samuel CHNIBER Date: Thu, 21 Jul 2022 17:39:17 +0200 Subject: [PATCH 10/12] fix example to be deployable --- examples/complete/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/complete/README.md b/examples/complete/README.md index d7454943..008f8307 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -48,6 +48,7 @@ Note that this example may create resources which can cost money. Run `terraform | Name | Type | |------|------| +| [aws_ec2_capacity_reservation.targeted](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_capacity_reservation) | resource | | [aws_kms_key.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource | | [aws_network_interface.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/network_interface) | resource | | [aws_placement_group.web](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/placement_group) | resource | From 2a94ddc0fc50d56e1865693b81bd3c501a4677c5 Mon Sep 17 00:00:00 2001 From: Bryant Biggs Date: Thu, 21 Jul 2022 11:41:00 -0400 Subject: [PATCH 11/12] Update examples/complete/main.tf --- examples/complete/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 5f5bdc93..39c53fae 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -74,7 +74,7 @@ resource "aws_network_interface" "this" { } resource "aws_ec2_capacity_reservation" "targeted" { - instance_type = "m6i.2xlarge" + instance_type = "t3.micro" instance_platform = "Linux/UNIX" availability_zone = "${local.region}a" instance_count = 1 From c25879c02283e2ad9fb546e3f2936831acec38d2 Mon Sep 17 00:00:00 2001 From: Bryant Biggs Date: Thu, 21 Jul 2022 11:41:22 -0400 Subject: [PATCH 12/12] Update examples/complete/main.tf --- examples/complete/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 39c53fae..c2cd951a 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -347,7 +347,7 @@ module "ec2_capacity_reservation" { name = "${local.name}-capacity-reservation" ami = data.aws_ami.amazon_linux.id - instance_type = "m6i.2xlarge" + instance_type = "t3.micro" subnet_id = element(module.vpc.private_subnets, 0) vpc_security_group_ids = [module.security_group.security_group_id] associate_public_ip_address = true