Skip to content

Commit 268b3a1

Browse files
Merge pull request #9 from terraform-aws-modules/feature/ebs_optimized_whenever_possible
ebs optimization of instances now possible
2 parents c2db74b + a286a54 commit 268b3a1

File tree

10 files changed

+139
-19
lines changed

10 files changed

+139
-19
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ script:
3535
- cd -
3636
- terraform -v
3737
# - bundle exec kitchen test --destroy always
38-
deploy:
39-
provider: script
40-
script: ci/deploy.sh
41-
on:
42-
branch: master
38+
# deploy:
39+
# provider: script
40+
# script: ci/deploy.sh
41+
# on:
42+
# branch: master
4343
notifications:
4444
email:
4545
recipients:

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
1313
- `workers_ami_id` is now made optional. If not specified, the module will source the latest AWS supported EKS AMI instead.
1414
- added ability to specify extra userdata code to execute after the second to configure and start kube services.
1515
- When `configure_kubectl_session` is set to true the current shell will be configured to talk to the kubernetes cluster using config files output from the module.
16+
- EBS optimization used whenever possible for the given instance type.
1617

1718
## [[v0.1.1](https://github.com/terraform-aws-modules/terraform-aws-eks/compare/v0.1.0...v0.1.1)] - 2018-06-07]
1819

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-a
9999
| cluster_version | Kubernetes version to use for the cluster. | string | `1.10` | no |
100100
| config_output_path | Determines where config files are placed if using configure_kubectl_session and you want config files to land outside the current working directory. | string | `./` | no |
101101
| configure_kubectl_session | Configure the current session's kubectl to use the instantiated cluster. | string | `false` | no |
102+
| ebs_optimized_workers | If left at default of true, will use ebs optimization if available on the given instance type. | string | `true` | no |
102103
| subnets | A list of subnets to associate with the cluster's underlying instances. | list | - | yes |
103104
| tags | A map of tags to add to all resources. | string | `<map>` | no |
104105
| vpc_id | VPC id where the cluster and other resources will be deployed. | string | - | yes |

data.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,8 @@ data template_file config_map_aws_auth {
7171
role_arn = "${aws_iam_role.workers.arn}"
7272
}
7373
}
74+
75+
module "ebs_optimized" {
76+
source = "modules/util/ebs_optimized/"
77+
instance_type = "${var.workers_instance_type}"
78+
}

examples/eks_test_fixture/README.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,6 @@ This set of templates serves a few purposes. It:
66
2. serves as the test infrastructure for CI on the project.
77
3. provides a simple way to play with the Kubernetes cluster you create.
88

9-
## testing with kubectl
10-
11-
Once converged, `kubeconfig` and `config-map-aws-auth.yml` should be in this directory.
12-
Ensure you have a recent version of `kubectl` on your PATH ([instructions here](https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl))
13-
14-
```bash
15-
curl -o heptio-authenticator-aws https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-06-05/bin/darwin/amd64/heptio-authenticator-aws
16-
mv heptio-authenticator-aws ~/go/bin/
17-
kubectl apply -f examples/eks_test_fixture/config-map-aws-auth.yaml --kubeconfig examples/eks_test_fixture/kubeconfig
18-
# configmap "aws-auth" created
19-
kubectl get nodes --watch --kubeconfig examples/eks_test_fixture/kubeconfig
20-
```
21-
229
## IAM Permissions
2310

2411
The following IAM policy is the minimum needed to execute the module from the test suite.

