Commit 3e9471d3 authored by Chris Merrett's avatar Chris Merrett

Enable EKS Kubernetes support for VPC module

parent b5570009
Pipeline #4955 passed with stage
in 18 seconds
.DS_Store
.terraform/
image: alpine:latest
variables:
TERRAFORM_URL: "https://releases.hashicorp.com/terraform/0.7.1/terraform_0.7.1_linux_amd64.zip"
TERRAFORM_URL: "https://releases.hashicorp.com/terraform/0.11.7/terraform_0.11.7_linux_amd64.zip"
before_script:
- apk update && apk add ca-certificates && update-ca-certificates && apk add openssl
......@@ -9,4 +9,4 @@ before_script:
- unzip /tmp/terraform.zip -d /usr/local/bin
test:
script: terraform validate
script: terraform init && terraform validate -check-variables=false
......@@ -31,18 +31,35 @@ variable "enable_dns_support" {
default = true
}
variable "enable_eks_support" {
description = "When set to true, properly tags VPC assets with proper discovery assets"
default = "true"
}
variable "eks_cluster_name" {
description = "Name of the EKS cluster to reside within the VPC"
}
resource "aws_vpc" "mod" {
cidr_block = "${var.cidr}"
enable_dns_hostnames = "${var.enable_dns_hostnames}"
enable_dns_support = "${var.enable_dns_support}"
tags {
Name = "${var.name}"
}
tags = "${var.enable_eks_support == "true" ?
map(
"Name", "${var.name}",
"kubernetes.io/cluster/${var.eks_cluster_name}", "shared",
) :
map(
"Name", "${var.name}",
)
}"
}
resource "aws_subnet" "public" {
lifecycle { create_before_destroy = true }
lifecycle {
create_before_destroy = true
}
vpc_id = "${aws_vpc.mod.id}"
cidr_block = "${element(var.public_subnets, count.index)}"
......@@ -56,16 +73,24 @@ resource "aws_subnet" "public" {
}
resource "aws_subnet" "private" {
lifecycle { create_before_destroy = true }
lifecycle {
create_before_destroy = true
}
vpc_id = "${aws_vpc.mod.id}"
cidr_block = "${element(var.private_subnets, count.index)}"
availability_zone = "${element(var.availability_zones, count.index)}"
count = "${length(var.private_subnets)}"
tags {
Name = "${var.name}.private.${element(var.availability_zones, count.index)}"
}
tags = "${var.enable_eks_support == "true" ?
map(
"Name", "${var.name}.private.${element(var.availability_zones, count.index)}",
"kubernetes.io/cluster/${var.eks_cluster_name}", "shared",
) :
map(
"Name", "${var.name}.private.${element(var.availability_zones, count.index)}",
)
}"
}
resource "aws_internet_gateway" "mod" {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment