This topic describes how to use Terraform to integrate (“onboard”) an AWS account for use with Zesty Kompass solutions and also how to install the Kompass Insights agent.
Terraform enables flexible and repeatable integration with Kompass Insights within your infrastructure.
You can use Terraform to:
Integrate an AWS account for use with Kompass and install the Insights agent in the same step.
Integrate an AWS account for use with Kompass without installing the Insights agent.
Limitations
Account type: Only AWS Linked accounts are supported.
To integrate an AWS Management account, use the Zesty platform, as described in Integrate and onboard an AWS account with Zesty.Products: Only Kompass solutions are supported (other Zesty products will be supported in the future).
Lifecycle: After integrating with Terraform, all future changes must also use Terraform
Lifecycle management
You can integrate an account using either the Zesty platform UI or Terraform. The method you choose to begin the process determines which tools you must use to manage changes throughout the product lifecycle.
Account updating is determined by the integration source:
If an account was integrated using Terraform, the account can be updated only with Terraform.
If an account was integrated using the UI, the account can be updated only with the UI.
Insights agent installation (and updating) is determined by the integration source:
If an account was integrated using the UI, the Insights agent can be installed (and updated) only with the UI.
If an account was integrated using Terraform, the Insights agent can be installed (and updated) with either Terraform or the UI.
Best practice: After integrating an account with Terraform, continue to use Terraform to install the Insights agent, update, etc.
For more information about integrating with the UI, see Integrate and onboard an AWS account with Zesty.
Prerequisites
API token for Zesty platform, provided by a Zesty representative
Access to AWS account to integrate
Terraform AWS provider v5.0, or later
Terraform v0.13, or later
If installing the Insights agent, Terraform Helm provider v2.14.1, or later
You must install the Insights agent before installing other Kompass solutions.
Proceed with one of the following:
Integrate an account and install the Insights agent
This procedure integrates an AWS account and installs the Kompass Insights agent.
To integrate an account and install the Insights agent:
Log in to the AWS account to be integrated.
From the AWS console, connect to the target cluster.
Set the Zesty API token environment variable:
export ZESTY_API_TOKEN=<API-KEY>
Set up Terraform configuration:
Copy the Terraform module code from the Example Usage section of Terraform Zesty Module.
module "zesty" { source = "zesty-co/aws-eks-cluster/zesty" } resource "helm_release" "kompass" { name = "kompass" repository = "https://zesty-co.github.io/kompass" chart = "kompass" namespace = "zesty-system" cleanup_on_fail = true create_namespace = true values = [module.zesty.kompass_values_yaml] }
(Optional) Customize the configuration, as described in Optional adjustments.
Save the configuration, for example, main.tf.
Use Terraform to deploy:
Initialize Terraform:
terraform init
(Optional) Preview changes:
terraform plan
Apply the configuration:
terraform apply
Optional adjustments
Before deploying, you can customize the following:
Name of the IAM role: You can change the name of the IAM role (ZestyIAMrole, by default).
Storage class value: If you are installing the Insights agent, you must set the name of the storage class in your environment. The default value is
ebs-sc
AWS provider: If you don’t have an AWS provider defined, define one in the configuration.
Helm provider: If you don’t have a Helm provider defined, define one in the configuration.
Set a custom IAM role name
The default IAM role name is ZestyIAMrole.
To change the IAM role name:
Copy the
role_name
code line and add it under the source line in the module section of main.tf.module "zesty" { source = "zesty-co/aws-eks-cluster/zesty" role_name = <NAME THE ROLE> //the default is ZestyIAMRole }
Type the new role name.
Save the file.
Set the storage class name
If you are installing the Insights agent with Terraform, you must set the name of the storage class to match the name used in your environment.
The default value for storageClassName
is ebs-sc
.
To get the storage class name in your environment, run kubectl get storageclass
on the cluster.
To set the storage class name:
Copy the following code:
set = [{ name = "global.storageClassName" value = "gp2" }, { name = "grafana.persistentVolume.storageClassName" value = "gp2" }, { name = "victoriaMetrics.server.persistentVolume.storageClassName" value = "gp2" }, { name = "kompass-insights.persistence.spec.storageClassName" value = "gp2" }]
Paste it into the main.tf file under the values.
Replace
gp2
with the name of your storage class.Save the file.
Set an AWS provider
If you don’t have an AWS provider defined, configure that.
To set an AWS provider:
Copy the following code and paste it into main.tf above the Cloud Provider Block.
provider "aws" { profile = <PROFILE-NAME> region = <AWS-REGION> }
Replace the values of the variables.
Save the file.
Set a Helm provider
If you don’t have a Helm provider defined, configure that.
To set a Helm provider:
Copy the following code and paste it into main.tf above the helm Provider Block:
provider "helm" {
kubernetes = {
config_path = "~/.kube/config"
config_context = "CONTEXT_NAME"
}
}
Integrate an account only
This procedure integrates an AWS account.
To integrate an account only:
Log in to the AWS account to be integrated.
Set up the Terraform configuration:
Copy the Terraform module code from the Example Usage section of Terraform Zesty Module.
module "zesty" { source = "zesty-co/aws-eks-cluster/zesty" } resource "helm_release" "kompass" { name = "kompass" repository = "https://zesty-co.github.io/kompass" chart = "kompass" namespace = "zesty-system" cleanup_on_fail = true create_namespace = true values = [module.zesty.kompass_values_yaml] }
Comment (or delete) the
helm_release "kompass"
block.Save the configuration, for example, main.tf.
Use Terraform to deploy:
Initialize Terraform:
terraform init
(Optional) Preview changes:
terraform plan
Apply the configuration:
terraform apply