Git Product home page Git Product logo

actions's Introduction

Infracost breakdown command

Infracost shows cloud cost estimates and FinOps best practices for Terraform. It lets engineers see a cost breakdown and understand costs before making changes, either in the terminal, VS Code or pull requests.

Docs Docker pulls Community Slack channel tweet

Get started

Follow our quick start guide to get started ๐Ÿš€

Infracost also has many CI/CD integrations so you can easily post cost estimates in pull requests. This provides your team with a safety net as people can discuss costs as part of the workflow.

Post cost estimates in pull requests

Infracost in GitHub Actions

Output of infracost breakdown

Infracost breakdown command

infracost diff shows diff of monthly costs between current and planned state

Infracost diff command

Infracost Cloud

Infracost Cloud is our SaaS product that builds on top of Infracost open source and works with CI/CD integrations. It enables you to check for best practices such as using latest generation instance types or block storage, e.g. consider switching AWS gp2 volumes to gp3 as they are more performant and cheaper. Team leads, managers and FinOps practitioners can also setup tagging policies and guardrails to help guide the team.

Infracost Cloud

Supported clouds and resources

Infracost supports over 1,100 Terraform resources across AWS, Azure and Google. Other IaC tools, such as Pulumi, AWS CloudFormation/CDK and Azure ARM/Bicep are on our roadmap.

Infracost can also estimate usage-based resources such as AWS S3 or Lambda!

Community and contributing

Join our community Slack channel to learn more about cost estimation, Infracost, and to connect with other users and contributors. Checkout the pinned issues for our next community call or our YouTube for previous calls.

We โค๏ธ contributions big or small. For development details, see the contributing guide. For major changes, including CLI interface changes, please open an issue first to discuss what you would like to change.

Thanks to all the people who have contributed, including bug reports, code, feedback and suggestions!

License

Apache License 2.0

actions's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

actions's Issues

feature: support multi api-key

summary

infracost/actions support multiple api-key ?

on: [pull_request]
env:
  SSH_AUTH_SOCK: /tmp/ssh_agent.sock
jobs:
  infracost:
    name: Infracost
    runs-on: ubuntu-latest
    permissions:
      contents: read
      # Required to post comments
      pull-requests: write
  
    steps:
      - name: Setup Infracost
        uses: infracost/actions/setup@v2
        with:
          api-key: ${{ secrets.INFRACOST_API_KEY }}  // ๐Ÿ˜ 

Error: json: cannot unmarshal number 2176460725 into Go value of type githubv4.Int

I encountered an error when Infracost is trying to post a pull request comment using GitHub Actions using the following step in the GitHub Actions workflow:

- name: Post Infracost comment
  run: |
    infracost comment github --path=/tmp/infracost.json \
                              --repo=$GITHUB_REPOSITORY \
                              --github-token=${{github.token}} \
                              --pull-request=${{github.event.pull_request.number}} \
                              --behavior=update

Error Message:

Error: The pull request comment was generated successfully but could not be posted:
json: cannot unmarshal number 2176460725 into Go value of type githubv4.Int

See https://infracost.io/docs/troubleshooting/#5-posting-comments for help.
Error: Process completed with exit code 1.

Running infracost action using `working-directory`

We are using working-directory https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun

defaults:
 run:
  working-directory: applications/prod/kafka-ui

We then define below a cost job.

  cost:
    needs: plan
    name: cost
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout/@v3
    - name: Setup Infracost
      uses: infracost/actions/setup@v2
      with:
        api-key: ${{ secrets.INFRACOST_API_KEY }}
    - name: Checkout base branch
      uses: actions/checkout@v3
      with:
        ref: '${{ github.event.pull_request.base.ref }}'

    - name: Generate Infracost cost estimate baseline
      run: |
        infracost breakdown --path=. \
                            --format=json \
                            --out-file=/tmp/infracost-base.json
    - name: Checkout PR branch
      uses: actions/checkout@v3
    - name: Generate Infracost diff
      run: |
        infracost diff --path=. \
                        --format=json \
                        --compare-to=/tmp/infracost-base.json \
                        --out-file=/tmp/infracost.json
    - name: Post Infracost comment
      run: |
          infracost comment github --path=/tmp/infracost.json \
                                   --repo=$GITHUB_REPOSITORY \
                                   --github-token=${{github.token}} \
                                   --pull-request=${{github.event.pull_request.number}} \
                                   --behavior=new

