Skip to content

Commit

Permalink
Initial version of EKS terraform config
Browse files Browse the repository at this point in the history
Add module for EKS cluster, need to add VPC.
  • Loading branch information
aLekSer committed Aug 26, 2019
1 parent 61540c2 commit b9ac35a
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 0 deletions.
64 changes: 64 additions & 0 deletions build/modules/eks/eks.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Copyright 2019 Google LLC All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

provider "aws" {
version = ">= 2.11"
region = var.region
}


resource "aws_vpc" "example" {
cidr_block = "10.0.0.0/16"
enable_dns_hostnames = true
enable_dns_support = true
tags = "${
map(
"Name", "terraform-eks",
"kubernetes.io/cluster/example", "shared",
)
}"
}

resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
enable_dns_hostnames = true
enable_dns_support = true
tags = "${
map(
"Name", "terraform-eks",
"kubernetes.io/cluster/example", "shared",
)
}"
}

#
# main EKS terraform resource definition
#
resource "aws_eks_cluster" "main" {
name = "${var.cluster_name}"
worker_groups = [
{
name = "worker-group-1"
instance_type = "t2.micro"
asg_desired_capacity = 5
additional_security_group_ids = [aws_security_group.worker_group_mgmt_one.id]
},
{
name = "worker-group-2"
instance_type = "t2.micro"
additional_security_group_ids = [aws_security_group.worker_group_mgmt_two.id]
asg_desired_capacity = 5
},
]
}
33 changes: 33 additions & 0 deletions build/modules/eks/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2019 Google LLC All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

output "cluster_ca_certificate" {
value = "${base64decode(aws_eks_cluster.main.kube_config.0.cluster_ca_certificate)}"
}

output "client_certificate" {
value = "${aws_eks_cluster.main.kube_config.0.client_certificate}"
}

output "kube_config" {
value = "${aws_eks_cluster.main.kube_config_raw}"
}

output "host" {
value = "${aws_eks_cluster.main.kube_config.0.host}"
}

output "token" {
value = "${aws_eks_cluster.main.kube_config.0.password}"
}
21 changes: 21 additions & 0 deletions build/modules/eks/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2019 Google LLC All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

variable "cluster_name" {
default = "test-cluster"
}

variable "region" {
default = "us-west-2"
}

0 comments on commit b9ac35a

Please sign in to comment.