# sonatype/nxrm-reference-architectures architecture

> Architecture diagram of the GitHub repository sonatype/nxrm-reference-architectures, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sonatype/nxrm-reference-architectures
- Repository: https://github.com/sonatype/nxrm-reference-architectures

## Overview

#### 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`](https://github.com/sonatype/nxrm-reference-architectures/blob/main/main.tf) (Terraform), [`modules/compute/main.tf`](https://github.com/sonatype/nxrm-reference-architectures/blob/main/modules/compute/main.tf) (Compute module), [`modules/loadbalancer/main.tf`](https://github.com/sonatype/nxrm-reference-architectures/blob/main/modules/loadbalancer/main.tf) (ALB module), [`modules/networking/main.tf`](https://github.com/sonatype/nxrm-reference-architectures/blob/main/modules/networking/main.tf) (Networking module)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_root["Terraform Control Plane"]
  node_operator(("Operator<br/>user"))
  node_profiles["Sizing profiles<br/>tfvars"]
  node_terraform{{"Terraform<br/>provisioner<br/>[main.tf]"}}
  node_root_interface["Root inputs &amp; outputs<br/>Terraform interface<br/>[variables.tf]"]
  node_state[("Terraform state<br/>lifecycle state")]
end

subgraph group_aws["AWS Infrastructure"]
  node_networking["Networking module<br/>Terraform module<br/>[main.tf]"]
  node_iam["IAM module<br/>Terraform module<br/>[main.tf]"]
  node_load_balancer["ALB module<br/>Terraform module<br/>[main.tf]"]
  node_compute["Compute module<br/>Terraform module<br/>[main.tf]"]
  node_storage["Storage module<br/>Terraform module<br/>[main.tf]"]
  node_database["Database module<br/>Terraform module<br/>[main.tf]"]
  node_aws_apis{{"AWS APIs<br/>cloud control plane"}}
end

subgraph group_bootstrap["Nexus Bootstrap"]
  node_install_artifacts["Nexus installer &amp; license<br/>deployment artifacts"]
  node_user_data["EC2 user-data<br/>bootstrap template<br/>[user-data.sh.tpl]"]
  node_nexus_config["Nexus configuration<br/>bootstrap template"]
end

subgraph group_runtime["Nexus Runtime"]
  node_clients(("Repository clients"))
  node_nexus_nodes["Nexus EC2 nodes<br/>application cluster"]
  node_blob_store[("Blob storage<br/>S3 or EBS/file")]
  node_metadata_store[("Metadata database<br/>H2 or PostgreSQL RDS")]
end

node_operator -->|"selects"| node_profiles
node_operator -->|"runs"| node_terraform
node_profiles -->|"supplies topology"| node_terraform
node_root_interface -->|"defines interface"| node_terraform
node_terraform -->|"records lifecycle"| node_state
node_terraform -->|"composes"| node_networking
node_terraform -->|"composes"| node_iam
node_terraform -->|"composes"| node_load_balancer
node_terraform -->|"composes"| node_compute
node_terraform -->|"composes"| node_storage
node_terraform -->|"composes"| node_database
node_networking -->|"provisions network"| node_aws_apis
node_iam -->|"provisions roles"| node_aws_apis
node_load_balancer -->|"provisions ALB"| node_aws_apis
node_compute -->|"provisions EC2"| node_aws_apis
node_storage -->|"provisions backend"| node_aws_apis
node_database -->|"provisions database"| node_aws_apis
node_networking -->|"public subnets"| node_load_balancer
node_networking -->|"private subnets"| node_compute
node_iam -->|"instance role"| node_compute
node_database -->|"connection details"| node_compute
node_storage -->|"storage settings"| node_compute
node_install_artifacts -->|"consumed during bootstrap"| node_user_data
node_user_data -->|"runs"| node_nexus_config
node_compute -->|"renders on nodes"| node_user_data
node_nexus_config -->|"configures"| node_nexus_nodes
node_clients -->|"HTTP/HTTPS"| node_load_balancer
node_load_balancer -->|"routes requests"| node_nexus_nodes
node_nexus_nodes -->|"stores blobs"| node_blob_store
node_nexus_nodes -->|"stores metadata"| node_metadata_store