However this is failing with the following error

An error occurred trying to start process '/usr/bin/bash' with working directory '/home/runner/work/infra-kafka/infra-kafka/applications/prod/kafka-ui'. No such file or directory

any idea what is happening here?

github action infracost/actions/setup@v2 failing because node12 is blocked by github

error i see in the github action logs:

Node.js 12 actions are deprecated. Please update the following actions to use Node.js 16: infracost/actions/setup@v2. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.

should use node16

https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/

using: node12

Usage of PR_NUMBER while using reusable workflow .

I have a master workflow which calls the actual terraform workflow .
While sending PR_NO: ${{github.event.pull_request.number}} to the called workflow , its not able to pick the number of the PR to comment .

with:
PR_NO: ${{github.event.pull_request.number}}

Action not working with Terraform Cloud

First I used this guide. After I got the error:

Error: terraform plan failed: exit status 1

Try setting the --path to a Terraform plan JSON file. See https://infracost.io/troubleshoot for how to generate this.
Error: Process completed with exit code 1.

I have tried several other options, all without success.

My last GitHub Actions configuration looks like this:

name: Terraform

on:
  push:
    branches:
      - main
    paths:
      - '**.tf'
  pull_request:
    paths:
      - '**.tf'

jobs:
  terraform:
    name: Terraform
    runs-on: ubuntu-latest
    env:
      working-directory: .
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup Terraform
        uses: hashicorp/setup-terraform@v1
        with:
          cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
          terraform_version: 1.1.5

      - name: Terraform Format
        id: fmt
        run: terraform fmt -check -recursive
        working-directory: ${{ env.working-directory }}

      - name: Terraform Init
        id: init
        run: terraform init
        working-directory: ${{ env.working-directory }}

      - name: Terraform Validate
        id: validate
        run: terraform validate -no-color
        working-directory: ${{ env.working-directory }}

      - name: Setup TFLint
        uses: terraform-linters/setup-tflint@v1
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}

      - name: Run TFLint
        run: tflint --format compact
        working-directory: ${{ env.working-directory }}

      - name: Terraform Plan
        id: plan
        if: github.event_name == 'pull_request'
        run: terraform plan -no-color -compact-warnings
        working-directory: ${{ env.working-directory }}
        continue-on-error: true

      - name: Truncate Terraform Plan
        if: github.event_name == 'pull_request'
        run: |
          plan=$(cat <<'EOF'
          ${{ format('{0}{1}', steps.plan.outputs.stdout, steps.plan.outputs.stderr) }}
          EOF
          )
          echo "PLAN<<EOF" >> $GITHUB_ENV
          echo "${plan:0:65536}" >> $GITHUB_ENV
          echo "EOF" >> $GITHUB_ENV

      - name: Update Pull Request
        uses: actions/github-script@v5
        if: github.event_name == 'pull_request'
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          script: |
            github.rest.issues.createComment({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: `
            **Terraform Format and Style**: \`${{ steps.fmt.outcome }}\`
            **Terraform Initialization**: \`${{ steps.init.outcome }}\`
            **Terraform Plan**: \`${{ steps.plan.outcome }}\`
            **Terraform Validation**: \`${{ steps.validate.outcome }}\`

            <details><summary>Plan Details</summary>

            \`\`\`terraform
            ${process.env.PLAN}
            \`\`\`\

            </details>

            **Pusher**: @${{ github.actor }}
            **Action**: \`${{ github.event_name }}\`
            `
            })

      - name: Terraform Plan Status
        if: steps.plan.outcome == 'failure'
        run: exit 1

      - name: Setup Infracost
        if: github.event_name == 'pull_request'
        uses: infracost/actions/setup@v1
        with:
          api-key: ${{ secrets.INFRACOST_API_KEY }}

      - name: Generate Infracost JSON
        if: github.event_name == 'pull_request'
        run: infracost breakdown --path ${{ env.working-directory }} --format json --out-file /tmp/infracost.json
        working-directory: ${{ env.working-directory }}

      - name: Post Infracost Comment
        if: github.event_name == 'pull_request'
        uses: infracost/actions/comment@v1
        with:
          path: /tmp/infracost.json
          behavior: new

      - name: Terraform Apply
        if: github.ref == 'refs/heads/main' && github.event_name == 'push'
        run: terraform apply -auto-approve
        working-directory: ${{ env.working-directory }}

