Resource Types
The Resource Types view shows all Terraform resource types in your infrastructure, with counts and quick access to instances of each type.
Overview
Resource types are the building blocks of Terraform configurations:
aws_instance- EC2 instancesaws_s3_bucket- S3 bucketsgoogle_compute_instance- GCE VMsazurerm_virtual_machine- Azure VMs
Stategraph catalogs every resource type across all your states.
Accessing Resource Types
Via UI
- Navigate to Inventory > Types in the sidebar
- Browse the list of all resource types
- See instance counts for each type
- Click a type to see all instances of that type
Via API
Get a summary of resource types (see instances docs for getting STATE_ID):
curl "http://localhost:8080/api/v1/states/$STATE_ID/resources/summary" \
-H "Authorization: Bearer $STATEGRAPH_API_KEY"
Response:
{
"aws_instance": { "instances": 20 },
"aws_security_group": { "instances": 15 },
"aws_subnet": { "instances": 6 },
"aws_iam_role": { "instances": 12 }
}
Type Analysis
Count All Types
SELECT type, count(*) as count
FROM resources
GROUP BY type
ORDER BY count DESC
Types by Provider
-- AWS resources
SELECT type, count(*) as count
FROM resources
WHERE provider = 'aws'
GROUP BY type
ORDER BY count DESC
-- Google Cloud resources
SELECT type, count(*) as count
FROM resources
WHERE provider = 'google'
GROUP BY type
ORDER BY count DESC
-- Azure resources
SELECT type, count(*) as count
FROM resources
WHERE provider = 'azurerm'
GROUP BY type
ORDER BY count DESC
Unique Types per State
SELECT state_id, count(DISTINCT type) as types
FROM resources
GROUP BY state_id
ORDER BY types DESC
Common Resource Types
AWS
| Type | Description |
|---|---|
aws_instance |
EC2 instances |
aws_security_group |
Security groups |
aws_iam_role |
IAM roles |
aws_s3_bucket |
S3 buckets |
aws_subnet |
VPC subnets |
aws_vpc |
Virtual private clouds |
aws_lambda_function |
Lambda functions |
aws_db_instance |
RDS instances |
Google Cloud
| Type | Description |
|---|---|
google_compute_instance |
Compute Engine VMs |
google_storage_bucket |
Cloud Storage buckets |
google_container_cluster |
GKE clusters |
google_sql_database_instance |
Cloud SQL instances |
Azure
| Type | Description |
|---|---|
azurerm_virtual_machine |
Virtual machines |
azurerm_storage_account |
Storage accounts |
azurerm_kubernetes_cluster |
AKS clusters |
azurerm_sql_server |
SQL servers |
Type-Specific Queries
EC2 Instances by Type
SELECT attributes->>'instance_type' as instance_type, count(*) as count
FROM instances
WHERE type = 'aws_instance'
GROUP BY attributes->>'instance_type'
ORDER BY count DESC
S3 Buckets by Region
SELECT attributes->>'region' as region, count(*) as count
FROM instances
WHERE type = 'aws_s3_bucket'
GROUP BY attributes->>'region'
ORDER BY count DESC
RDS Instances by Engine
SELECT attributes->>'engine' as engine, count(*) as count
FROM instances
WHERE type = 'aws_db_instance'
GROUP BY attributes->>'engine'
ORDER BY count DESC
Lambda Functions by Runtime
SELECT attributes->>'runtime' as runtime, count(*) as count
FROM instances
WHERE type = 'aws_lambda_function'
GROUP BY attributes->>'runtime'
ORDER BY count DESC
Resource Categories
Group resource types by category:
Compute Resources
SELECT type, count(*) as count
FROM resources
WHERE type IN (
'aws_instance',
'aws_lambda_function',
'aws_ecs_service',
'google_compute_instance',
'azurerm_virtual_machine'
)
GROUP BY type
ORDER BY count DESC
Storage Resources
SELECT type, count(*) as count
FROM resources
WHERE type IN (
'aws_s3_bucket',
'aws_ebs_volume',
'google_storage_bucket',
'azurerm_storage_account'
)
GROUP BY type
ORDER BY count DESC
Network Resources
SELECT type, count(*) as count
FROM resources
WHERE type IN (
'aws_vpc',
'aws_subnet',
'aws_security_group',
'aws_network_interface',
'google_compute_network',
'google_compute_subnetwork',
'azurerm_virtual_network',
'azurerm_subnet'
)
GROUP BY type
ORDER BY count DESC
Security Resources
SELECT type, count(*) as count
FROM resources
WHERE type IN (
'aws_iam_role',
'aws_iam_policy',
'aws_iam_user',
'aws_kms_key',
'aws_secretsmanager_secret'
)
GROUP BY type
ORDER BY count DESC
Type Distribution Analysis
Types per Workspace
SELECT state_id, type, count(*) as count
FROM resources
GROUP BY state_id, type
ORDER BY state_id, count DESC
New Resource Types
Find types that only appear in certain states (potentially new additions):
SELECT type, count(DISTINCT state_id) as states_count
FROM resources
GROUP BY type
HAVING count(DISTINCT state_id) = 1
ORDER BY type
Most Common Types
SELECT type, count(*) as count
FROM resources
GROUP BY type
ORDER BY count DESC
LIMIT 10
Monitoring Type Growth
Track how resource types grow over time by comparing counts periodically:
-- Current counts
SELECT type, count(*) as count
FROM resources
GROUP BY type
ORDER BY count DESC
Save these queries to a Dashboard for regular monitoring.
Best Practices
- Monitor growth - Track type counts over time
- Review distribution - Ensure resources are distributed appropriately
- Check for drift - Compare expected vs actual type counts
- Identify outliers - Look for unexpected resource types
Next Steps
- Instances - Browse all instances
- Modules - View by module
- Query - Advanced queries
- Dashboards - Save type queries