The Label Studio AWS EKS Terraform module is a tool for deploying LabelStudio on Amazon Web Services Elastic Kubernetes Service (AWS EKS). This module allows users to easily deploy and manage LabelStudio in a scalable, highly available manner using the AWS cloud and Kubernetes.
This document will provide an overview of the deployment process and the prerequisites for using the module. It will also cover the configuration options and provide step-by-step instructions for deploying LabelStudio on AWS EKS using the Terraform module. Finally, it will provide tips for testing and validating the deployment, as well as next steps for updating and modifying the deployment.
Amazon Elastic Kubernetes Service is a managed Kubernetes service on AWS, it gives user flexibility to run and scale Kubernetes applications in the AWS cloud.
NAME | Version |
---|---|
Common prerequisites | |
aws cli | 2.9.4 |
Consult the AWS documentation for specific instructions for your system.
You should have an AWS account and appropriate permissions to create and manage the resources required for the deployment. This includes the ability to create and manage EC2 instances, S3 buckets, and other AWS services.
Click to expand IAM configuration
Once you have created an AWS account, go to your account security settings and be sure to follow these steps:
- Set a strong password
- Activate MFA for the root account
- Delete and do not create access keys for the root account
Further, in the IAM console:
-
In the Policies menu, create
MFASecurity
policy that prohibits users from using services without activating MFA -
In the Roles menu, create new role
administrator
. Select Another AWS Account - and enter your account number in the Account ID field. Check the Require MFA checkbox. In the next Permissions window, attach theAdministratorAccess
policy to it. -
In the Policies menu, create
assumeAdminRole
policy:{ "Version": "2012-10-17", "Statement": { "Effect": "Allow", "Action": "sts:AssumeRole", "Resource": "arn:aws:iam::<your-account-id>:role/administrator" } }
-
In the Groups menu, create the
admin
group; in the next window, attachassumeAdminRole
andMFASecurity
policy to it. Finish creating the group. -
In the Users menu, create a user to work with AWS by selecting both checkboxes in Select AWS access type. In the next window, add the user to the
admin
group. Finish and download CSV with credentials.
Once these prerequisites are in place, you can proceed to the next step of configuring and deploying LabelStudio using the Terraform module.
There are multiple configuration examples for different use-cases to provision Label Studio/Label Studio Enterprise stored in examples folder.
The full list of available configuration variables can be found in AWS module folder.
Deploy Label Studio with Bitnami's PostgreSQL database provisioned in AWS EKS.
Deploy Label Studio with AWS RDS as database.
postgresql_type = "rds"
postgresql_database = "<REPLACE_ME>"
postgresql_username = "<REPLACE_ME>"
Deploy Label Studio connected to the external postgresql database(e.g. already provisioned).
postgresql_type = "external"
postgresql_database = "<REPLACE_ME>"
postgresql_host = "<REPLACE_ME>"
postgresql_port = "<REPLACE_ME>"
postgresql_username = "<REPLACE_ME>"
postgresql_password = "<REPLACE_ME>"
Deploy Label Studio connected to the external postgresql database with SSL(e.g. already provisioned).
postgresql_type = "external"
postgresql_database = "<REPLACE_ME>"
postgresql_host = "<REPLACE_ME>"
postgresql_port = "<REPLACE_ME>"
postgresql_username = "<REPLACE_ME>"
postgresql_password = "<REPLACE_ME>"
postgresql_ssl_mode = "verify-ca"
postgresql_tls_key_file = "<REPLACE_ME>/postgres.key"
postgresql_tls_crt_file = "<REPLACE_ME>/postgres.crt"
postgresql_ca_crt_file = "<REPLACE_ME>/postgresCA.crt"
Deploy and assign domain name with singed by Let's Encrypt certificate using cert-manager.
If you already have Hosted Zone, set create_r53_zone
to false
.
create_r53_zone = false
domain_name = "example.com"
record_name = "label-studio"
email = "[email protected]"
Deploy to existing VPC.
predefined_vpc_id = "vpc-***"
Deploy a Label Studio Enterprise with ElastiCache and RDS.
enterprise = true
license_literal = "<REPLACE_ME>"
registry_username = "<REPLACE_ME>"
registry_password = "<REPLACE_ME>"
label_studio_additional_set = {
"global.image.repository" = "heartexlabs/label-studio-enterprise"
"global.image.tag" = "<REPLACE_ME>"
}
Deploy a Label Studio Enterprise with external Redis(e.g. already provisioned).
redis_type = "external"
redis_host = "redis://<SECRET>:<SECRET>/1"
redis_password = "<SECRET>"
Deploy a Label Studio Enterprise with external Redis with SSL(e.g. already provisioned)..
redis_type = "external"
redis_host = "rediss://<REPLACE_ME>:<REPLACE_ME>/1"
redis_password = "<SECRET>"
redis_ssl_mode = "required"
redis_tls_key_file = "<REPLACE_ME>/redis.key"
redis_tls_crt_file = "<REPLACE_ME>/redis.crt"
redis_ca_crt_file = "<REPLACE_ME>/redisCA.crt"
To start usage an example of a Terraform configuration and adjust it for your own use, you will need to follow these steps:
- Find an example of a Terraform configuration that is similar to the infrastructure you want to create.
- Copy the example configuration and save it to a file with a
.tf
extension. For example, you might save the configuration to a file namedexample.tf
. - Open the file in a text editor and review the configuration. Look for any values that need to be adjusted to match your desired infrastructure. For example, you might need to change the name of a resource, the size of a virtual machines, or the region where the resources will be created.
- Change the required environment name, name and AWS regions:
environment = "demo"
name = "ls"
region = "eu-north-1"
- Initialize and configure backend:
make init "provider=aws" "var_file=$(pwd)/terraform/aws/examples/opensource.tfvars"
- Plan all AWS resources:
make plan "provider=aws" "var_file=$(pwd)/terraform/aws/examples/opensource.tfvars"
- Create or update Terraform resources:
make apply "provider=aws" "var_file=$(pwd)/terraform/aws/examples/opensource.tfvars"
- Check an output for available endpoints.
- Destroy all Terraform resources:
make destroy "provider=aws" "var_file=$(pwd)/terraform/aws/examples/opensource.tfvars"
In order to ensure that our infrastructure is secure and compliant with best practices we have a CI integration with TFsec.
These checks are designed to help us identify potential security vulnerabilities in our Terraform configuration, and skipping them could leave our infrastructure at risk.
However, we have suppressed few checks as it's impossible to satisfy them and/or they are not related to our demo-cases. More info can be found in TFSEC.md