All *.tf files are located in the root of the repository.

Each run of Generate Infracost JSON step looks like this:

Run infracost breakdown --path . --format json --out-file /tmp/infracost.json
  infracost breakdown --path . --format json --out-file /tmp/infracost.json
  shell: /usr/bin/bash -e {0}
  env:
    working-directory: .
    TERRAFORM_CLI_PATH: /home/runner/work/_temp/f790a945-b2d2-4cfb-b698-7f567a359822
    PLAN: Running plan in the remote backend. Output will stream here. Pressing Ctrl-C
  will stop streaming the logs, but will not stop the plan running remotely.
  
  Preparing the remote plan...
  
  To view this run in a browser, visit:
  https://app.terraform.io/app/website/test/runs/run-9d2nNaVjbf4sPWG5
  
  Waiting for the plan to start...
  
  Terraform v1.1.5
  on linux_amd64
  Configuring remote state backend...
  Initializing Terraform configuration...


(removed for brevity)

  
  Plan: 4 to add, 0 to change, 0 to destroy.
  โ•ท
  โ”‚ Warning: Experimental feature "module_variable_optional_attrs" is active
  โ”‚ 
  โ”‚   on .terraform/modules/acme_com/main.tf line 2, in terraform:
  โ”‚    2:   experiments = [module_variable_optional_attrs]
  โ”‚ 
  โ”‚ Experimental features are subject to breaking changes in future minor or
  โ”‚ patch releases, based on feedback.
  โ”‚ 
  โ”‚ If you have feedback on the design of this feature, please open a GitHub
  โ”‚ issue to discuss it.
  โ•ต
    INFRACOST_GITHUB_ACTION: true
    INFRACOST_SKIP_UPDATE_CHECK: true
    INFRACOST_VCS_REPOSITORY_URL: https://github.com/website/terraform-test
    INFRACOST_VCS_PULL_REQUEST_URL: https://github.com/website/terraform-test/pull/13
    INFRACOST_LOG_LEVEL: info
time="2022-02-22T18:00:31Z" level=info msg="Detected Terraform directory at ."
time="2022-02-22T18:00:31Z" level=info msg="Starting: Running terraform plan"

Error: terraform plan failed: exit status 1

Try setting the --path to a Terraform plan JSON file. See https://infracost.io/troubleshoot for how to generate this.
Error: Process completed with exit code 1.

I have several questions:

  1. It says that you can point to the Terraform configuration directory, how do you specify that the directory is the top level directory in the repository? I've tried different options - none work.
  2. How exactly to specify parameters when using Action? Here = sign is used between the parameter and its value like this: infracost breakdown --path=examples/terraform-cloud-enterprise/code --format=json --out-file=/tmp/infracost.json, and on the main page the parameter and its value are separated by a space like this: infracost breakdown --path plan.json --format json --out-file /tmp/infracost.json. Are both options acceptable or is the documentation out of date?
  3. How to make it work with Terraform Cloud?

Error: No INFRACOST_API_KEY environment variable is set.

Description

I've started getting this error when running the action:

Error: No INFRACOST_API_KEY environment variable is set.

My workflows worked fine last time they ran so I'm wondering if something has changed with v2 since then.

From my understanding I only need the setup action to reference the API secret, like so:

    steps:
      - name: 'Setup Infracost'
        uses: infracost/actions/setup@v2
        with:
          api-key: ${{ secrets.INFRACOST_API_KEY }}

However, once I get to follow-up steps to either breakdown or diff I get the error.

Any idea what's going on?

Thanks in advance.

Infracost comment github --tag

Hi,

Context

Got a github repository which manage 2 environment, prod and non-prod. Theses environment are managed by github-action through matrix.

Infracost setup :

      - name: Setup Infracost
        uses: infracost/actions/setup@v1

Got an issue with the following command

