Skip to content

Instantly share code, notes, and snippets.

@tomdavidson tomdavidson/config.tf
Last active Feb 24, 2018

Embed
What would you like to do?
tectonic-installer#3025
/**
* Defaults and other config items for the K8S Installer
*
*/
terraform {
backend "s3" {}
required_version = ">= 0.10.7"
}
locals {
backend_name = "${var.project_name}-${var.env}-${var.primary_region}-${data.aws_caller_identity.current.account_id}"
env = "${var.env}"
primary_region = "${var.primary_region}"
}
# Meta
locals {
comment = "Managed by ccs/k8s for ${lookup(local.tags, "vendor", "" )}: ${lookup(local.tags, "env", "" )}"
names_defaults = {
prefix = ""
suffix = "${local.env}"
root = "${var.project_name}"
}
names_required = {}
names = "${merge(local.names_defaults, var.names, local.names_required)}"
name = "${join("-", compact(list(
lookup(local.names, "prefix"),
lookup(local.names, "root"),
lookup(local.names, "suffix"),
)))}"
tags_default = {
name = "${local.name}"
data-sensitivity = "sensitive"
}
tags_required = {
vendor = "DevOps Team"
env = "${local.env}"
}
tags = "${merge(local.tags_default, var.tags, local.tags_required)}"
}
# Tectonic
locals {
tectonic_defaults = {}
tectonic = "${merge(local.tectonic_defaults, var.tectonic)}"
}
# Identity
locals {
iam = {
aws_key_pair_name = "${element(concat(aws_key_pair.default.*.key_name, list("")), 0)}"
installer_role_path = "/"
}
}
# Cluster
locals {
cluster_defaults = {
aws_region = "${local.primary_region}"
name = "${lookup(local.names, "suffix")}"
public_endpoints = true
private_endpoints = true
aws_assets_s3_bucket_name = "${local.backend_name}"
}
cluster = "${merge(local.cluster_defaults, var.cluster)}"
etcd_defaults = {
aws_ec2_type = "t2.medium"
aws_root_volume_iops = "100"
aws_root_volume_size = "30"
aws_root_volume_type = "gp2"
node_count = 1
}
etcd = "${merge(local.etcd_defaults, var.etcd)}"
master_defaults = {
aws_ec2_type = "t2.medium"
aws_iam_role_name = ""
aws_root_volume_iops = "100"
aws_root_volume_size = "30"
aws_root_volume_type = "gp2"
node_count = 1
}
master = "${merge(local.master_defaults, var.master)}"
worker_defaults = {
aws_ec2_type = "t2.medium"
aws_iam_role_name = ""
aws_root_volume_iops = "100"
aws_root_volume_size = "30"
aws_root_volume_type = "gp2"
node_count = 1
}
worker = "${merge(local.worker_defaults, var.worker)}"
cluster_aws_extra_sg_ids = {
master = []
worker = []
etcd = []
}
}
# Networking
locals {
dns_defaults = {
prefix = ""
base_zone = "${lookup(local.names,"root")}.${lookup(var.dns,"parent_zone")}"
hostname = "${lookup(local.names,"root")}"
aws_external_private_zone = ""
}
dns = "${merge(local.dns_defaults, var.dns)}"
network_defaults = {
aws_external_private_zone = ""
aws_external_vpc_id = ""
aws_external_vpc_public = "${lookup(local.cluster, "public_facing", true)}"
aws_vpc_cidr_block = "10.0.0.0/16"
}
network = "${merge(local.network_defaults, var.network)}"
network_extras = {
aws_external_master_subnet_ids = []
aws_external_worker_subnet_ids = []
aws_worker_load_balancers = []
}
}
provider "aws" {
region = "${local.primary_region}"
version = "~> 1.0"
}
locals {
module_name = "k8s"
}
resource "tls_private_key" "default" {
algorithm = "RSA"
}
resource "aws_key_pair" "default" {
key_name = "${local.name}"
public_key = "${tls_private_key.default.public_key_openssh}"
}
module "tectonic-installer" {
source = "github.com/coreos/tectonic-installer.git//platforms/aws?ref=1.8.7-tectonic.1"
tectonic_admin_email = "${local.tectonic["email"]}"
tectonic_admin_password = "${lookup(local.tectonic, "password")}"
tectonic_aws_assets_s3_bucket_name = "${lookup(local.cluster, "aws_assets_s3_bucket_name")}"
tectonic_aws_etcd_ec2_type = "${lookup(local.etcd, "aws_ec2_type")}"
tectonic_aws_etcd_extra_sg_ids = "${local.cluster_aws_extra_sg_ids["etcd"]}"
tectonic_aws_etcd_root_volume_iops = "${lookup(local.etcd, "aws_root_volume_iops")}"
tectonic_aws_etcd_root_volume_size = "${lookup(local.etcd, "aws_root_volume_size")}"
tectonic_aws_etcd_root_volume_type = "${lookup(local.etcd, "aws_root_volume_type")}"
tectonic_aws_external_master_subnet_ids = "${local.network_extras["aws_external_master_subnet_ids"]}"
tectonic_aws_external_worker_subnet_ids = "${local.network_extras["aws_external_worker_subnet_ids"]}"
tectonic_aws_external_private_zone = "${lookup(local.network, "aws_external_private_zone")}"
# https://github.com/coreos/tectonic-installer/issues/3024
# tectonic_aws_external_vpc_id = "${lookup(local.network, "aws_external_vpc_id")}"
tectonic_aws_extra_tags = "${local.tags}"
tectonic_aws_master_ec2_type = "${lookup(local.master, "aws_ec2_type")}"
tectonic_aws_master_extra_sg_ids = "${local.cluster_aws_extra_sg_ids["master"]}"
tectonic_aws_master_iam_role_name = "${lookup(local.master, "aws_iam_role_name")}"
tectonic_aws_master_root_volume_iops = "${lookup(local.master, "aws_root_volume_iops")}"
tectonic_aws_master_root_volume_size = "${lookup(local.master, "aws_root_volume_size")}"
tectonic_aws_master_root_volume_type = "${lookup(local.master, "aws_root_volume_type")}"
tectonic_aws_private_endpoints = "${lookup(local.cluster, "private_endpoints")}"
tectonic_aws_public_endpoints = "${lookup(local.cluster, "public_endpoints")}"
#tectonic_aws_region = "${lookup(local.cluster_defaults, "aws_region")}"
tectonic_aws_region = "${local.primary_region}"
tectonic_aws_ssh_key = "${lookup(local.iam, "aws_key_pair_name")}"
tectonic_aws_vpc_cidr_block = "${lookup(local.network, "aws_vpc_cidr_block")}"
tectonic_aws_worker_ec2_type = "${lookup(local.worker, "aws_ec2_type")}"
tectonic_aws_worker_extra_sg_ids = "${local.cluster_aws_extra_sg_ids["worker"]}"
tectonic_aws_worker_iam_role_name = "${lookup(local.worker, "aws_iam_role_name")}"
tectonic_aws_worker_load_balancers = "${local.network_extras["aws_worker_load_balancers"]}"
tectonic_aws_worker_root_volume_iops = "${lookup(local.worker, "aws_root_volume_iops")}"
tectonic_aws_worker_root_volume_size = "${lookup(local.worker, "aws_root_volume_size")}"
tectonic_aws_worker_root_volume_type = "${lookup(local.worker, "aws_root_volume_type")}"
tectonic_base_domain = "${lookup(local.dns, "base_zone")}"
tectonic_cluster_name = "${lookup(local.cluster, "name")}"
tectonic_dns_name = "${lookup(local.dns, "prefix")}"
tectonic_etcd_count = "${lookup(local.etcd, "node_count")}"
tectonic_license_path = "${lookup(local.tectonic, "license_path")}"
tectonic_master_count = "${lookup(local.master, "node_count")}"
tectonic_pull_secret_path = "${lookup(local.tectonic, "pull_secret_path")}"
tectonic_worker_count = "${lookup(local.worker, "node_count")}"
# tectonic_aws_ec2_ami_override
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.