github.com/replicatedhq/ship@v0.55.0/pkg/lifecycle/render/amazoneks/render_templates.go (about)

     1  package amazoneks
     2  
     3  const newVPCTempl = `
     4  variable "vpc_cidr" {
     5    type    = "string"
     6    default = "{{.CreatedVPC.VPCCIDR}}"
     7  }
     8  
     9  variable "vpc_public_subnets" {
    10    default = [{{range .CreatedVPC.PublicSubnets}}
    11      "{{.}}",{{end}}
    12    ]
    13  }
    14  
    15  variable "vpc_private_subnets" {
    16    default = [{{range .CreatedVPC.PrivateSubnets}}
    17      "{{.}}",{{end}}
    18    ]
    19  }
    20  
    21  variable "vpc_azs" {
    22    default = [{{range .CreatedVPC.Zones}}
    23      "{{.}}",{{end}}
    24    ]
    25  }
    26  
    27  module "vpc" {
    28    source  = "terraform-aws-modules/vpc/aws"
    29    version = "1.60.0"
    30    name    = "eks-vpc"
    31    cidr    = "${var.vpc_cidr}"
    32    azs     = "${var.vpc_azs}"
    33  
    34    private_subnets = "${var.vpc_private_subnets}"
    35    public_subnets  = "${var.vpc_public_subnets}"
    36  
    37    map_public_ip_on_launch = true
    38    enable_nat_gateway      = true
    39    single_nat_gateway      = true
    40  
    41    tags = "${map("kubernetes.io/cluster/${var.eks-cluster-name}", "shared")}"
    42  }
    43  
    44  locals {
    45    "eks_vpc"                 = "${module.vpc.vpc_id}"
    46    "eks_vpc_public_subnets"  = "${module.vpc.public_subnets}"
    47    "eks_vpc_private_subnets" = "${module.vpc.private_subnets}"
    48  }
    49  `
    50  
    51  const existingVPCTempl = `
    52  locals {
    53    "eks_vpc"                 = "{{.ExistingVPC.VPCID}}"
    54    "eks_vpc_public_subnets"  = [{{range .ExistingVPC.PublicSubnets}}
    55      "{{.}}",{{end}}
    56    ]
    57    "eks_vpc_private_subnets" = [{{range .ExistingVPC.PrivateSubnets}}
    58      "{{.}}",{{end}}
    59    ]
    60  }
    61  `
    62  
    63  const workerTempl = `
    64  locals {
    65    "worker_group_count" = "{{len .AutoscalingGroups}}"
    66  }
    67  
    68  locals {
    69    "worker_groups" = [{{range .AutoscalingGroups}}
    70      {
    71        name                 = "{{.Name}}"
    72        asg_min_size         = "{{.GroupSize}}"
    73        asg_max_size         = "{{.GroupSize}}"
    74        asg_desired_capacity = "{{.GroupSize}}"
    75        instance_type        = "{{.MachineType}}"
    76  
    77        subnets = "${join(",", local.eks_vpc_private_subnets)}"
    78      },{{end}}
    79    ]
    80  }
    81  
    82  provider "aws" {
    83    version = "~> 2.7.0"
    84    region  = "{{.Region}}"
    85  }
    86  
    87  variable "eks-cluster-name" {
    88    default = "{{.ClusterName}}"
    89    type    = "string"
    90  }
    91  
    92  module "eks" {
    93    source  = "terraform-aws-modules/eks/aws"
    94    version = "3.0.0"
    95  
    96    cluster_name = "${var.eks-cluster-name}"
    97  
    98    subnets = ["${local.eks_vpc_private_subnets}", "${local.eks_vpc_public_subnets}"]
    99  
   100    vpc_id = "${local.eks_vpc}"
   101  
   102    worker_group_count = "${local.worker_group_count}"
   103    worker_groups      = "${local.worker_groups}"
   104  }
   105  `