Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bendrucker/terraform-aws-ec2-pricing
Terraform module that uses the AWS Pricing API to query EC2 instance type attributes
https://github.com/bendrucker/terraform-aws-ec2-pricing
aws aws-pricing ec2 terraform terraform-module
Last synced: 22 days ago
JSON representation
Terraform module that uses the AWS Pricing API to query EC2 instance type attributes
- Host: GitHub
- URL: https://github.com/bendrucker/terraform-aws-ec2-pricing
- Owner: bendrucker
- License: mit
- Created: 2020-02-21T20:19:57.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-12T19:32:56.000Z (4 months ago)
- Last Synced: 2024-07-12T21:51:05.640Z (4 months ago)
- Topics: aws, aws-pricing, ec2, terraform, terraform-module
- Language: HCL
- Homepage:
- Size: 302 KB
- Stars: 5
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: license
Awesome Lists containing this project
README
# terraform-aws-ec2-pricing [![terraform workflow status](https://github.com/bendrucker/terraform-aws-ec2-pricing/workflows/terraform/badge.svg?branch=master)](https://github.com/bendrucker/terraform-aws-ec2-pricing/actions?query=workflow%3Aterraform)
> Terraform module that uses the [AWS Pricing API](https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/price-changes.html) to query EC2 instance type attributes
## Usage
```tf
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`](https://www.terraform.io/docs/providers/kubernetes/r/resource_quota.html) in order to assign a percentage of cluster capacity to a namespace:
```tf
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"
}
}
}
```## Providers
| Name | Version |
|------|---------|
| aws | ~> 2 |## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:-----:|
| instance\_type | EC2 instance type for which attributes will be fetched | `string` | n/a | yes |## Outputs
| Name | Description |
|------|-------------|
| cpus | Number of CPU cores available on the instance |
| memory | Memory available on the instance, in gibibytes (GiB) |## Testing
This module is tested via [Terratest](https://github.com/gruntwork-io/terratest).
```sh
make test
```## License
MIT © [Ben Drucker](http://bendrucker.me)