Skip to content

Commit 72a438f

Browse files
Merge pull request #5 from terraform-aws-modules/feature/add_optional_dynamic_ami_search
added the ability to optionally specify workers_ami_id
2 parents fbe64df + 46e5bf6 commit 72a438f

File tree

7 files changed

+39
-26
lines changed

7 files changed

+39
-26
lines changed

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,22 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this
66
project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## [[v0.2.0](https://github.com/terraform-aws-modules/terraform-aws-eks/compare/v0.1.1...v0.2.0)] - 2018-06-08]
9+
10+
### Changed
11+
12+
- `worker_ami_id` is now made optional. If not specified, the module will source the latest AWS supported EKS AMI instead.
13+
14+
## [[v0.1.1](https://github.com/terraform-aws-modules/terraform-aws-eks/compare/v0.1.0...v0.1.1)] - 2018-06-07]
15+
16+
### Changed
17+
18+
- pre-commit hooks fixed and working.
19+
- made progress on CI, advancing the build to the final `kitchen test` stage before failing.
20+
821
## [v0.1.0] - 2018-06-07
922

1023
### Added
1124

1225
- Everything! Initial release of the module.
13-
- Kudos to @tanmng for finding and fixing bug #1.
26+
- added a local variable to do a lookup against for a dynamic value in userdata which was previously static. Kudos to @tanmng for finding and fixing bug #1!

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-a
8989
| Name | Description | Type | Default | Required |
9090
|------|-------------|:----:|:-----:|:-----:|
9191
| cluster_ingress_cidrs | The CIDRs from which we can execute kubectl commands. | list | - | yes |
92-
| cluster_name | Name of the EKS cluster. | string | - | yes |
92+
| cluster_name | Name of the EKS cluster which is also used as a prefix in names of related resources. | string | - | yes |
9393
| cluster_version | Kubernetes version to use for the cluster. | string | `1.10` | no |
9494
| subnets | A list of subnets to associate with the cluster's underlying instances. | list | - | yes |
95-
| tags | A map of tags to add to all resources | string | `<map>` | no |
95+
| tags | A map of tags to add to all resources. | string | `<map>` | no |
9696
| vpc_id | VPC id where the cluster and other resources will be deployed. | string | - | yes |
97-
| workers_ami_id | AMI ID for the eks workers. | string | - | yes |
98-
| workers_asg_desired_capacity | description | string | `1` | no |
99-
| workers_asg_max_size | description | string | `3` | no |
100-
| workers_asg_min_size | description | string | `1` | no |
97+
| workers_ami_id | AMI ID for the eks workers. If none is provided, Terraform will search for the latest version of their EKS optimized worker AMI. | string | `` | no |
98+
| workers_asg_desired_capacity | Desired worker capacity in the autoscaling group. | string | `1` | no |
99+
| workers_asg_max_size | Maximum worker capacity in the autoscaling group. | string | `3` | no |
100+
| workers_asg_min_size | Minimum worker capacity in the autoscaling group. | string | `1` | no |
101101
| workers_instance_type | Size of the workers instances. | string | `m4.large` | no |
102102

103103
## Outputs

data.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
data "aws_region" "current" {}
22

3+
data "aws_ami" "eks_worker" {
4+
filter {
5+
name = "name"
6+
values = ["eks-worker-*"]
7+
}
8+
9+
most_recent = true
10+
owners = ["602401143452"] # Amazon
11+
}
12+
313
data "aws_iam_policy_document" "workers_assume_role_policy" {
414
statement {
515
sid = "EKSWorkerAssumeRole"

examples/eks_test_fixture/main.tf

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@ provider "random" {
1414
provider "http" {}
1515
provider "local" {}
1616

17-
data "aws_ami" "eks_worker" {
18-
filter {
19-
name = "name"
20-
values = ["eks-worker-*"]
21-
}
22-
23-
most_recent = true
24-
owners = ["602401143452"] # Amazon
25-
}
26-
2717
data "aws_availability_zones" "available" {}
2818

2919
data "http" "workstation_external_ip" {
@@ -75,7 +65,6 @@ module "eks" {
7565
subnets = "${module.vpc.public_subnets}"
7666
tags = "${local.tags}"
7767
vpc_id = "${module.vpc.vpc_id}"
78-
workers_ami_id = "${data.aws_ami.eks_worker.id}"
7968
cluster_ingress_cidrs = ["${local.workstation_external_cidr}"]
8069
workers_instance_type = "t2.small"
8170
}

variables.tf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ variable "cluster_ingress_cidrs" {
44
}
55

66
variable "cluster_name" {
7-
description = "Name of the EKS cluster."
7+
description = "Name of the EKS cluster which is also used as a prefix in names of related resources."
88
}
99

1010
variable "cluster_version" {
@@ -18,7 +18,7 @@ variable "subnets" {
1818
}
1919

2020
variable "tags" {
21-
description = "A map of tags to add to all resources"
21+
description = "A map of tags to add to all resources."
2222
default = {}
2323
}
2424

@@ -27,21 +27,22 @@ variable "vpc_id" {
2727
}
2828

2929
variable "workers_ami_id" {
30-
description = "AMI ID for the eks workers."
30+
description = "AMI ID for the eks workers. If none is provided, Terraform will search for the latest version of their EKS optimized worker AMI."
31+
default = ""
3132
}
3233

3334
variable "workers_asg_desired_capacity" {
34-
description = "description"
35+
description = "Desired worker capacity in the autoscaling group."
3536
default = "1"
3637
}
3738

3839
variable "workers_asg_max_size" {
39-
description = "description"
40+
description = "Maximum worker capacity in the autoscaling group."
4041
default = "3"
4142
}
4243

4344
variable "workers_asg_min_size" {
44-
description = "description"
45+
description = "Minimum worker capacity in the autoscaling group."
4546
default = "1"
4647
}
4748

version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.1.1
1+
v0.2.0

workers.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ resource "aws_launch_configuration" "workers" {
1919
associate_public_ip_address = true
2020
name_prefix = "${var.cluster_name}"
2121
iam_instance_profile = "${aws_iam_instance_profile.workers.name}"
22-
image_id = "${var.workers_ami_id}"
22+
image_id = "${var.workers_ami_id == "" ? data.aws_ami.eks_worker.id : var.workers_ami_id}"
2323
instance_type = "${var.workers_instance_type}"
2424
security_groups = ["${aws_security_group.workers.id}"]
2525
user_data_base64 = "${base64encode(local.workers_userdata)}"

0 commit comments

Comments
 (0)