Terraform module that uses the AWS Pricing API to query EC2 instance type attributes
module "instance" {
source = "bendrucker/ec2-pricing/aws"
instance_type = "m5.large"
}
The module exposes outputs that describe key attributes of the specified instance type. These values are helpful for creating monitoring or resource quotas that are defined relative to the instance's capacity.
For example, you might pass these along to a kubernetes_resource_quota
in order to assign a percentage of cluster capacity to a namespace:
locals {
# allow developers to use 80% of worker resources
# reserve the remaining 20% for system components
developer_quota = 0.8
}
resource "kubernetes_resource_quota" "developers" {
metadata {
name = "developers-quota"
namespace = "developers"
}
spec {
hard = {
cpu = var.worker_count * module.instance.cpus * local.developer_quota
memory = "${var.worker_count * module.instance.memory * local.developer_quota} GiB"
}
}
}
Name | Version |
---|---|
aws | ~> 2 |
Name | Description | Type | Default | Required |
---|---|---|---|---|
instance_type | EC2 instance type for which attributes will be fetched | string |
n/a | yes |
Name | Description |
---|---|
cpus | Number of CPU cores available on the instance |
memory | Memory available on the instance, in gibibytes (GiB) |
This module is tested via Terratest.
make test
MIT © Ben Drucker