This message was deleted.
# general
b
This message was deleted.
πŸ‘€ 1
c
Hi Ricardo, can you post the actual ouput your seeing (including any debug or warning messages that show up)?
w
sure
Copy code
time="2022-07-05T14:22:17+01:00" level=info msg="Evaluating Terraform directory at scripts"
time="2022-07-05T14:22:17+01:00" level=debug msg="Specified usage file already exists, no overriding"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Beginning parse for directory 'scripts/terraform'..."
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Added 6 blocks from scripts/terraform/main.tf..."
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Added 5 blocks from scripts/terraform/vars.tf..."
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Loading TFVars..."
time="2022-07-05T14:22:17+01:00" level=info msg="Starting: Downloading Terraform modules"
time="2022-07-05T14:22:17+01:00" level=debug msg="Module defibrillator_image already loaded"
time="2022-07-05T14:22:17+01:00" level=debug msg="Module defibrillator_service already loaded"
time="2022-07-05T14:22:17+01:00" level=debug msg="Module configs already loaded"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Evaluating expressions..."
time="2022-07-05T14:22:17+01:00" level=info msg="Starting: Evaluating Terraform directory"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform iteration 1"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform iteration 2"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform iteration 3"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Added 1 blocks from scripts/terraform/.infracost/terraform_modules/defibrillator_image/ecr-url/vars.tf..."
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Added 6 blocks from scripts/terraform/.infracost/terraform_modules/defibrillator_image/ecr-url/main.tf..."
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Loaded module 'scripts/terraform/.infracost/terraform_modules/defibrillator_image/ecr-url' (requested at module.defibrillator_image)"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Added 2 blocks from scripts/terraform/_globber/main.tf..."
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Added 3 blocks from scripts/terraform/_globber/vars.tf..."
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Loaded module 'scripts/terraform/_globber' (requested at module.configs)"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Added 3 blocks from scripts/terraform/_defibrillator/iam.tf..."
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Added 5 blocks from scripts/terraform/_defibrillator/network.tf..."
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Added 7 blocks from scripts/terraform/_defibrillator/vars.tf..."
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Added 5 blocks from scripts/terraform/_defibrillator/ecs.tf..."
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Loaded module 'scripts/terraform/_defibrillator' (requested at module.defibrillator_service)"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform iteration 1"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform/.infracost/terraform_modules/defibrillator_image/ecr-url iteration 1"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform/.infracost/terraform_modules/defibrillator_image/ecr-url iteration 2"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform/.infracost/terraform_modules/defibrillator_image/ecr-url iteration 1"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform/.infracost/terraform_modules/defibrillator_image/ecr-url iteration 2"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform/.infracost/terraform_modules/defibrillator_image/ecr-url iteration 1"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform/.infracost/terraform_modules/defibrillator_image/ecr-url iteration 2"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform/_globber iteration 1"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform/_globber iteration 2"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform/_globber iteration 3"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform/_globber iteration 1"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform/_globber iteration 2"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform/_globber iteration 1"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform/_globber iteration 2"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform/_defibrillator iteration 1"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform/_defibrillator iteration 2"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform/_defibrillator iteration 3"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform/_defibrillator iteration 1"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform/_defibrillator iteration 2"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform/_defibrillator iteration 1"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform/_defibrillator iteration 2"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform iteration 2"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform iteration 1"
time="2022-07-05T14:22:17+01:00" level=debug parser=terraform_hcl msg="Starting context evaluation for module scripts/terraform iteration 2"
time="2022-07-05T14:22:17+01:00" level=debug msg="Checking if scripts/terraform is a git repo"
time="2022-07-05T14:22:17+01:00" level=debug msg="Calculated relative terraformModulePath for scripts from scripts/terraform"
time="2022-07-05T14:22:17+01:00" level=debug msg="Unexpected ARN format for 0c33d9eb-f3f2-4489-afd1-31c420713cbb"
time="2022-07-05T14:22:17+01:00" level=debug msg="Loading usage data from Infracost provider resources"
time="2022-07-05T14:22:17+01:00" level=info msg="Starting: Retrieving cloud prices to calculate costs"
time="2022-07-05T14:22:17+01:00" level=debug msg="Getting pricing details from <https://pricing.api.infracost.io> for module.defibrillator_service.aws_ecs_service.service"
time="2022-07-05T14:22:17+01:00" level=debug msg="Getting pricing details from <https://pricing.api.infracost.io> for module.defibrillator_service.aws_cloudwatch_log_group.log_group"
time="2022-07-05T14:22:18+01:00" level=debug msg="Skipping free resource module.defibrillator_service.aws_iam_role.task_role"
time="2022-07-05T14:22:18+01:00" level=debug msg="Skipping free resource module.defibrillator_service.aws_iam_role_policy.ecs_execution_role_policy"
time="2022-07-05T14:22:18+01:00" level=debug msg="Skipping free resource module.defibrillator_service.aws_service_discovery_service.service_discovery"
time="2022-07-05T14:22:18+01:00" level=debug msg="Skipping free resource module.defibrillator_service.aws_ecs_task_definition.task"
time="2022-07-05T14:22:18+01:00" level=debug msg="Skipping sending project results since it is disabled."
time="2022-07-05T14:22:18+01:00" level=info msg="Hiding cost with no usage: module.defibrillator_service.aws_ecs_service.service 'Per GB per hour'"
time="2022-07-05T14:22:18+01:00" level=info msg="Hiding cost with no usage: module.defibrillator_service.aws_ecs_service.service 'Per vCPU per hour'"
time="2022-07-05T14:22:18+01:00" level=info msg="Hiding resource with no usage: module.defibrillator_service.aws_ecs_service.service"

