Zabbix (Docker) on AWS ECS with Terraform
Table of content
What is this?
This repository contains an easy to setup working zabbix HA cluster which runs on AWS ECS. The blogpost about this repository can be found here
The following things are created when applying the terraform configuration:
The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.
Please see the manual on Amazon AWS on how to install aws-cli.
Docker is the world’s leading software container platform. Developers use Docker to eliminate “works on my machine” problems when collaborating on code with co-workers. Operators use Docker to run and manage apps side-by-side in isolated containers to get better compute density. Enterprises use Docker to build agile software delivery pipelines to ship new features faster, more securely and with confidence for both Linux and Windows Server apps.
Please see the manual on Docker on how to install docker and on how to run an example hello-world application.
Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions.
Please see the manual on Terraform on how to install terraform.
The following configuration settings can be set in the file
variables.tfvars.example as example.
aws_region]: String(optional): AWS Region you want to deploy this in. (default:
aws_profile]: String(optional) AWS Profile. (default:
aws_instance_type]: String(optional) AWS Instance type you want this application to run on. (default:
aws_db_instance_type]: String(optional) AWS RDS Instance type you want this application to run on. (default:
aws_db_backup_days]: String(optional)Amount (days) how long database backups should be stored. 0 to disable (default: 7)
aws_ami]: String(optional) Amazon AMI to use (default:
aws_certificate_arn]: String(optional) Amazon Certificate Manager is not in terraform. Place the ARN here. If default, zabbix will run on HTTP instead of HTTPS. (default:
aws_route53_hosted_zone_id]: String(optional) The AWS Route53 hosted zone id you want the subdomain to be created on. If false, load balancer is your endpoint. (default:
aws_high_availability]: String(optional) Wheter or not this cluster should be considered high available. Setting this to true means multiple AZ deployment (And an increase in costs!) (default:
name]: String(optional) Name for this application (default:
db_password]: String(required) Password for the RDS database. Choose something strong (default:
ip_ssh_access]: String(optional) Set to false to disable ssh access (recommended). CIDR block (add /32) that has SSH access into the instance. Can be your IP or a bastion host. (default:
public_key]: String(optional) The public key that has access to ssh into the zabbix instance. (default:
domain]: String(optional) The domainname you want to run zabbix on. Only works if
aws_route53_hosted_zone_idis also set! (default:
Once you got all the tools installed we can start launching our zabbix infrastructure.
- Go inside the terraform folder and run
terraform plan -var-file=variables.tfvars. This will give you an overview of what will be created.
terraform apply -var-file=variables.tfvarsto start creating the Amazon AWS recources.
- When everything is successful, You'll see output that will look like this:
Outputs: Zabbix ECR Endpoint = 435551404480.dkr.ecr.eu-west-1.amazonaws.com/zabbix Zabbix Endpoint = https://zabbix-1844418752.eu-west-1.elb.amazonaws.com
AWS Setup is running. Now we need to deploy the docker image. Go inside the docker folder and execute
aws ecr get-login --no-include-email --region eu-west-1
The previous command will return an output that starts with
docker login -u AWS -p Xeg...... Copy that entire output and execute it.
docker build -t zabbix .to start building the docker image
docker tag test:latest <Zabbix ECR Endpoint>:latestReplace with the Zabbix ECR Endpoint received in step 3
As a last step we need to push the docker image to our newly created repository. Execute
docker push <Zabbix ECR Endpoint>:latestReplace with the Zabbix ECR Endpoint received in step 3
That's it! in a moment your zabbix cluster will come online on (See step 3).
If there are any issues, please do let me know!
The Zabbix (Docker) on AWS Terraform repository is licensed under the terms of the GPL Open Source license and is available for free.