click node_profiles "https://github.com/sonatype/nxrm-reference-architectures/blob/main/tfvars/ra-1-selfmanaged.tfvars"
click node_terraform "https://github.com/sonatype/nxrm-reference-architectures/blob/main/main.tf"
click node_root_interface "https://github.com/sonatype/nxrm-reference-architectures/blob/main/variables.tf"
click node_networking "https://github.com/sonatype/nxrm-reference-architectures/blob/main/modules/networking/main.tf"
click node_iam "https://github.com/sonatype/nxrm-reference-architectures/blob/main/modules/iam/main.tf"
click node_load_balancer "https://github.com/sonatype/nxrm-reference-architectures/blob/main/modules/loadbalancer/main.tf"
click node_compute "https://github.com/sonatype/nxrm-reference-architectures/blob/main/modules/compute/main.tf"
click node_storage "https://github.com/sonatype/nxrm-reference-architectures/blob/main/modules/storage/main.tf"
click node_database "https://github.com/sonatype/nxrm-reference-architectures/blob/main/modules/database/main.tf"
click node_user_data "https://github.com/sonatype/nxrm-reference-architectures/blob/main/scripts/templates/user-data.sh.tpl"
click node_nexus_config "https://github.com/sonatype/nxrm-reference-architectures/blob/main/scripts/templates/configure-nexus.sh.tpl"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_operator,node_profiles,node_terraform,node_root_interface,node_state toneBlue
class node_networking,node_iam,node_load_balancer,node_compute,node_storage,node_database,node_aws_apis toneAmber
class node_install_artifacts,node_user_data,node_nexus_config toneMint
class node_clients,node_nexus_nodes,node_blob_store,node_metadata_store toneRose
```

## Components

### Terraform Control Plane

- **Operator**: user
- [Sizing profiles](https://github.com/sonatype/nxrm-reference-architectures/blob/main/tfvars/ra-1-selfmanaged.tfvars): tfvars · Selects standalone through HA topology. · `tfvars/ra-1-selfmanaged.tfvars`
- [Terraform](https://github.com/sonatype/nxrm-reference-architectures/blob/main/main.tf): provisioner · Plans and applies the selected architecture. · `main.tf`
- [Root inputs & outputs](https://github.com/sonatype/nxrm-reference-architectures/blob/main/variables.tf): Terraform interface · Exposes deployment controls and operational endpoints. · `variables.tf`
- **Terraform state**: lifecycle state · Control plane for managed resource lifecycle.

### AWS Infrastructure

- [Networking module](https://github.com/sonatype/nxrm-reference-architectures/blob/main/modules/networking/main.tf): Terraform module · Creates or accepts VPC and public/private subnet topology. · `modules/networking/main.tf`
- [IAM module](https://github.com/sonatype/nxrm-reference-architectures/blob/main/modules/iam/main.tf): Terraform module · Creates node roles and AWS access policies. · `modules/iam/main.tf`
- [ALB module](https://github.com/sonatype/nxrm-reference-architectures/blob/main/modules/loadbalancer/main.tf): Terraform module · Terminates optional TLS and routes traffic to nodes. · `modules/loadbalancer/main.tf`
- [Compute module](https://github.com/sonatype/nxrm-reference-architectures/blob/main/modules/compute/main.tf): Terraform module · Provisions one or more private Nexus EC2 nodes. · `modules/compute/main.tf`
- [Storage module](https://github.com/sonatype/nxrm-reference-architectures/blob/main/modules/storage/main.tf): Terraform module · Selects S3 blobs or single-node EBS/file storage. · `modules/storage/main.tf`
- [Database module](https://github.com/sonatype/nxrm-reference-architectures/blob/main/modules/database/main.tf): Terraform module · Selects H2 standalone or PostgreSQL RDS. · `modules/database/main.tf`
- **AWS APIs**: cloud control plane

### Nexus Bootstrap

- **Nexus installer & license**: deployment artifacts · Operator-supplied installer and optional Pro license.
- [EC2 user-data](https://github.com/sonatype/nxrm-reference-architectures/blob/main/scripts/templates/user-data.sh.tpl): bootstrap template · Installs Nexus and prepares settings, credentials, and mounts. · `scripts/templates/user-data.sh.tpl`
- [Nexus configuration](https://github.com/sonatype/nxrm-reference-architectures/blob/main/scripts/templates/configure-nexus.sh.tpl): bootstrap template · Configures database, blob store, and clustering. · `scripts/templates/configure-nexus.sh.tpl`

### Nexus Runtime

- **Repository clients**: clients
- **Nexus EC2 nodes**: application cluster · Single node or HA cluster based on the profile.
- **Blob storage**: S3 or EBS/file · S3 is required for scalable HA profiles.
- **Metadata database**: H2 or PostgreSQL RDS · RDS PostgreSQL is required for HA profiles.

## Connections

- 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
