Skip to content

Commit

Permalink
Merge pull request #84 from infracost/add_test_step
Browse files Browse the repository at this point in the history
docs: update docs
  • Loading branch information
tim775 authored Feb 19, 2024
2 parents 751cae5 + 6c36b47 commit 44af881
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 44 deletions.
Binary file modified .github/assets/infracost-cloud-dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Infracost Atlantis Integration

This repo shows how [Infracost](https://infracost.io) can be used with Atlantis, so you can see cloud cost estimates for Terraform in pull requests 💰
### Try the GitHub or GitLab App
👉👉 If you use Atlantis with GitHub/GitLab, we recommend using the free Infracost [**GitHub App**](https://www.infracost.io/docs/integrations/github_app/) or [**GitLab App**](https://www.infracost.io/docs/integrations/gitlab_app/) as they're much simpler to setup and faster to run

---

This repo shows how [Infracost](https://infracost.io) can be used with Atlantis, so you can see cloud cost estimates and FinOps best practices for Terraform in pull requests 💰

<img src="examples/combined-infracost-comment/screenshot.png" width=640 alt="Example screenshot" />

Expand Down Expand Up @@ -41,24 +46,22 @@ To use this method, add the following `pre_workflow_hook` to your chosen option
Once you've decided, **<a href="examples/combined-infracost-comment/README.md">follow this guide</a>** to setup Infracost with Atlantis.
## Additional examples
### 3. Test the integration
Follow [these simple steps](https://www.infracost.io/docs/infracost_cloud/get_started/#4-send-a-pull-request) to test the integration. This is important as it ensures the CLI commands are running correctly in your workflow 👌
The following examples might be helpful to use alongside the above examples:
- [Slack](./examples/slack/README.md): post cost estimates to Slack
- [Conftest](./examples/conftest/README.md): check cost policies using Atlantis' native Conftest integration and Infracost cost estimates.
- [Infracost Cloud](https://dashboard.infracost.io) is our SaaS product that builds on top of Infracost open source. It enables team leads, managers and FinOps practitioners to setup [tagging policies](https://www.infracost.io/docs/infracost_cloud/tagging_policies/), [guardrails](https://www.infracost.io/docs/infracost_cloud/guardrails/) and [best practices](https://www.infracost.io/docs/infracost_cloud/cost_policies/) to help guide the team. For example, you can check for required tag keys/values, or suggest switching AWS gp2 volumes to gp3 as they are more performant and cheaper.
If you do not use Conftest/Open Policy Agent, you can still set [thresholds](./examples/thresholds/README.md) using bash and [jq](https://stedolan.github.io/jq/) so notifications or pull request comments are only sent when cost thresholds are exceeded.
If you **do not** want to use [Infracost Cloud](https://dashboard.infracost.io), go to Org Settings and disable the dashboard. This causes the CLI not to send its JSON output to your dashboard; the JSON does not contain any cloud credentials or secrets, see the [FAQ](https://infracost.io/docs/faq/) for more information.
<img src=".github/assets/infracost-cloud-dashboard.png" alt="Infracost Cloud enables you to check for best practices such as using latest generation instance types or block storage, as well as setup tagging policies and guardrails to help guide the team." />
## Atlantis usage notes
### Private Terraform modules
To use with Terraform modules that are hosted in a private git repository you can add the `--write-git-creds` flag to your `atlantis server` command.

### Terraform Cloud/Enterprise

To use with Terraform Cloud/Enterprise you can add the following flags to your `atlantis server` command: `--tfe-hostname='MY_TFE_HOSTNAME' --tfe-token='MY_TFE_TOKEN'`.

### Project names

Project names default to the relative path of the project using the Atlantis `$REPO_REL_DIR` environment variable. See [our docs](https://www.infracost.io/docs/infracost_cloud/key_concepts/#customize-project-names) to customize this.
Expand Down
40 changes: 6 additions & 34 deletions examples/combined-infracost-comment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This Atlantis repo.yaml file shows how Infracost can be used with Atlantis. Even

## Running with GitHub

👉👉 We recommend using the [**free Infracost GitHub App**](https://www.infracost.io/docs/integrations/github_app/) instead as it has many benefits.
👉👉 We recommend using the [**free Infracost GitHub App**](https://www.infracost.io/docs/integrations/github_app/) as it's much simpler to setup and faster to run

1. Update your setup to use the [infracost-atlantis](https://hub.docker.com/r/infracost/infracost-atlantis) Docker image
2. If you haven't done so already, [download Infracost](https://www.infracost.io/docs/#quick-start) and run `infracost auth login` to get a free API key.
Expand Down Expand Up @@ -83,18 +83,11 @@ This Atlantis repo.yaml file shows how Infracost can be used with Atlantis. Even
```
6. Restart the Atlantis application with the new environment vars and config.
7. Send a pull request in GitHub to change something in the Terraform code, the Infracost pull request comment should be added and show details for every changed project.
<img src="screenshot.png" width=640 alt="Example screenshot" />
8. In [Infracost Cloud](https://dashboard.infracost.io), go to Org Settings and enable the dashboard, then trigger your CI/CD pipeline again. This causes the CLI to send its JSON output to your dashboard; the JSON does not contain any cloud credentials or secrets, see the [FAQ](https://infracost.io/docs/faq/) for more information.
This is our SaaS product that builds on top of Infracost open source. It enables team leads, managers and FinOps practitioners to setup [tagging policies](https://www.infracost.io/docs/infracost_cloud/tagging_policies/), [guardrails](https://www.infracost.io/docs/infracost_cloud/guardrails/) and [best practices](https://www.infracost.io/docs/infracost_cloud/cost_policies/) to help guide the team. For example, you can check for required tag keys/values, or suggest switching AWS GP2 volumes to GP3 as they are more performant and cheaper.
<img src="/.github/assets/infracost-cloud-dashboard.png" alt="Infracost Cloud gives team leads, managers and FinOps practitioners visibility across all cost estimates in CI/CD" width="58%" /><img src="/.github/assets/pull-request-tags.png" alt="Communicate and enforce FinOps tags in pull requests" width="42%" />
7. Continue with the setup steps [here](../../?tab=readme-ov-file#3-test-the-integration).
## Running with GitLab
👉👉 We recommend using the [**free Infracost GitLab App**](https://www.infracost.io/docs/integrations/gitlab_app/) instead as it has many benefits.
👉👉 We recommend using the [**free Infracost GitLab App**](https://www.infracost.io/docs/integrations/gitlab_app/) as it's much simpler to setup and faster to run
1. Update your setup to use the [infracost-atlantis](https://hub.docker.com/r/infracost/infracost-atlantis) Docker image
2. If you haven't done so already, [download Infracost](https://www.infracost.io/docs/#quick-start) and run `infracost auth login` to get a free API key.
Expand Down Expand Up @@ -143,14 +136,7 @@ This Atlantis repo.yaml file shows how Infracost can be used with Atlantis. Even
```

6. Restart the Atlantis application with the new environment vars and config.
7. Send a merge request in GitLab to change something in the Terraform code, the Infracost merge request comment should be added and show details for every changed project.

<img src="/.github/assets/gitlab-pr-comment.png" width=640 alt="Example screenshot" />
8. In [Infracost Cloud](https://dashboard.infracost.io), go to Org Settings and enable the dashboard, then trigger your CI/CD pipeline again. This causes the CLI to send its JSON output to your dashboard; the JSON does not contain any cloud credentials or secrets, see the [FAQ](https://infracost.io/docs/faq/) for more information.

This is our SaaS product that builds on top of Infracost open source. It enables team leads, managers and FinOps practitioners to setup [tagging policies](https://www.infracost.io/docs/infracost_cloud/tagging_policies/), [guardrails](https://www.infracost.io/docs/infracost_cloud/guardrails/) and [best practices](https://www.infracost.io/docs/infracost_cloud/cost_policies/) to help guide the team. For example, you can check for required tag keys/values, or suggest switching AWS GP2 volumes to GP3 as they are more performant and cheaper.

<img src="/.github/assets/infracost-cloud-dashboard.png" alt="Infracost Cloud gives team leads, managers and FinOps practitioners visibility across all cost estimates in CI/CD" width="58%" /><img src="/.github/assets/pull-request-tags.png" alt="Communicate and enforce FinOps tags in pull requests" width="42%" />
7. Continue with the setup steps [here](../../?tab=readme-ov-file#3-test-the-integration).

## Running with Azure Repos

Expand Down Expand Up @@ -203,14 +189,7 @@ This Atlantis repo.yaml file shows how Infracost can be used with Atlantis. Even
```

6. Restart the Atlantis application with the new environment vars and config.
7. Send a pull request in Azure Repos to change something in the Terraform code, the Infracost merge request comment should be added and show details for every changed project.

<img src="/.github/assets/azure-pr-comment.png" width=640 alt="Example screenshot" />
8. In [Infracost Cloud](https://dashboard.infracost.io), go to Org Settings and enable the dashboard, then trigger your CI/CD pipeline again. This causes the CLI to send its JSON output to your dashboard; the JSON does not contain any cloud credentials or secrets, see the [FAQ](https://infracost.io/docs/faq/) for more information.

This is our SaaS product that builds on top of Infracost open source. It enables team leads, managers and FinOps practitioners to setup [tagging policies](https://www.infracost.io/docs/infracost_cloud/tagging_policies/), [guardrails](https://www.infracost.io/docs/infracost_cloud/guardrails/) and [best practices](https://www.infracost.io/docs/infracost_cloud/cost_policies/) to help guide the team. For example, you can check for required tag keys/values, or suggest switching AWS GP2 volumes to GP3 as they are more performant and cheaper.

<img src="/.github/assets/infracost-cloud-dashboard.png" alt="Infracost Cloud gives team leads, managers and FinOps practitioners visibility across all cost estimates in CI/CD" width="58%" /><img src="/.github/assets/pull-request-tags.png" alt="Communicate and enforce FinOps tags in pull requests" width="42%" />
7. Continue with the setup steps [here](../../?tab=readme-ov-file#3-test-the-integration).

## Running with Bitbucket

Expand Down Expand Up @@ -283,11 +262,4 @@ This Atlantis repo.yaml file shows how Infracost can be used with Atlantis. Even
```
6. Restart the Atlantis application with the new environment vars and config.
7. Send a pull request in Bitbucket to change something in the Terraform code, the Infracost pull request comment should be added and show details for every changed project.
<img src="/.github/assets/bitbucket-pr-comment.png" width=640 alt="Example screenshot" />
8. In [Infracost Cloud](https://dashboard.infracost.io), go to Org Settings and enable the dashboard, then trigger your CI/CD pipeline again. This causes the CLI to send its JSON output to your dashboard; the JSON does not contain any cloud credentials or secrets, see the [FAQ](https://infracost.io/docs/faq/) for more information.
This is our SaaS product that builds on top of Infracost open source. It enables team leads, managers and FinOps practitioners to setup [tagging policies](https://www.infracost.io/docs/infracost_cloud/tagging_policies/), [guardrails](https://www.infracost.io/docs/infracost_cloud/guardrails/) and [best practices](https://www.infracost.io/docs/infracost_cloud/cost_policies/) to help guide the team. For example, you can check for required tag keys/values, or suggest switching AWS GP2 volumes to GP3 as they are more performant and cheaper.
<img src="/.github/assets/infracost-cloud-dashboard.png" alt="Infracost Cloud gives team leads, managers and FinOps practitioners visibility across all cost estimates in CI/CD" width="58%" /><img src="/.github/assets/pull-request-tags.png" alt="Communicate and enforce FinOps tags in pull requests" width="42%" />
7. Continue with the setup steps [here](../../?tab=readme-ov-file#3-test-the-integration).
Binary file modified examples/combined-infracost-comment/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 44af881

Please sign in to comment.