infracost: AWS Launch Template not detected when using terraform-aws-modules/eks/aws module

Example Terraform:

provider "aws" {
  region = "us-east-1"
}

resource "aws_default_vpc" "default" {
}

data "aws_subnet_ids" "default" {
  vpc_id = aws_default_vpc.default.id
}

module "my-cluster" {
  source          = "terraform-aws-modules/eks/aws"
  cluster_name    = "my-cluster"
  cluster_version = "1.17"
  subnets         = data.aws_subnet_ids.default.ids
  vpc_id          = aws_default_vpc.default.id

  worker_groups_launch_template = [
    {
      instance_type = "m4.large"
      asg_desired_capacity  = 5
    },
  ]
}

Output is:

  NAME                                                                  MONTHLY QTY  UNIT   PRICE   HOURLY COST  MONTHLY COST

  module.my-cluster-2.aws_autoscaling_group.workers_launch_template[0]
  Total                                                                                                       -             -

  module.my-cluster-2.aws_eks_cluster.this[0]
  └─ EKS cluster                                                                730  hours  0.1000       0.1000       73.0000
  Total                                                                                                  0.1000       73.0000

  OVERALL TOTAL (USD)                                                                                    0.1000       73.0000

We expect that the aws_autoscaling_group.workers_launch_template[0] resource has a launch template subresource with costs.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (12 by maintainers)

Most upvoted comments

Merged πŸ˜ƒ @akastav if you like, you can test it from the latest master branch. Assuming this repo is cloned and go is installed:

make deps
make -s run ARGS="breakdown --log-level info --path /path/to/code"

Thanks @akastav, I’ll dig into this a bit more and see if we can push a fix for this case.

Same thing , when using module.eks.aws_autoscaling_group.workers_launch_template shows 0

`

  module.eks.aws_autoscaling_group.workers_launch_template[0]                                                               
  └─ module.eks.aws_launch_template.workers_launch_template[0]  
     β”œβ”€ EC2 detailed monitoring                                           0  metrics     0.3000       0.0000        0.0000  
     β”œβ”€ root_block_device                                       
     β”‚  └─ General Purpose SSD storage (gp2)                              0  GB-months   0.1100       0.0000        0.0000  
     └─ block_device_mapping[0]                                 
        └─ General Purpose SSD storage (gp2)                              0  GB-months   0.0880       0.0000        0.0000  
  Total                                                                                               0.0000        0.0000  
                                                                                                                            
  module.eks.aws_autoscaling_group.workers_launch_template[1]                                                               
  └─ module.eks.aws_launch_template.workers_launch_template[1]  
     β”œβ”€ EC2 detailed monitoring                                           0  metrics     0.3000       0.0000        0.0000  
     β”œβ”€ root_block_device                                       
     β”‚  └─ General Purpose SSD storage (gp2)                              0  GB-months   0.1100       0.0000        0.0000  
     └─ block_device_mapping[0]                                 
        └─ General Purpose SSD storage (gp2)                              0  GB-months   0.0880       0.0000        0.0000  
  Total                                                                                               0.0000        0.0000  
                                                                                                                            
  module.eks.aws_eks_cluster.this[0]                                                                                        
  └─ EKS cluster                                                        730  hours       0.1000       0.1000       73.0000  
  Total                                                                                               0.1000       73.0000  
     ```
 Terraform EKS versions                                                                                                                       


module β€œeks” { source = β€œterraform-aws-modules/eks/aws” version = β€œ14.0.0” cluster_name = local.cluster_name cluster_version = β€œ1.18”

worker_groups_launch_template = [ { name = β€œspot-group” override_instance_types = [β€œt3a.medium”, β€œt3.medium”, β€œt2.medium”]

It seems to work when using worker_groups instead of worker_groups_launch_template, e.g.:

module "my-cluster" {
  source          = "terraform-aws-modules/eks/aws"
  cluster_name    = "my-cluster"
  cluster_version = "1.17"
  subnets         = data.aws_subnet_ids.default.ids
  vpc_id          = aws_default_vpc.default.id

  worker_groups = [
    {
      instance_type = "m4.large"
      asg_desired_capacity  = 5
    }
  ]
}

Shows:

  NAME                                                      MONTHLY QTY  UNIT       PRICE   HOURLY COST  MONTHLY COST

  module.my-cluster.aws_autoscaling_group.workers[0]
  └─ module.my-cluster.aws_launch_configuration.workers[0]
     β”œβ”€ Linux/UNIX usage (on-demand, m4.large)                    3,650  hours      0.1000       0.5000      365.0000
     β”œβ”€ EBS-optimized usage                                       3,650  hours      0.0000       0.0000        0.0000
     β”œβ”€ EC2 detailed monitoring                                      35  metrics    0.3000       0.0144       10.5000
     └─ root_block_device
        └─ General Purpose SSD storage (gp2)                        500  GB-months  0.0800       0.0548       40.0000
  Total                                                                                          0.5692      415.5000

  module.my-cluster.aws_eks_cluster.this[0]
  └─ EKS cluster                                                    730  hours      0.1000       0.1000       73.0000
  Total                                                                                          0.1000       73.0000

  OVERALL TOTAL (USD)                                                                            0.6692      488.5000