File tree Expand file tree Collapse file tree
examples/self_managed_node_group Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11repos :
22 - repo : https://github.com/antonbabenko/pre-commit-terraform
3- rev : v1.64.0
3+ rev : v1.64.1
44 hooks :
55 - id : terraform_fmt
66 - id : terraform_validate
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ Note that this example may create resources which cost money. Run `terraform des
4949
5050| Name | Type |
5151| ------| ------|
52+ | [ aws_ec2_capacity_reservation.targeted] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_capacity_reservation ) | resource |
5253| [ aws_key_pair.this] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/key_pair ) | resource |
5354| [ aws_kms_key.ebs] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key ) | resource |
5455| [ aws_kms_key.eks] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key ) | resource |
Original file line number Diff line number Diff line change @@ -202,6 +202,12 @@ module "eks" {
202202 instance_metadata_tags = " disabled"
203203 }
204204
205+ capacity_reservation_specification = {
206+ capacity_reservation_target = {
207+ capacity_reservation_id = aws_ec2_capacity_reservation.targeted.id
208+ }
209+ }
210+
205211 create_iam_role = true
206212 iam_role_name = " self-managed-node-group-complete-example"
207213 iam_role_use_name_prefix = false
@@ -407,6 +413,14 @@ resource "aws_kms_key" "ebs" {
407413 policy = data. aws_iam_policy_document . ebs . json
408414}
409415
416+ resource "aws_ec2_capacity_reservation" "targeted" {
417+ instance_type = " m6i.large"
418+ instance_platform = " Linux/UNIX"
419+ availability_zone = " ${ local . region } a"
420+ instance_count = 1
421+ instance_match_criteria = " targeted"
422+ }
423+
410424# This policy is required for the KMS key used for EKS root volumes, so the cluster is allowed to enc/dec/attach encrypted EBS volumes
411425data "aws_iam_policy_document" "ebs" {
412426 # Copy of default KMS policy that lets you manage it
Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ resource "aws_launch_template" "this" {
9494 capacity_reservation_preference = lookup (capacity_reservation_specification. value , " capacity_reservation_preference" , null )
9595
9696 dynamic "capacity_reservation_target" {
97- for_each = lookup ( capacity_reservation_specification. value , " capacity_reservation_target" , [])
97+ for_each = try ([ capacity_reservation_specification . value . capacity_reservation_target ] , [])
9898 content {
9999 capacity_reservation_id = lookup (capacity_reservation_target. value , " capacity_reservation_id" , null )
100100 }
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ resource "aws_launch_template" "this" {
9797 capacity_reservation_preference = lookup (capacity_reservation_specification. value , " capacity_reservation_preference" , null )
9898
9999 dynamic "capacity_reservation_target" {
100- for_each = lookup ( capacity_reservation_specification. value , " capacity_reservation_target" , [])
100+ for_each = try ([ capacity_reservation_specification . value . capacity_reservation_target ] , [])
101101 content {
102102 capacity_reservation_id = lookup (capacity_reservation_target. value , " capacity_reservation_id" , null )
103103 }
You can’t perform that action at this time.
0 commit comments