DeployKit
intermediateIntegrating DeployKit with Your CI/CD Pipeline
Add infrastructure cost estimation to your pull requests. See the cost impact of infrastructure changes before they're merged.
check_circlePrerequisites
- check_circleGitHub, GitLab, or Bitbucket repository
- check_circleTerraform or CloudFormation IaC
- check_circleCI/CD pipeline (GitHub Actions, GitLab CI, etc.)
menu_bookIn This Guide
1.Introduction
DeployKit analyzes your infrastructure-as-code changes and estimates the cost impact before deployment. It posts a comment on your pull request showing:
- Monthly cost difference (before vs after) - Breakdown by resource type - Warnings for expensive changes - Suggestions for cost optimization
This helps teams make informed decisions about infrastructure changes and prevents cost surprises.
2.Step 1: Generate API Token
First, create a DeployKit API token:
1. Go to app.morphlix.com/deploykit 2. Navigate to Settings > API Tokens 3. Create a new token with "Cost Estimation" scope 4. Copy the token and save it securely
Add this token as a secret in your repository (e.g., `DEPLOYKIT_API_TOKEN`).
3.Step 2: GitHub Actions Integration
Add the DeployKit action to your Terraform workflow:
# .github/workflows/terraform.yml
name: Terraform Plan with Cost Estimation
on:
pull_request:
paths:
- 'terraform/**'
- '.github/workflows/terraform.yml'
jobs:
plan:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.6.0
- name: Terraform Init
run: terraform init
working-directory: terraform
- name: Terraform Plan
run: terraform plan -out=tfplan
working-directory: terraform
- name: Convert Plan to JSON
run: terraform show -json tfplan > tfplan.json
working-directory: terraform
- name: DeployKit Cost Estimation
uses: morphlix/deploykit-action@v2
with:
api_token: ${{ secrets.DEPLOYKIT_API_TOKEN }}
plan_file: terraform/tfplan.json
github_token: ${{ secrets.GITHUB_TOKEN }}
# Optional: Set thresholds for warnings
warn_threshold: 100 # Warn if monthly increase > $100
fail_threshold: 1000 # Fail if monthly increase > $10004.Step 3: GitLab CI Integration
For GitLab CI, add a cost estimation job:
# .gitlab-ci.yml
stages:
- validate
- plan
- cost
- apply
terraform-plan:
stage: plan
image: hashicorp/terraform:1.6
script:
- terraform init
- terraform plan -out=tfplan
- terraform show -json tfplan > tfplan.json
artifacts:
paths:
- tfplan.json
expire_in: 1 day
only:
- merge_requests
cost-estimation:
stage: cost
image: morphlix/deploykit:latest
script:
- deploykit estimate \
--plan-file tfplan.json \
--format gitlab-mr \
--api-token $DEPLOYKIT_API_TOKEN
dependencies:
- terraform-plan
only:
- merge_requests5.Example PR Comment
DeployKit posts a formatted comment on your PR showing the cost impact:
---
## 💰 Infrastructure Cost Estimate
| | Monthly Cost | |---|---:| | **Current** | $1,245.00 | | **Proposed** | $1,892.00 | | **Difference** | **+$647.00 (+52%)** |
### Changes by Resource
| Resource | Type | Change | Monthly Impact | |---|---|---|---:| | aws_instance.api | t3.medium → t3.xlarge | Resize | +$120.00 | | aws_rds_instance.main | New | Create | +$450.00 | | aws_elasticache_cluster.redis | New | Create | +$77.00 |
### ⚠️ Warnings
- RDS instance `db.r5.large` may be oversized for expected load. Consider `db.t3.large` for $320/mo savings.
---
This helps reviewers understand the cost implications before approving.
6.Customizing Thresholds and Rules
Create a `.deploykit.yml` config file in your repo:
# .deploykit.yml
version: 1
# Cost thresholds
thresholds:
warn: 100 # Comment warning if increase > $100/mo
fail: 1000 # Block PR if increase > $1000/mo
# Approval requirements
approvals:
high_cost_changes:
threshold: 500
required_reviewers:
- cloud-team
- finance
# Custom pricing (for resources not in public pricing)
custom_pricing:
aws_instance:
m5.metal: 4.608 # $/hour
# Excluded resources (don't count in estimates)
exclude:
- aws_cloudwatch_log_group # Costs vary too much
- data.* # Data sources
# Notifications
notifications:
slack:
webhook: ${{ SLACK_WEBHOOK }}
on: [high_cost_change, threshold_exceeded]Need Help?
Our team is here to help you get set up.
Get expert guidance on implementing DeployKit for your infrastructure.
Contact Supportarrow_forward