infracost comment github --path /tmp/infracost-${{ matrix.environment }}.json \
                                   --repo $GITHUB_REPOSITORY \
                                   --github-token ${{github.token}} \
                                   --pull-request ${{github.event.pull_request.number}} \
                                   --behavior update \
                                   --tag "${{ matrix.environment }}"

Issue

The behaviour of --tag seems wrong.
Because of matrix job is executed twice.

  • The first one for example non-prod create a new comment which containing the tag "non-prod"
  • The second one, prod, update the comment created by non-prod and replace the tag

Expected

  • The first one non-prod create a new comment which contains the tag "non-prod"
  • The second one, prod, create a new comment which contains the tag "prod"

Trouble with infracost diff

I'm likely doing something wrong but just not sure what. I can get an infracost breakdown to work in my workflow, however adding infracost diff is having problems. Any advice would be appreciated.
So the first part of the job in the workflow it runs terraform init,workspace,plan then I have the following:

    - name: Setup Infracost
      uses: infracost/actions/[email protected]
      with:
        api-key: ${{ secrets.INFRACOST_API_KEY }}
    
    # - name: Checkout base branch
    #   uses: actions/checkout@v3
    #   with:
    #     ref: '${{ github.event.pull_request.base.ref }}'

    - name: Generate Infracost cost estimate baseline
      run: |
        infracost breakdown --path=. \
                            --format=json \
                            --out-file=/tmp/infracost-base.json

    - name: Checkout PR branch
      uses: actions/checkout@v3
      with:
        ref: '${{ github.event.pull_request.head.ref }}'

    - name: Generate Infracost diff
      run: |
        infracost diff --path=. \
                       --format=json \
                       --compare-to=/tmp/infracost-base.json \
                       --out-file=/tmp/infracost.json
    
    - name: Post Infracost comment
      run: |
        infracost comment github --path=/tmp/infracost.json \
                                 --repo=$GITHUB_REPOSITORY \
                                 --github-token=${{ secrets.GITHUB_TOKEN }} \
                                 --pull-request=${{github.event.pull_request.number}} \
                                 --behavior=update \
                                 --policy-path=${{ github.workspace }}/.github/infracost/infracost-policy.rego

The comment looks like this :
image
So I'm not sure why Diff goes to to $0. I also have the checkout base branch commented out as if I do run it the infracost comment gives me $0's across the board with warnings in the logs like:
time="2023-04-19T14:56:02Z" level=warning msg="No products found for module.avd_vm_pooled_module.azurerm_windows_virtual_machine.main[0] Instance usage (hybrid benefit, Standard_D2s_v3), using 0.00"

GITHUB_TOKEN permissions used by this action

At https://github.com/step-security/secure-workflows we are building a knowledge-base (KB) of GITHUB_TOKEN permissions needed by different GitHub Actions. When developers try to set minimum token permissions for their workflows, they can use this knowledge-base instead of trying to research permissions needed by each GitHub Action they use.

Below you can see the KB of your GITHUB Action.

name: "Setup Infracost"
#GITHUB_TOKEN not used
#FIXES: #616

If you think this information is not accurate, or if in the future your GitHub Action starts using a different set of permissions, please create an issue at https://github.com/step-security/secure-workflows/issues to let us know.

This issue is automatically created by our analysis bot, feel free to close after reading :)

References:

GitHub asks users to define workflow permissions, see https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/ and https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token for securing GitHub workflows against supply-chain attacks.

Setting minimum token permissions is also checked for by Open Source Security Foundation (OpenSSF) Scorecards. Scorecards recommend using https://github.com/step-security/secure-workflows so developers can fix this issue in an easier manner.

Infracost estimate: monthly cost will increase by $0.00 - When base branch is empty

We have started a new infrastructure project where we are deploying aws-msk. We have two branches.

In our main branch it is empty.
In dev/modules it contains our new terraform config.

We have created a PR from dev/modules to main. During the CI run we get the following message when we are expecting more.

Infracost estimate: monthly cost will increase by $0.00

image

If we run infracost breakdown --path . --show-skipped locally in our dev/modules branch we get what we are expecting to see in our CI.

