Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Add Infracost to GHA CI for infra cost tracking #1316

Merged
merged 13 commits into from
Jun 20, 2022
Merged

Conversation

HarshCasper
Copy link
Contributor

Partially-resolves #1315

Changes introduced in this PR:

  • Adds Infracost CI integration for QHub

Types of changes

What types of changes does your PR introduce?

Put an x in the boxes that apply

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds a feature)
  • Breaking change (fix or feature that would cause existing features to not work as expected)
  • Documentation Update
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build related changes
  • Other (please describe):

Testing

Requires testing

  • Yes
  • No

In case you checked yes, did you write tests?

  • Yes
  • No

@trallard trallard requested review from iameskild and viniciusdc June 9, 2022 14:41
Copy link
Member

@iameskild iameskild left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for working on this @HarshCasper! I appreciate the comments you left as well :)

I raised a few items that we might want to discuss before merging though, let me know what you think!

.github/workflows/infracost.yml Outdated Show resolved Hide resolved
.github/workflows/infracost.yml Show resolved Hide resolved
.github/workflows/infracost.yml Show resolved Hide resolved
@HarshCasper HarshCasper force-pushed the infracost-gha-ci branch 6 times, most recently from 36efdb9 to b31f226 Compare June 13, 2022 16:10
@nebari-dev nebari-dev deleted a comment from github-actions bot Jun 13, 2022
@nebari-dev nebari-dev deleted a comment from github-actions bot Jun 13, 2022
@nebari-dev nebari-dev deleted a comment from github-actions bot Jun 13, 2022
@nebari-dev nebari-dev deleted a comment from github-actions bot Jun 13, 2022
@HarshCasper HarshCasper force-pushed the infracost-gha-ci branch 6 times, most recently from a1dbf56 to 288c62f Compare June 13, 2022 17:35
@nebari-dev nebari-dev deleted a comment from github-actions bot Jun 13, 2022
@HarshCasper HarshCasper force-pushed the infracost-gha-ci branch 5 times, most recently from a0af065 to cc7af7f Compare June 14, 2022 07:15
@nebari-dev nebari-dev deleted a comment from github-actions bot Jun 14, 2022
@HarshCasper HarshCasper force-pushed the infracost-gha-ci branch 3 times, most recently from 405fa61 to c74f479 Compare June 14, 2022 08:11
@nebari-dev nebari-dev deleted a comment from github-actions bot Jun 14, 2022
@github-actions
Copy link

💰 Infracost estimate: monthly cost will decrease by $0.57 (-1%) 📉

Project Previous New Diff
Quansight/qhub/data/stages/01-terraform-state/aws $0.57 $0 -$0.57
All projects $73.57 $73.00 -$0.57 (-1%)

7 projects have no cost estimate changes.

Infracost output
Project: Quansight/qhub/data/stages/01-terraform-state/aws

- module.terraform-state.aws_dynamodb_table.terraform-state-lock
  -$0.57

    - Write capacity unit (WCU)
      -$0.47

    - Read capacity unit (RCU)
      -$0.09

    - Data storage
      Monthly cost depends on usage
        -$0.25 per GB

    - Point-In-Time Recovery (PITR) backup storage
      Monthly cost depends on usage
        -$0.20 per GB

    - On-demand backup storage
      Monthly cost depends on usage
        -$0.10 per GB

    - Table data restored
      Monthly cost depends on usage
        -$0.15 per GB

    - Streams read request unit (sRRU)
      Monthly cost depends on usage
        -$0.0000002 per sRRUs

- module.terraform-state.aws_s3_bucket.terraform-state
  Monthly cost depends on usage

    - 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

Monthly cost change for Quansight/qhub/data/stages/01-terraform-state/aws
Amount:  -$0.57 ($0.57 → $0.00)

──────────────────────────────────

The following projects have no cost estimate changes: Quansight/qhub/data/stages/02-infrastructure/aws, Quansight/qhub/data/stages/03-kubernetes-initialize, Quansight/qhub/data/stages/04-kubernetes-ingress, Quansight/qhub/data/stages/05-kubernetes-keycloak, Quansight/qhub/data/stages/06-kubernetes-keycloak-configuration, Quansight/qhub/data/stages/07-kubernetes-services, Quansight/qhub/data/stages/08-qhub-tf-extensions
Run the following command to see their breakdown: infracost breakdown --path=/path/to/code

──────────────────────────────────
Key: ~ changed, + added, - removed

4 cloud resources were detected:
∙ 4 were estimated, 3 of which include usage-based costs, see https://infracost.io/usage-file

This comment will be updated when the cost estimate changes.

Is this comment useful? Yes, No

@trallard trallard added the needs: changes 🧱 Review completed - some changes are needed before merging label Jun 14, 2022
.github/workflows/infracost.yml Show resolved Hide resolved
on:
pull_request:
paths:
- 'qhub/template/stages/02-infrastructure'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we targetting only the 02-infrastructure stage here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are some resources created during other stages (such as the loadbalancer), does infracost run over all the stages or only the initial 01 and 02?

It runs over all the stages, not just the initial 01 and 02. However, the workflow doesn't detect changes in the infrastructure not mentioned on the filters. Can you just let me know about them so that I can add them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we targetting only the 02-infrastructure stage here?

It's as per the comment by @costrouc. If you want, I can direct it to target changes made on any change in the infrastructure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it's okay for me. Could you point me out to this comment as well? no need to change the config. Thanks @HarshCasper

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viniciusdc It was over a private message. @costrouc can verify that.

.github/workflows/infracost.yml Show resolved Hide resolved
.github/workflows/infracost.yml Show resolved Hide resolved
.github/workflows/infracost.yml Outdated Show resolved Hide resolved
.github/workflows/infracost.yml Outdated Show resolved Hide resolved
.github/workflows/infracost.yml Show resolved Hide resolved
Copy link
Member

@iameskild iameskild left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💰 Infracost estimate: monthly cost will decrease by $0.57 (-1%) 📉

Project Previous New Diff
Quansight/qhub/data/stages/01-terraform-state/aws $0.57 $0 -$0.57
All projects $73.57 $73.00 -$0.57 (-1%)
7 projects have no cost estimate changes.

Infracost output
This comment will be updated when the cost estimate changes.

Is this comment useful? Yes, No

Thanks for all the updates @HarshCasper! This is looking real sweet 😎

Let me just verify I understand these changes too:

  • the above Infracost output whenever we make changes (PR) to stages 01-02 (see filter)
  • and CI outputs these costs as an artifact

LGTM!

@HarshCasper
Copy link
Contributor Author

the above Infracost output whenever we make changes (PR) to stages 01-02 (see filter)

Yes! Whenever the infrastructure is changed for either cloud service provider, the Infracost PR report is generated.

and CI outputs these costs as an artifact

Yes! It is also posted as a PR comment (for the particular cloud service provider).

Copy link
Contributor

@viniciusdc viniciusdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @iameskild commented, this LGTM as well. If anything we can update this later if needed.

@HarshCasper HarshCasper merged commit f1ecde5 into main Jun 20, 2022
@HarshCasper HarshCasper deleted the infracost-gha-ci branch June 20, 2022 16:33
@pmeier pmeier mentioned this pull request May 15, 2023
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: CI/CD 👷🏽‍♀️ area:developer-experience 👩🏻‍💻 area: terraform 💾 needs: changes 🧱 Review completed - some changes are needed before merging needs: follow-up 📫 Someone needs to get back to this issue or PR
Projects
Development

Successfully merging this pull request may close these issues.

[ENH] - Add Infracost to QHub CI and CLI
4 participants