Disable Infracost for Drift Detection runs
We use infracost by attaching the infracost to enable spacelift’s integration. As per the docs we also attach a auto-atatch a context with our api key as an env var with the infracost label.
We would like to be able to disable the infracost integration when a run is triggered via drift detection.
- Workaround
- Problem
Log in to comment and vote
Comments3
Blue Puzzle
May 8
•Merged request
•2 votes
Better control over infracost integration
Currently to enable infracost, two things are necessary:
add the
infracostlabel to a stackset the
INFRACOST_API_KEYenvironment variableIn order to disable infracost for specific situations (e.g. local preview run or drift detection run), one has to manipulate the
INFRACOST_API_KEYenvironment variable in order to prevent the call from happening.It would be good to have better control over this, and not have to manipulate the
INFRACOST_API_KEYenvironment variable (which I assume will still make the call to infracost, and Infracost will block it because of the bad API key).```
[[ "$TF_VAR_spacelift_run_trigger" = "spacelift/drift_detection" || "$TF_VAR_spacelift_local_preview" = "true" ]] && export INFRACOST_API_KEY=disabled && export INFRACOST_WARN_ON_FAILURE=true || true
```
It would be nice to have an
INFRACOST_ENABLEDenvironment value that is possible to configure on the fly, which would prevent the calls from actually made and allowing us better control over the infracost integration.