Skip to content

Commit

Permalink
Merge pull request #91 from hashicorp/tfc
Browse files Browse the repository at this point in the history
Update configuration for TFC workflow
  • Loading branch information
ritsok committed Jan 27, 2023
2 parents 622d793 + d880c47 commit 685bb97
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 111 deletions.
65 changes: 34 additions & 31 deletions .terraform.lock.hcl

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

38 changes: 0 additions & 38 deletions eks-cluster.tf

This file was deleted.

76 changes: 66 additions & 10 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
# Kubernetes provider
# https://learn.hashicorp.com/terraform/kubernetes/provision-eks-cluster#optional-configure-terraform-kubernetes-provider
# To learn how to schedule deployments and services using the provider, go here: https://learn.hashicorp.com/terraform/kubernetes/deploy-nginx-kubernetes
# The Kubernetes provider is included in this file so the EKS module can complete successfully. Otherwise, it throws an error when creating `kubernetes_config_map.aws_auth`.
# You should **not** schedule deployments and services in this workspace. This keeps workspaces modular (one for provision EKS, another for scheduling Kubernetes resources) as per best practices.
provider "kubernetes" {
host = module.eks.cluster_endpoint
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)
}

provider "aws" {
region = var.region
}
Expand All @@ -22,3 +12,69 @@ resource "random_string" "suffix" {
length = 8
special = false
}

module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "3.19.0"

name = "education-vpc"

cidr = "10.0.0.0/16"
azs = slice(data.aws_availability_zones.available.names, 0, 3)

private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
public_subnets = ["10.0.4.0/24", "10.0.5.0/24", "10.0.6.0/24"]

enable_nat_gateway = true
single_nat_gateway = true
enable_dns_hostnames = true

public_subnet_tags = {
"kubernetes.io/cluster/${local.cluster_name}" = "shared"
"kubernetes.io/role/elb" = 1
}

private_subnet_tags = {
"kubernetes.io/cluster/${local.cluster_name}" = "shared"
"kubernetes.io/role/internal-elb" = 1
}
}

module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "19.5.1"

cluster_name = local.cluster_name
cluster_version = "1.24"

vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnets
cluster_endpoint_public_access = true

eks_managed_node_group_defaults = {
ami_type = "AL2_x86_64"

}

eks_managed_node_groups = {
one = {
name = "node-group-1"

instance_types = ["t3.small"]

min_size = 1
max_size = 3
desired_size = 2
}

two = {
name = "node-group-2"

instance_types = ["t3.small"]

min_size = 1
max_size = 2
desired_size = 1
}
}
}
14 changes: 8 additions & 6 deletions terraform.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
terraform {

cloud {
workspaces {
name = "learn-terraform-eks"
}
}

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.46.0"
version = "~> 4.47.0"
}

random = {
Expand All @@ -19,11 +26,6 @@ terraform {
source = "hashicorp/cloudinit"
version = "~> 2.2.0"
}

kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 2.16.1"
}
}

required_version = "~> 1.3"
Expand Down
26 changes: 0 additions & 26 deletions vpc.tf

This file was deleted.

1 comment on commit 685bb97

@KishoreMandy
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey there, this latest commit broke the tutorial, it was working before this, please revert the change

Please sign in to comment.