Project: <redacted>/infra-kafka/applications/prod/msk

 Name                                                                           Monthly Qty  Unit                    Monthly Cost

 aws_s3_bucket.custom_plugins
 โ””โ”€ Standard
    โ”œโ”€ Storage                                                            Monthly cost depends on usage: $0.023 per GB
    โ”œโ”€ PUT, COPY, POST, LIST requests                                     Monthly cost depends on usage: $0.005 per 1k requests
    โ”œโ”€ GET, SELECT, and all other requests                                Monthly cost depends on usage: $0.0004 per 1k requests
    โ”œโ”€ Select data scanned                                                Monthly cost depends on usage: $0.002 per GB
    โ””โ”€ Select data returned                                               Monthly cost depends on usage: $0.0007 per GB

 module.prod_msk_default.aws_cloudwatch_log_group.this
 โ”œโ”€ 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

 module.prod_msk_default.aws_msk_cluster.this
 โ”œโ”€ Instance (kafka.m5.large)                                                         2,190  hours                        $459.90
 โ””โ”€ Storage (autoscaling)                                                                 3  GB                             $0.30

 module.prod_msk_mongodb_default_connector.aws_cloudwatch_log_group.this
 โ”œโ”€ 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

 module.prod_msk_mysql_default_connector.aws_cloudwatch_log_group.this
 โ”œโ”€ 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                                                                                                            $460.20
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
30 cloud resources were detected:
โˆ™ 6 were estimated, 4 of which include usage-based costs, see https://infracost.io/usage-file
โˆ™ 14 were free:
  โˆ™ 4 x aws_iam_role
  โˆ™ 4 x aws_iam_role_policy_attachment
  โˆ™ 2 x aws_iam_policy
  โˆ™ 1 x aws_appautoscaling_policy
  โˆ™ 1 x aws_iam_instance_profile
  โˆ™ 1 x aws_msk_configuration
  โˆ™ 1 x aws_security_group
โˆ™ 10 are not supported yet, see https://infracost.io/requested-resources:
  โˆ™ 3 x aws_mskconnect_custom_plugin
  โˆ™ 3 x aws_s3_object
  โˆ™ 2 x aws_mskconnect_connector
  โˆ™ 2 x aws_mskconnect_worker_configuration

terraform-ci.yaml

name: terraform-ci

on:
  workflow_call:
    inputs:
      TF_ROOT:
        required: true
        type: string
      TF_APP_NAME:
        required: true
        type: string

jobs:
  cost:
    needs: plan
    name: cost
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout/@v3
    - name: Setup Infracost
      uses: infracost/actions/setup@v2
      with:
        api-key: ${{ secrets.INFRACOST_API_KEY }}
    - name: Checkout base branch
      uses: actions/checkout@v3
      with:
        ref: '${{ github.event.pull_request.base.ref }}'
    - name: Generate Infracost cost estimate baseline
      run: |
        infracost breakdown --path=${{ inputs.TF_ROOT }} \
                            --format=json \
                            --out-file=/tmp/infracost-base.json
        cat /tmp/infracost-base.json

    - name: Checkout PR branch
      uses: actions/checkout@v3
    - name: Generate Infracost diff
      run: |
        infracost diff --path=${{ inputs.TF_ROOT }} \
                        --format=json \
                        --compare-to=/tmp/infracost-base.json \
                        --out-file=/tmp/infracost.json
        cat /tmp/infracost-base.json
        echo "here"
        cat /tmp/infracost.json
    - name: Post Infracost comment
      run: |
          infracost comment github --path=/tmp/infracost.json \
                                   --repo=$GITHUB_REPOSITORY \
                                   --github-token=${{github.token}} \
                                   --pull-request=${{github.event.pull_request.number}} \
                                   --behavior=new

/tmp/infracost-base.json

