Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds EKS #4

Merged
merged 18 commits into from
Oct 12, 2021
2 changes: 1 addition & 1 deletion clusters/aks/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ output "console_url" {
# this variable is used for testing purposes and has no bearing on the demo
# see https://www.terraform.io/docs/language/values/outputs.html
output "workspace_url" {
value = "https://app.terraform.io/app/a-demo-organization/workspaces/multi-cloud-k8s-aks"
value = "https://app.terraform.io/app/a-demo-organization/workspaces/${var.tfe_workspaces_prefix}-aks"
}
2 changes: 1 addition & 1 deletion clusters/doks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ resource "digitalocean_kubernetes_cluster" "cluster" {

node_pool {
name = "worker-pool"
size = "s-2vcpu-2gb"
size = "s-4vcpu-8gb"
node_count = 3
}

Expand Down
2 changes: 1 addition & 1 deletion clusters/doks/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ output "console_url" {
# this variable is used for testing purposes and has no bearing on the demo
# see https://www.terraform.io/docs/language/values/outputs.html
output "workspace_url" {
value = "https://app.terraform.io/app/a-demo-organization/workspaces/multi-cloud-k8s-doks"
value = "https://app.terraform.io/app/a-demo-organization/workspaces/${var.tfe_workspaces_prefix}-doks"
}
2 changes: 1 addition & 1 deletion clusters/doks/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ variable "tfe_workspaces_prefix" {

variable "do_region" {
type = string
description = "he slug identifier for the region where the resources will be created."
description = "The slug identifier for the region where the resources will be created."
default = "sfo3" # San Francisco, CA
}

Expand Down
99 changes: 99 additions & 0 deletions clusters/eks/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions clusters/eks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Workspace `EKS`

> This directory contains [AWS](https://registry.terraform.io/providers/hashicorp/aws) Resources.
## Requirements

* Terraform CLI `1.0.8` or newer
* an AWS [account](https://aws.amazon.com)

## Downstream Consumption

The Kubernetes Cluster can be consumed via the [aws_eks_cluster](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster) data source:

```hcl
# see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster
data "aws_eks_cluster" "cluster" {
name = "multi-cloud-k8s"
}
```

The above example uses the default values for the `name` property. This may need to be changed for your situation.
13 changes: 13 additions & 0 deletions clusters/eks/data-sources.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc
data "aws_vpc" "default" {
default = true
}

# see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet
data "aws_subnet" "default" {
for_each = toset(var.subnet_az)

availability_zone = "${var.aws_region}${each.key}"
default_for_az = true
vpc_id = data.aws_vpc.default.id
}
28 changes: 28 additions & 0 deletions clusters/eks/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# see https://registry.terraform.io/modules/terraform-aws-modules/eks/aws/latest
module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "17.20.0"

cluster_name = var.tfe_workspaces_prefix
cluster_version = "1.20"
manage_aws_auth = false

subnets = [
data.aws_subnet.default["a"].id,
data.aws_subnet.default["c"].id,
]

worker_groups = [{
name = "worker-group-1"
instance_type = "t2.large"
asg_desired_capacity = 1
}
]

workers_group_defaults = {
root_volume_type = "gp2"
}

write_kubeconfig = false
vpc_id = data.aws_vpc.default.id
}
29 changes: 29 additions & 0 deletions clusters/eks/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## see https://www.terraform.io/docs/language/values/outputs.html
output "cluster_id" {
description = "EKS Cluster ID."
value = module.eks.cluster_arn
}

# see https://www.terraform.io/docs/language/values/outputs.html
output "cluster_name" {
description = "EKS Cluster Name."
value = var.tfe_workspaces_prefix
}

# see https://www.terraform.io/docs/language/values/outputs.html
output "cluster_region" {
description = "EKS Cluster Region."
value = var.aws_region
}

# see https://www.terraform.io/docs/language/values/outputs.html
output "console_url" {
description = "AWS Console URL."
value = "https://${var.aws_region}.console.aws.amazon.com/ecs/home?region=${var.aws_region}#/clusters"
}

# this variable is used for testing purposes and has no bearing on the demo
# see https://www.terraform.io/docs/language/values/outputs.html
output "workspace_url" {
value = "https://app.terraform.io/app/a-demo-organization/workspaces/${var.tfe_workspaces_prefix}-eks"
}
4 changes: 4 additions & 0 deletions clusters/eks/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# see https://registry.terraform.io/providers/digitalocean/digitalocean/latest
provider "aws" {
region = var.aws_region
}
23 changes: 23 additions & 0 deletions clusters/eks/terraform.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
terraform {
# see https://www.terraform.io/docs/language/settings/backends/remote.html
backend "remote" {
hostname = "app.terraform.io"
organization = "a-demo-organization"

workspaces {
name = "multi-cloud-k8s-eks"
}
}

# see https://www.terraform.io/docs/language/settings/index.html#specifying-provider-requirements
required_providers {
# see https://registry.terraform.io/providers/hashicorp/aws/3.62.0/docs
aws = {
source = "hashicorp/aws"
version = "3.62.0"
}
}

# see https://www.terraform.io/docs/language/settings/index.html#specifying-a-required-terraform-version
required_version = "1.0.8"
}
2 changes: 2 additions & 0 deletions clusters/eks/terraform.tfvars.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
aws_access_key = "..."
aws_secret_key = "..."
21 changes: 21 additions & 0 deletions clusters/eks/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
variable "tfe_workspaces_prefix" {
type = string
description = "Prefix for TFE Workspaces."
default = "multi-cloud-k8s"
}

variable "aws_region" {
type = string
description = "This is the AWS region."
default = "us-west-1" # N. California, US
}

variable "subnet_az" {
type = list(string)
description = "List of strings of Availability Zone suffixes."

default = [
"a",
"c",
]
}
46 changes: 14 additions & 32 deletions clusters/gke/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading