How sonatype/nxrm-reference-architectures works
Purpose and Entry Points
This is Terraform infrastructure-as-code for deploying self-managed Sonatype Nexus Repository reference architectures on AWS, from single-node dev/test through HA clusters. The root composition and public deployment interface are main.tf, variables.tf, outputs.tf, and versions.tf. Operators select a sizing profile from tfvars/ra-1-selfmanaged.tfvars through tfvars/ra-5-selfmanaged.tfvars, normally copied to terraform.tfvars, then run Terraform.
Root Orchestration
main.tf composes domain modules for network, IAM, persistence, compute, and ingress; root variables supply topology, sizing, storage/database choices, and security controls. outputs.tf exposes the operational boundary: Nexus URL, ALB DNS, instance IDs, database endpoint, blob bucket, and generated/provided admin credentials. Terraform state is the control plane for provisioning and lifecycle operations.
Networking and Ingress
The networking module either creates a VPC topology or accepts caller-provided VPC and subnet IDs, separating public ALB placement from private Nexus nodes. modules/networking/main.tf defines this boundary; modules/networking/outputs.tf exports IDs consumed downstream. modules/loadbalancer/main.tf provides the Application Load Balancer and routes client HTTP/HTTPS traffic to Nexus instances, using ACM when a certificate ARN is supplied.
Compute and Node Bootstrap
modules/compute/main.tf provisions one or more EC2 Nexus nodes, with cluster count determined by the selected reference architecture. Nodes run in private subnets and use IAM-backed AWS access and SSM operations. Bootstrap/user-data is rendered from scripts/templates/user-data.sh.tpl; it installs/configures Nexus, supplies generated settings and credentials, and coordinates persistent mounts. scripts/templates/configure-nexus.sh.tpl is the application-configuration stage, including database, blob-store, and clustering-dependent setup.
Persistence Choices
The storage boundary supports S3 blob storage or node-attached EBS/file storage. modules/storage/main.tf provisions and configures the selected backend; S3 is the scalable/HA path, while EBS/file storage is constrained to single-node profiles. The database boundary is selected independently: H2 for the smallest standalone topology or PostgreSQL RDS for production and HA deployments. modules/database/main.tf creates the RDS side, and modules/database/outputs.tf supplies connection details to compute bootstrap.
Identity and Security Boundaries
modules/iam/main.tf creates instance roles/policies needed for EC2 nodes to interact with AWS services such as S3 and Systems Manager. Security is layered across private compute networking, security groups owned by networking/load-balancer modules, encrypted storage, IMDSv2 enforcement, optional TLS termination at ALB, and Terraform-managed Nexus admin credentials. Exact policy/resource outputs are passed through modules/iam/outputs.tf and module interfaces.
Runtime, Artifacts, and Deployment Flow
Terraform (AWS provider; version constraints in versions.tf) invokes AWS APIs to create VPC/NAT/ALB, EC2, EBS/S3, RDS, and IAM resources. Before apply, users place the Nexus Linux installer and, when required, Pro license in files_to_upload_to_nodes/; bootstrap consumes these artifacts. Runtime request flow is client → ALB → Nexus EC2 node(s); Nexus persists metadata to H2 or RDS and repository blobs to EBS/file or S3. HA profiles require multiple Nexus nodes, PostgreSQL, and S3-backed blobs.
Main entry points: main.tf Terraform · compute/main.tf Compute module · loadbalancer/main.tf ALB module · networking/main.tf Networking module
Components 19
Terraform Control Plane
- Operator
- Sizing profiles · Selects standalone through HA topology.
tfvars/ra-1-selfmanaged.tfvars - Terraform · Plans and applies the selected architecture.
main.tf - Root inputs & outputs · Exposes deployment controls and operational endpoints.
variables.tf - Terraform state · Control plane for managed resource lifecycle.
AWS Infrastructure
- Networking module · Creates or accepts VPC and public/private subnet topology.
modules/networking/main.tf - IAM module · Creates node roles and AWS access policies.
modules/iam/main.tf - ALB module · Terminates optional TLS and routes traffic to nodes.
modules/loadbalancer/main.tf - Compute module · Provisions one or more private Nexus EC2 nodes.
modules/compute/main.tf - Storage module · Selects S3 blobs or single-node EBS/file storage.
modules/storage/main.tf - Database module · Selects H2 standalone or PostgreSQL RDS.
modules/database/main.tf - AWS APIs
Nexus Bootstrap
- Nexus installer & license · Operator-supplied installer and optional Pro license.
- EC2 user-data · Installs Nexus and prepares settings, credentials, and mounts.
scripts/templates/user-data.sh.tpl - Nexus configuration · Configures database, blob store, and clustering.
scripts/templates/configure-nexus.sh.tpl
Nexus Runtime
- Repository clients
- Nexus EC2 nodes · Single node or HA cluster based on the profile.
- Blob storage · S3 is required for scalable HA profiles.
- Metadata database · RDS PostgreSQL is required for HA profiles.
Connections 30
- Operator → Sizing profiles: selects
- Operator → Terraform: runs
- Sizing profiles → Terraform: supplies topology
- Root inputs & outputs → Terraform: defines interface
- Terraform → Terraform state: records lifecycle
- Terraform → Networking module: composes
- Terraform → IAM module: composes
- Terraform → ALB module: composes
- Terraform → Compute module: composes
- Terraform → Storage module: composes
- Terraform → Database module: composes
- Networking module → AWS APIs: provisions network
- IAM module → AWS APIs: provisions roles
- ALB module → AWS APIs: provisions ALB
- Compute module → AWS APIs: provisions EC2
- Storage module → AWS APIs: provisions backend
- Database module → AWS APIs: provisions database
- Networking module → ALB module: public subnets
- Networking module → Compute module: private subnets
- IAM module → Compute module: instance role
- Database module → Compute module: connection details
- Storage module → Compute module: storage settings
- Nexus installer & license → EC2 user-data: consumed during bootstrap
- EC2 user-data → Nexus configuration: runs
- Compute module → EC2 user-data: renders on nodes
- Nexus configuration → Nexus EC2 nodes: configures
- Repository clients → ALB module: HTTP/HTTPS
- ALB module → Nexus EC2 nodes: routes requests
- Nexus EC2 nodes → Blob storage: stores blobs
- Nexus EC2 nodes → Metadata database: stores metadata