diff --git a/ec2_node_class.yaml.tpl b/ec2_node_class.yaml.tpl index 74c4172..2a8deef 100644 --- a/ec2_node_class.yaml.tpl +++ b/ec2_node_class.yaml.tpl @@ -58,3 +58,6 @@ spec: # Optional, configures detailed monitoring for the instance detailedMonitoring: true + + # Add finops tags to karpenter provisioned nodes + tags: ${tags} diff --git a/main.tf b/main.tf index b1d7d0e..5d8e398 100644 --- a/main.tf +++ b/main.tf @@ -181,6 +181,9 @@ resource "aws_iam_instance_profile" "karpenter_node_instance_profile" { role = module.karpenter_resources.node_iam_role_name } +# Get the default tags from the provider +data "aws_default_tags" "default_tags" {} + # SHOULD PROBABLY PUT THESE OBJECTS INTO A HELM CHART # Create karpenter default resource "kubectl_manifest" "karpenter_ec2_node_class" { @@ -189,6 +192,7 @@ resource "kubectl_manifest" "karpenter_ec2_node_class" { ] yaml_body = templatefile("${path.module}/ec2_node_class.yaml.tpl", { cluster_name = var.cluster_name + tags = jsonencode(data.aws_default_tags.default_tags.tags) amd_ami_family = "Bottlerocket" amd_ami_alias = "bottlerocket" })