|
| 1 | +# Instance Type |
| 2 | + |
| 3 | +This is a module that can be used to look up a list of EC2 instance types and determine which of them is available in |
| 4 | +all Availability Zones (AZs) in the current AWS Region. This is useful because certain instance types, such as |
| 5 | +`t2.micro` are not available in some of the newer AZs, while `t3.micro` is not available in some of the older AZs, and |
| 6 | +if you have code that needs to run on a "small" instance across all AZs in many different regions, you can use this |
| 7 | +module to automatically figure out which instance type you should use. |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +## Example code |
| 14 | + |
| 15 | +See the [instance-type example](/examples/instance-type) for working sample code. |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | +## Usage |
| 21 | + |
| 22 | +Use the module in your Terraform code, replacing `<VERSION>` with the latest version from the [releases |
| 23 | +page](https://github.com/gruntwork-io/package-terraform-utilities/releases): |
| 24 | + |
| 25 | +```hcl |
| 26 | +module "path" { |
| 27 | + source = "git::[email protected]:gruntwork-io/package-terraform-utilities.git//modules/instance-type?ref=<VERSION>" |
| 28 | + |
| 29 | + instance_types = ["t2.micro", "t3.micro"] |
| 30 | +} |
| 31 | +``` |
| 32 | + |
| 33 | +The arguments to pass are: |
| 34 | + |
| 35 | +* `instance_types`: A list of instance types to look up in the current AWS region. We recommend putting them in order |
| 36 | + of preference, as the recommended_instance_type output variable will contain the first instance type from this list |
| 37 | + that is available in all AZs. |
| 38 | + |
| 39 | +When you run `apply`, the `recommended_instance_type` output variable will contain the recommended instance type to |
| 40 | +use. This will be the first instance type from your `instance_types` input that is available in all AZs in the current |
| 41 | +region. If no instance type is available in all AZs, you'll get an error. |
| 42 | + |
| 43 | +For example, as of July, 2020, if you run `apply` on the code above in `eu-west-1`, the `recommended_instance_type` |
| 44 | +will be `t2.micro`, as that's available in all AZs in `eu-west-1`. However, if you run the same code in |
| 45 | +`ap-northeast-2`, the `recommended_instance_type` will be `t3.micro`, as `t2.micro` is only available in 2 of the 4 AZs. |
0 commit comments