modules/util/ebs_optimized/main.tf

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/**
2+
# terraform_util_ebs_optimized
3+
4+
A terraform module to return true or false based on if an instance type supports the EBS optmized flag.
5+
*/
6+
7+
locals {
8+
ebs_optimized_types = {
9+
"c4.large" = true
10+
"c4.xlarge" = true
11+
"c4.2xlarge" = true
12+
"c4.4xlarge" = true
13+
"c4.8xlarge" = true
14+
"c5.large" = true
15+
"c5.xlarge" = true
16+
"c5.2xlarge" = true
17+
"c5.4xlarge" = true
18+
"c5.9xlarge" = true
19+
"c5.18xlarge" = true
20+
"c5d.large" = true
21+
"c5d.xlarge" = true
22+
"c5d.2xlarge" = true
23+
"c5d.4xlarge" = true
24+
"c5d.9xlarge" = true
25+
"c5d.18xlarge" = true
26+
"d2.xlarge" = true
27+
"d2.2xlarge" = true
28+
"d2.4xlarge" = true
29+
"d2.8xlarge" = true
30+
"f1.2xlarge" = true
31+
"f1.16xlarge" = true
32+
"g3.4xlarge" = true
33+
"g3.8xlarge" = true
34+
"g3.16xlarge" = true
35+
"h1.2xlarge" = true
36+
"h1.4xlarge" = true
37+
"h1.8xlarge" = true
38+
"h1.16xlarge" = true
39+
"i3.large" = true
40+
"i3.xlarge" = true
41+
"i3.2xlarge" = true
42+
"i3.4xlarge" = true
43+
"i3.8xlarge" = true
44+
"i3.16xlarge" = true
45+
"i3.metal" = true
46+
"m4.large" = true
47+
"m4.xlarge" = true
48+
"m4.2xlarge" = true
49+
"m4.4xlarge" = true
50+
"m4.10xlarge" = true
51+
"m4.16xlarge" = true
52+
"m5.large" = true
53+
"m5.xlarge" = true
54+
"m5.2xlarge" = true
55+
"m5.4xlarge" = true
56+
"m5.12xlarge" = true
57+
"m5.24xlarge" = true
58+
"m5d.large" = true
59+
"m5d.xlarge" = true
60+
"m5d.2xlarge" = true
61+
"m5d.4xlarge" = true
62+
"m5d.12xlarge" = true
63+
"m5d.24xlarge" = true
64+
"p2.xlarge" = true
65+
"p2.8xlarge" = true
66+
"p2.16xlarge" = true
67+
"p3.2xlarge" = true
68+
"p3.8xlarge" = true
69+
"p3.16xlarge" = true
70+
"r4.large" = true
71+
"r4.xlarge" = true
72+
"r4.2xlarge" = true
73+
"r4.4xlarge" = true
74+
"r4.8xlarge" = true
75+
"r4.16xlarge" = true
76+
"x1.16xlarge" = true
77+
"x1.32xlarge" = true
78+
"x1e.xlarge" = true
79+
"x1e.2xlarge" = true
80+
"x1e.4xlarge" = true
81+
"x1e.8xlarge" = true
82+
"x1e.16xlarge" = true
83+
"x1e.32xlarge" = true
84+
"c5.large" = true
85+
"c5.xlarge" = true
86+
"c5.2xlarge" = true
87+
"c5d.large" = true
88+
"c5d.xlarge" = true
89+
"c5d.2xlarge" = true
90+
"m5.large" = true
91+
"m5.xlarge" = true
92+
"m5.2xlarge" = true
93+
"m5d.large" = true
94+
"m5d.xlarge" = true
95+
"m5d.2xlarge" = true
96+
"c1.xlarge" = true
97+
"c3.xlarge" = true
98+
"c3.2xlarge" = true
99+
"c3.4xlarge" = true
100+
"g2.2xlarge" = true
101+
"i2.xlarge" = true
102+
"i2.2xlarge" = true
103+
"i2.4xlarge" = true
104+
"m1.large" = true
105+
"m1.xlarge" = true
106+
"m2.2xlarge" = true
107+
"m2.4xlarge" = true
108+
"m3.xlarge" = true
109+
"m3.2xlarge" = true
110+
"r3.xlarge" = true
111+
"r3.2xlarge" = true
112+
"r3.4xlarge" = true
113+
}
114+
}

modules/util/ebs_optimized/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "answer" {
2+
description = "Returns true or false depending on if the instance type is able to be EBS optimized."
3+
value = "${lookup(local.ebs_optimized_types, var.instance_type, false)}"
4+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
variable "instance_type" {
2+
description = "Instance type to evaluate if EBS optimized is an option."
3+
}

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ variable "configure_kubectl_session" {
2727
default = false
2828
}
2929

30+
variable "ebs_optimized_workers" {
31+
description = "If left at default of true, will use ebs optimization if available on the given instance type."
32+
default = true
33+
}
34+
3035
variable "subnets" {
3136
description = "A list of subnets to associate with the cluster's underlying instances."
3237
type = "list"

workers.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ resource "aws_launch_configuration" "workers" {
2323
instance_type = "${var.workers_instance_type}"
2424
security_groups = ["${aws_security_group.workers.id}"]
2525
user_data_base64 = "${base64encode(data.template_file.userdata.rendered)}"
26-
ebs_optimized = false
26+
ebs_optimized = "${var.ebs_optimized_workers ? module.ebs_optimized.answer : false}"
2727

2828
lifecycle {
2929
create_before_destroy = true

0 commit comments

Comments
 (0)