{"version":"0.2","metadata":{"infracostCommand":"breakdown","vcsBranch":"main","vcsCommitSha":"c9137bb438353a9a2d6630c7491c16bc28bd584e","vcsCommitAuthorName":"Kay Khan","vcsCommitAuthorEmail":"redacted","vcsCommitTimestamp":"2023-08-16T12:43:47Z","vcsCommitMessage":"first commit","vcsRepositoryUrl":"https://github.com/redacted/infra-kafka","vcsProvider":"github","vcsBaseBranch":"main","vcsPullRequestTitle":"feat: kafka + kafkaui","vcsPullRequestUrl":"https://github.com/redacted/infra-kafka/pull/1","vcsPullRequestAuthor":"kaykhan","vcsPipelineRunId":"5901458303","vcsPullRequestId":"1"},"currency":"USD","projects":[{"name":"redacted/infra-kafka/applications/prod/msk","metadata":{"path":"applications/prod/msk","type":"error","vcsSubPath":"applications/prod/msk","errors":[{"code":0,"message":"No such file or directory applications/prod/msk\n\nTry adding a config-file to configure how Infracost should run. See https://infracost.io/config-file for details and examples.","data":null}]},"pastBreakdown":{"resources":[],"totalHourlyCost":"0","totalMonthlyCost":"0"},"breakdown":{"resources":[],"totalHourlyCost":"0","totalMonthlyCost":"0"},"diff":{"resources":[],"totalHourlyCost":"0","totalMonthlyCost":"0"},"summary":{"totalDetectedResources":0,"totalSupportedResources":0,"totalUnsupportedResources":0,"totalUsageBasedResources":0,"totalNoPriceResources":0,"unsupportedResourceCounts":{},"noPriceResourceCounts":{}}}],"totalHourlyCost":"0","totalMonthlyCost":"0","pastTotalHourlyCost":"0","pastTotalMonthlyCost":"0","diffTotalHourlyCost":"0","diffTotalMonthlyCost":"0","timeGenerated":"2023-08-18T10:15:30.213041174Z","summary":{"totalDetectedResources":0,"totalSupportedResources":0,"totalUnsupportedResources":0,"totalUsageBasedResources":0,"totalNoPriceResources":0,"unsupportedResourceCounts":{},"noPriceResourceCounts":{}}}

/tmp/infracost.json

{"version":"0.2","metadata":{"infracostCommand":"diff","vcsBranch":"dev/modules","vcsCommitSha":"40567b7ed14441c64890b09f0cca994f688a910e","vcsCommitAuthorName":"Kay Khan","vcsCommitAuthorEmail":"redacted","vcsCommitTimestamp":"2023-08-18T10:13:53Z","vcsCommitMessage":"update: debug","vcsRepositoryUrl":"https://github.com/redacted/infra-kafka","vcsProvider":"github","vcsBaseBranch":"main","vcsPullRequestTitle":"feat: kafka + kafkaui","vcsPullRequestUrl":"https://github.com/redacted/infra-kafka/pull/1","vcsPullRequestAuthor":"kaykhan","vcsPipelineRunId":"5901458303","vcsPullRequestId":"1"},"currency":"USD","projects":[{"name":"redacted/infra-kafka/applications/prod/msk","metadata":{"path":"applications/prod/msk","type":"terraform_dir","vcsSubPath":"applications/prod/msk","errors":[{"code":0,"message":"Diff baseline error: No such file or directory applications/prod/msk\n\nTry adding a config-file to configure how Infracost should run. See https://infracost.io/config-file for details and examples.","data":null}],"providers":[{"name":"aws","filename":"applications/prod/msk/versions.tf","startLine":13,"endLine":15}]},"pastBreakdown":null,"breakdown":{"resources":[],"totalHourlyCost":"0","totalMonthlyCost":"0"},"diff":null,"summary":{"totalDetectedResources":30,"totalSupportedResources":6,"totalUnsupportedResources":10,"totalUsageBasedResources":4,"totalNoPriceResources":14,"unsupportedResourceCounts":{"aws_mskconnect_connector":2,"aws_mskconnect_custom_plugin":3,"aws_mskconnect_worker_configuration":2,"aws_s3_object":3},"noPriceResourceCounts":{"aws_appautoscaling_policy":1,"aws_iam_instance_profile":1,"aws_iam_policy":2,"aws_iam_role":4,"aws_iam_role_policy_attachment":4,"aws_msk_configuration":1,"aws_security_group":1}}}],"totalHourlyCost":"0","totalMonthlyCost":"0","pastTotalHourlyCost":null,"pastTotalMonthlyCost":null,"diffTotalHourlyCost":null,"diffTotalMonthlyCost":null,"timeGenerated":"2023-08-18T10:15:33.247471322Z","summary":{"totalDetectedResources":30,"totalSupportedResources":6,"totalUnsupportedResources":10,"totalUsageBasedResources":4,"totalNoPriceResources":14,"unsupportedResourceCounts":{"aws_mskconnect_connector":2,"aws_mskconnect_custom_plugin":3,"aws_mskconnect_worker_configuration":2,"aws_s3_object":3},"noPriceResourceCounts":{"aws_appautoscaling_policy":1,"aws_iam_instance_profile":1,"aws_iam_policy":2,"aws_iam_role":4,"aws_iam_role_policy_attachment":4,"aws_msk_configuration":1,"aws_security_group":1}}}

