Add the database monitoring agent Terraform module - #123
Merged
Merged
Conversation
Moves the Fargate module for the Elastio database monitoring agent (elastio/blue-stack#17072) here from its old repository, as aws-elastio-database-monitoring-agent 0.1.0. The image defaults to public.ecr.aws/elastio/elastio-database-monitoring-agent:0.1.4 and every resource name uses the elastio-dbmon prefix. The variable names are unchanged because the Elastio Portal renders a module call from them.
- Add an EFS file system policy: only the task role may mount, only through the access point, and only over TLS. Without it, any NFS client that reaches a mount target can mount the file system as root. - Make the service depend on the IAM policies, secret versions, and the file system policy, so the first task does not start before it may read its secrets or mount the ledger, and destroy stops the task first. - Validate that subnet_ids and security_group_ids are not empty, and that log_retention_days is a value CloudWatch Logs accepts.
Agent 0.1.5 reads ELASTIO_DBMON_* variables (QUELL_* still as a fallback) and keeps its ledger under /var/lib/elastio-dbmon. The module sets the new names, mounts the ledger there and names the path explicitly, so the EFS access point's ledger is the same file as before. It also sets GOMEMLIMIT to 80% of the task's memory: Go sets no memory limit from the container on its own. The default image is 0.1.5, which this needs.
Contributor
Author
|
Pushed 98276af for agent 0.1.5 (elastio/database-monitoring-agent#1): the module now sets the |
EFS admits a client when either its identity policy or the file system policy allows it, so an Allow alone does not keep out other roles with EFS permissions. Add explicit Denies for every principal except the task role and for every mount that does not use the access point.
EFS does not enforce aws:PrincipalArn for NFS clients, so the deny did not restrict other principals and could refuse the agent itself. Keep only the denies on the access point and TLS, which use keys EFS enforces, and state that the EFS security group is the boundary against other roles with their own EFS permissions.
The task was fixed at 0.25 vCPU and 512 MiB. What a larger task buys is the largest transaction the agent holds in memory whole: agent 0.1.6 judges anything bigger from its row counts and reports an oversized transaction with the smallest task memory that would have held it. So the size is now two inputs, task_cpu (default 256) and task_memory (default 512, MiB). They are validated as a pair Fargate runs on ARM64: 256 with 512, 1024 or 2048; 512 with 1024 to 4096; 1024 with 2048 to 8192; 2048 with 4096 to 16384; memory above 512 in steps of 1024. GOMEMLIMIT follows task_memory at floor(task_memory * 0.8) MiB, so the agent's transaction budget follows the size too. The default image is 0.1.6. The README has a Sizing section with the four sizes the product offers, what each holds and costs in us-east-1, and how the Elastio UI says when to size up. The tests plan each size and refuse pairs Fargate does not run.
The comment said Fargate makes the bind mount writable for the container's uid. It is writable when the image has a VOLUME at the ledger directory owned by uid 65532, because ECS copies that VOLUME into the bind mount. Also note that the task size is now configurable.
maksvet
approved these changes
Sep 24, 2026
maksvet
left a comment
Contributor
There was a problem hiding this comment.
Checked the 0.1.6 image (VOLUME and owner at /var/lib/elastio-dbmon) and ran this head in a test account: both ledger modes start and open the ledger, and the agent reads its limits from ECS metadata.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
database-monitoring/terraform: the module that runs the Elastio database monitoring agent on AWS Fargate (elastio/blue-stack#17072). It is published asaws-elastio-database-monitoring-agent0.1.0, so the registry source isterraform.cloudsmith.io/public/elastio-database-monitoring-agent/aws.Source:
deploy/terraform/aws-fargateat tagagent-v0.1.3in the old agent repository, adapted for this repo.Changes from the source module
imagedefault is nowpublic.ecr.aws/elastio/elastio-database-monitoring-agent:0.1.4. That image is not published yet.elastio-dbmonprefix:/elastio-dbmon/agent/<name>elastio-dbmon/<name>/{api-key,database-url,hash-secret}-*elastio-dbmon-<name16>-{exec,task}-*elastio-dbmon-<name16>-efs-*Nametagelastio-dbmon-<name>-ledger/elastio-dbmonread-elastio-dbmon-secretsandmount-elastio-dbmon-ledgerelastio-dbmon-agentname_prefix.creation_tokenis removed and the provider generates one. The old token was built from the full name, so it broke EFS's 64-character limit for long names.jsonencode, notdata "aws_iam_policy_document", to follow this repo's convention (Replacedata "aws_iam_policy_document"with manualjsonencode#109).data.aws_region'snameandidare both deprecated in AWS provider 6, andrequired_providersis nowaws >= 5.0/random >= 3.0(the relaxed constraints from Relax TF provider version requirements #121).required_versionis~> 1.9.QUELL_*environment variable names. They are the agent binary's configuration contract./var/lib/quell. It is the image's own volume, owned by the non-root user, and the ephemeral (non-EFS) mode depends on it.moved {}block. Resource addresses are the same as before; only the AWS-side names changed.examples/basic(with its lock file, as the other examples have), anames_and_imagetest, and a region assertion.Checks run locally
terraform init -backend=false && terraform validate: valid, no warnings (AWS provider 6.66.0)terraform test: 4 passed, 0 failedterraform validateinexamples/basic: validterraform-docsv0.19.0, thenprettier --check .: cleantflint --recursive(repo.tflint.hcl): cleantypos: cleanterraform fmt: clean on the new filesTask size (commit 387bdde)
task_cpu(default 256) andtask_memory(default 512, MiB). The product renders these names. Validation accepts only pairs that Fargate runs on ARM64: 256 with 512, 1024 or 2048; 512 with 1024 to 4096; 1024 with 2048 to 8192; 2048 with 4096 to 16384. Memory above 512 MiB goes in steps of 1024.GOMEMLIMITisfloor(task_memory * 0.8)MiB. The agent's budget for one open transaction is 30% of that, so the budget follows the size.agent-v0.1.6before this module is released.GOMEMLIMIT. Pairs Fargate does not run are refused at plan. The default image is checked as 0.1.6.terraform fmt,validate(module and example),test,tflint --recursive, terraform-docs v0.19.0 plus prettier, andtypos, all clean.Release
After merge, someone with write access runs the
releaseworkflow (workflow_dispatch) on master. It publishes only modules whosename-versiontag doesn't exist yet, so only this module is published.