Project: defibrillator/scripts/terraform
Module path: terraform

 Name                                                                Monthly Qty  Unit              Monthly Cost 
                                                                                                                 
 module.defibrillator_service.aws_cloudwatch_log_group.log_group                                                 
 β”œβ”€ Data ingested                                                 Monthly cost depends on usage: $0.50 per GB    
 β”œβ”€ Archival Storage                                              Monthly cost depends on usage: $0.03 per GB    
 └─ Insights queries data scanned                                 Monthly cost depends on usage: $0.005 per GB   
                                                                                                                 
 OVERALL TOTAL                                                                                             $0.00 
──────────────────────────────────
7 cloud resources were detected:
βˆ™ 2 were estimated, 1 of which usage-based costs, see <https://infracost.io/usage-file>
βˆ™ 4 were free, rerun with --show-skipped to see details
βˆ™ 1 is not supported yet, rerun with --show-skipped to see details
c
Is your ECS running on fargate? If not, we don’t show costs under that resource (this is consistent with amazon’s pricing page). The code that decides if it is on fargate is a little tricky, but it essentially checks to see if it is using or inheriting the FARGATE capacity provider.
w
it’s on fargate yes
c
any chance you could share the module code?
w
which one?
ecs service?
c
the ecs_service and the config (sanitized of course)
w
config:
Copy code
locals {
  searched_files = flatten([ for v in var.files : sort(fileset(var.base_path, v)) ])
  loaded_files = [for v in local.searched_files : jsondecode(file("${var.base_path}/${v}"))]
}

output result {
  value = merge(concat([var.base_object], local.loaded_files)...)
}
ecs_service
Copy code
resource aws_ecs_task_definition task {
  family = local.service_name
  requires_compatibilities = ["FARGATE"]
  network_mode = "awsvpc"
  execution_role_arn = data.aws_iam_role.ecs_deploy.arn
  task_role_arn = aws_iam_role.task_role.arn
  cpu = var.task_cpu
  memory = var.task_memory

  container_definitions = jsonencode([{
    logConfiguration: {
      logDriver = "awslogs"
      options = {
        awslogs-group = aws_cloudwatch_log_group.log_group.name
        awslogs-region = var.aws_region
        awslogs-stream-prefix = local.service_name
      }
    }
    
    name = local.service_name
    image = var.container_image
    essential = true
    execution_role_arn = data.aws_iam_role.ecs_deploy.arn
    environment = [for k, v in var.container_envars : { Name: k, Value: tostring(v) }]

    dockerLabels: {
      PROMETHEUS_EXPORTER_PORT = tostring(local.metrics_port)
    }
    
    linuxParameters: {
      initProcessEnabled: true
    }

    portMappings = [{
      containerPort = local.metrics_port
      hostPort = local.metrics_port
    }]
  }])
}

resource aws_ecs_service service {
  name = local.service_name
  task_definition = aws_ecs_task_definition.task.arn
  cluster = data.aws_ecs_cluster.deploy_cluster.id
  depends_on = [aws_iam_role_policy.ecs_execution_role_policy]
  platform_version = "LATEST"
  launch_type = "FARGATE"
  propagate_tags = "TASK_DEFINITION"
  force_new_deployment = true
  enable_ecs_managed_tags = true
  enable_execute_command = true
  wait_for_steady_state = true
  
  desired_count = 1
  deployment_maximum_percent = 100
  deployment_minimum_healthy_percent = 0

  network_configuration {
    subnets = data.aws_subnet_ids.private_subnets.ids
    security_groups = data.aws_security_groups.security_groups.ids
    assign_public_ip = false
  }

  service_registries {
    registry_arn = aws_service_discovery_service.service_discovery.arn
    port = local.metrics_port
  }

  deployment_circuit_breaker {
    enable = true
    rollback = true
  }
}
c
Hey sorry for the radio silence. I’ve been looking into this and I’ve set up an example that has a config module that loads the variables from a json file using the code you provided and passes them to the ecs module. My costs come through fine when doing this so the issue doesn’t seem to be related to that setup.
w
thanks Tim
I’m using hcl parsing if that helps
Hey Tim, any news on this issue?
I’ve extracted the config module to the main.tf and it works, ie, this part:
Copy code
locals {
  searched_files = flatten([ for v in var.files : sort(fileset(var.base_path, v)) ])
  loaded_files = [for v in local.searched_files : jsondecode(file("${var.base_path}/${v}"))]
  config         = merge(concat([local.base_config], local.loaded_files)...)
}
It’s not clear to me why infracost is ignoring the β€œconfig” module or it’s not parsing it.
I have a reproducible example, I’ll make a gh issue later
c
Ok great yeah please post an issue with the reproduction details. I am definitely getting values from the config. I structued my json config like this:
Copy code
{
  "ECS_TASK_CPU": "1 vCPU",
  "ECS_TASK_RAM": "4 GB"
}
w
tagged you on a github issue, thanks for the help