Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Extension does not work with Terraform workspaces that use prefix configuration #21

Copy link
Copy link
Open
@lkolchin

Description

@lkolchin
Issue body actions

Hello,

I'm working with multiple workspaces (with either s3, local or tf cloud backends).
Now I've enabled infracost extension and in vscode I'm getting an error (in the vscode editor):

Could not run the infracost cmd in the /Users/USERNAME/repos/healthscope/Some-Infrastructure directory.
If this is a multi-project workspace please try opening just a single project. 
If this problem continues please open an issue here: https://github.com/infracost/vscode-infracost.

It does work on the cli when I specify the workspace though:

$ infracost breakdown --path . --terraform-workspace dev
Evaluating Terraform directory at .
  ✔ Downloading Terraform modules
  ✔ Evaluating Terraform directory
  ✔ Retrieving cloud prices to calculate costs

Project: Some-Infrastructure/some-aws-shakeout-ec2/app1
Workspace: dev

 Name                                                   Monthly Qty  Unit              Monthly Cost

 aws_alb.application_load_balancer
 ├─ Application load balancer                                   730  hours                   $18.40
 └─ Load balancer capacity units                     Monthly cost depends on usage: $5.84 per LCU

 aws_autoscaling_group.asg
 └─ aws_launch_template.apptemplate
    ├─ Instance usage (Linux/UNIX, on-demand, )                 730  hours                    $0.00
    └─ EC2 detailed monitoring                                    7  metrics                  $2.10

 aws_cloudwatch_metric_alarm.all_alarms["cpu_high"]
 └─ High resolution                                               1  alarm metrics            $0.30

 aws_cloudwatch_metric_alarm.all_alarms["cpu_low"]
 └─ High resolution                                               1  alarm metrics            $0.30

 OVERALL TOTAL                                                                               $21.10
──────────────────────────────────
28 cloud resources were detected:
∙ 4 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file
∙ 22 were free, rerun with --show-skipped to see details
∙ 2 are not supported yet, rerun with --show-skipped to see details

Currently got a 'dev' workspace:

$ terraform workspace list
* dev

Why can't you do something like this in the extension to figure out the active workspace?

terraform_workspace="$(command terraform workspace show 2>/dev/null)"

Any way to fix it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.