it appears like it is unable to estiamte the cost if there is no base to compare with?

I think it would be better if it produced the output of infracost breakdown --path . --show-skipped when there is no base to compare with? How might we do this, has this been considered?

Empty Infracost output

I'm attempting to use v2 of the infracost action from a plan output json and running into a bizarre issue. The step runs successfully, is able to identify input and output files, but the comment step always produces an empty comment:

Screen Shot 2022-06-22 at 1 48 50 PM

The step code looks something like this:

steps:
  - name: Generate Infracost diff
    id: infracost-diff
    run: |
      # define vars
      _infile="${{ steps.terraform-show.outputs.outfile }}"
      _outfile="/tmp/infracost.json"
      
      # execute infracost
      infracost diff \
        --path="${_infile}" \
        --format=json \
        --out-file="${_outfile}"
      
      # set outputs
      echo "::set-output name=outfile::${_outfile}"

Any pointers? The entirely empty output is puzzling!

No valid Terraform files found at the given path, try a different directory | Github action

  • name: Generate Infracost cost estimate baseline
    run: |
    ls -l

     sed -i '1,2d' plan.json
     infracost breakdown --path plan.json  --format json --out-file /tmp/infracost-base.json
    
  • name: Generate Infracost diff
    run: |
    infracost diff --path plan.json --format=json --compare-to=/tmp/infracost-base.json --out-file=/tmp/infracost.json

Output : Run ls -l
total 11188

-rw-r--r-- 1 runner docker 6605 Nov 15 08:52 CHANGELOG.md
-rw-r--r-- 1 runner docker 384 Nov 15 08:52 CODEOWNERS
-rw-r--r-- 1 runner docker 5641 Oct 28 08:55 README.md

drwxr-xr-x 2 runner docker 4096 Nov 15 08:52 bin
drwxr-xr-x 4 runner docker 4096 Nov 15 08:52 infrastructure
-rw-r--r-- 1 runner docker 247309 Nov 15 08:53 plan.json

Error: No valid Terraform files found at the given path, try a different directory

Try setting --path to a Terraform plan JSON file. See https://infracost.io/troubleshoot for how to generate this.
Error: Process completed with exit code 1.


But doing an ls shows file is present is the same path as plan.json. Not sure what has changed , since this was working earlier .Guidancen please

post_condition seems to have disapeared from new GH Action

In the previous github action, there were several options to post infracost comments in PR only under conditions, with the post_condition JSON string

  • has_diff
  • percentage_threshold

This was really useful to post comments only when necessary, and avoid adding noise in the pull requests.

As these options seem to have disappeared, is there an alternative?

Increment to Node 20

GitHub is deprecating Node 16 this spring. Infracost is currently using Node 16 so all actions-invoked Infracost runs will fail. Please increment to Node 20.

Warning Message:
Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: webfactory/[email protected], infracost/actions/setup@v2. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.

Not able to download modules from private hosting

My terraform structure is ->


.github/workflowfiles
infra/env/teama/storage.tf

modules/storage/main.tf
...................................

Modules are hosted at private registry .Now the issue is when resource defined in teama folder calls the modules , infracost gives out an error saying module path not found.

Error: Error loading Terraform modules: error downloading 'file:///home/runner/work/infra-cost-test/infra-cost-test/infrastructure/env/teama/.infracost/terraform_modules/teama.storage/terraform.hosting.company.com/company/storage/azurerm': source path error: (path omitted )
Error: Process completed with exit code 1.

Can someone helps by telling how to use it with private path please?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.