Create layer definitions for Kubernetes, Elasticsearch, Kibana, and Beats.
layerform
CLI.
layerform.json
to be able to provision a layer definition.
eks
folder within your terraform
folder. Within that folder, you’ll add a vpc.tf
file.
vpc.tf
file creates a VPC for the EKS cluster you’ll add next.
eks.tf
file within the eks
folder.
eks.tf
file will use the terraform-aws-modules/eks
module to create an EKS instance which uses the VPC in vpc.tf
.
outputs.tf
file to export your cluster’s cluster_id
so that you can use it in the layers above.
outputs.tf
file, add the HCL code below.
eks.tf
file outside the eks
folder.
eks.tf
file, you should declare an instance of the eks
module.
NodePort
or configuring nginx-ingress-controller
so that your instances get an URL when you write an ingress for them in your Terraform files.layerform.json
file in your project’s root folder. You’ll use this file to store all layer definitions.
layers
. This layer has a name base
and a list of files which includes all files within the eks
folder and the outer eks.tf
file, which instantiates the module.
layerform configure
in the outermost folder to create a layer definition in your machine.
layerform.json
.
inputs.tf
file to receive the EKS cluster_id
you’ll use to configure the Kubernetes provider.
cluster_id
.
providers.tf
file and configure the kubernetes
provider to connect to the cluster whose cluster_id
you will receive as an input.
pods.tf
file in which you’ll create a namespace for the Kibana and Elasticsearch pods and the pods themselves.
kubernetes_namespace
and kubernetes_pod
resources, as shown below.
elastic_stack.tf
file in the layerform
folder which declares the module passing the necessary cluster_id
variables to it.
cluster_id
from eks
as an input
to the elastic_stack
module.
elastic_stack
layer will go on top of the base
layer. Therefore, it’s fine for elastic_stack
to use values belonging to the Terraform files of the base
layer below, like modules.eks.cluster_id
.On the other hand, you can’t use values from layers above in the layers below. The base
layer couldn’t reference values belonging to Terraform files of the elastic_stack
layer, for example.layerform.json
to include a layer definition entry for the elastic_stack
layer. This layer depends on base
and contains the Terraform files in the elastic_stack
folder as well as elastic_stack.tf
.
layerform configure
again to update your json
definitions in the back-end.
terraform apply
with a main.tf
file that instantiates both module’s layers.