infracost-price-lookup
Look up cloud resource pricing by generating sample Terraform and running Infracost against it. Use this skill when the user asks "how much does X cost?" or wants to compare pricing between resource configurations, instance types, regions, or cloud providers. This does not require the user to have any existing infrastructure code.
Skill body
Price Lookup
Look up cloud resource pricing without needing existing infrastructure code. Supports any resource type that Terraform and Infracost support across AWS, GCP, and Azure.
Setup
Important: Verify the Infracost CLI is installed and the user is authenticated before running any price lookups.
-
Check the CLI is on the path:
infracost --versionIf this fails, inform the user that they need to install the Infracost CLI by following the instructions at https://www.infracost.io/docs/features/get_started/.
-
Check the user is logged in:
infracost auth whoamiIf this reports that the user is not authenticated, ask them to run
infracost auth loginin a separate terminal window and let you know once it completes. Do not attempt to run the login command yourself — it is interactive.
Workflow
1. Run Infracost
Pipe the Terraform configuration directly into infracost price. This command reads Terraform from stdin, analyzes it, and prints a human-readable cost summary to stdout, followed by suggested inspect commands for drilling deeper. Temporary files are created and cleaned up automatically.
Pass the global --json flag if you need the raw JSON output instead — for example, when piping into another tool. The same --json flag also switches log output to JSON and works on scan and inspect.
infracost price << 'EOF'
provider "aws" {
region = "us-east-1"
}
resource "aws_instance" "example" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "m5.xlarge"
root_block_device {
volume_size = 100
volume_type = "gp3"
}
}
EOF
Rules for writing the Terraform:
- Minimal config only — no backends, no variable files, no outputs, no data sources. Just a provider block and the resource(s).
- Include attributes that affect pricing — instance type, storage size/type, engine version, throughput, IOPS, etc. These are the knobs that change the price, so they must be present.
- Use the user’s requested configuration — if they ask for “m5.xlarge with 100GB gp3”, write exactly that. If they ask generically (“how much does an RDS instance cost?”), pick reasonable defaults and clearly state what you chose.
- Set the region — use the region the user asks for, or default to
us-east-1and mention it. - Multiple resources are fine — if the user asks about several resource types, put them all in the same file.
- Use realistic names — name resources descriptively (e.g.,
aws_instance.web_servernotaws_instance.example) so the output is easier to read.
Currency: If the user requests pricing in a non-USD currency, set the INFRACOST_CLI_CURRENCY environment variable when running the command. For example:
INFRACOST_CLI_CURRENCY=EUR infracost price << 'EOF'
...
EOF
Use standard ISO 4217 currency codes (e.g., EUR, GBP, JPY, CAD, AUD). If the user doesn’t specify a currency, default to USD.
2. Inspect the results
price already prints a summary, but you can drill in further with inspect. Results are cached, so you don’t need to redirect output or pass --file.
# Summary overview (same shape as the default price output)
infracost inspect --summary
# Detailed cost breakdown, hiding free resources
infracost inspect --costs-only
# Top expensive resources
infracost inspect --top 5
# Every resource sorted by cost (no row limit)
infracost inspect --group-by resource
Presenting Results
Present pricing in a clear, structured way:
- Lead with the monthly cost — this is what the user cares about most
- Break down cost components — show what makes up the total (compute, storage, data transfer, etc.)
- Call out usage-based costs — note that some costs depend on actual usage (requests, data transferred, etc.) and the estimates use typical defaults. Be explicit about what assumptions were made.
- Compare when asked — if the user wants to compare configurations (e.g., m5.xlarge vs m5.2xlarge), create both resources and present a side-by-side table
- Include FinOps recommendations — if Infracost flags any policies (e.g., “use GP3 instead of GP2”, “consider Graviton”), highlight those with potential savings
- Mention the region — pricing varies by region, so always state which region was used
Example presentation
AWS RDS MySQL — db.r5.xlarge, 100GB gp3 Region: us-east-1
Component Monthly Cost Instance (on-demand) $365.00 Storage (100GB gp3) $11.50 Total $376.50 Usage-based costs (estimated):
- I/O requests: ~$X/mo based on typical usage
Savings opportunity: Consider Graviton (db.r6g.xlarge) for ~20% savings (~$73/mo).
Important Guidelines
- Do not commit any generated Terraform files — they are throwaway.
- Do not modify the CLI source code — this skill is for using the CLI.
- If
infracost scanprompts for login, ask the user to runinfracost auth loginin a separate terminal window first. - If the user asks about a resource type you’re unsure of the Terraform resource name for, look it up rather than guessing — an incorrect resource type will produce no pricing data.