IAM database authentication is the right default and it changes how you connect. With it enabled, there are no database users and no passwords - every request must be signed with AWS Signature Version 4, using credentials from an IAM role. The implications: the authorisation policy lives in IAM rather than in the database; credentials rotate automatically with the instance role; and there is nothing to leak in a configuration file.
The cost is that your client must sign requests, which means either a library that does it or a signing wrapper, and that curl and plain drivers stop working without one. This is the main friction people hit, and it is worth accepting rather than disabling IAM authentication.
IAM policy actions for Neptune are coarser than DynamoDB's. neptune-db:connect grants connection; neptune-db:ReadDataViaQuery, WriteDataViaQuery and DeleteDataViaQuery separate read, write and delete. There is no label-level, vertex-level or property-level authorisation - so fine-grained access control is your application's responsibility, and a design that needs it must say how. Condition keys allow some scoping, including by query language.
Without IAM authentication, the cluster has no authentication at all - anyone who can reach port 8182 inside the VPC can read and write everything. So the security posture is: IAM authentication on, or the VPC and security group are your only control. State which, explicitly.
The VPC is the boundary and it does real work. Security groups should allow 8182 only from the application's security group, not from a CIDR. A VPC endpoint for S3 is needed for the bulk loader and keeps that traffic off the internet. There is no public endpoint to accidentally expose, which is a genuine security advantage over several services in this programme.
TLS is mandatory - Neptune requires HTTPS and ssl=true on WebSocket connections, and this cannot be disabled on current engine versions. KMS encrypts storage at rest, and the choice of an AWS-managed or customer-managed key must be made at cluster creation; it cannot be added later, and nor can it be removed.
Audit logging writes every query to CloudWatch Logs when enabled via the parameter group and the cluster's log exports. It is the only record of who ran what, and because IAM authentication means the caller is an IAM principal, the audit log is genuinely attributable - which is one of the better security properties here.
Monitoring. The Neptune-specific set: BufferCacheHitRatio (the graph in memory - the closest analogue to Neo4j's page cache ratio and important for the same reason), MainRequestQueuePendingRequestsCount (backpressure), NumConnections against the instance limit, requests per second and errors by language, NeptuneReplicaLag and its maximum, ServerlessDatabaseCapacity against the configured range, CPU and freeable memory, and the gremlin/openCypher/sparql Http5xx and ClientErrors counts separately, because a rising client-error rate is usually a deployment that shipped an unsupported query.
Capacity and cost. Provisioned instances are billed per instance-hour by class, which is predictable and wastes money when idle. Serverless bills by Neptune Capacity Unit-hour between a configured minimum and maximum, scales over minutes, and has a minimum you pay for continuously - so Serverless is not free when idle, and a low minimum is both the cheapest idle cost and the slowest to absorb a spike. Plus storage per GB-month, I/O per million requests, backup storage beyond the cluster size, and data transfer. The decision: Serverless for variable or unknown load and for development; provisioned when the load is steady and the saving is material - and the way to decide is to run both and compare, which the laboratory does.
Laboratory exercise 6 - make it defensible.
Define the cluster, subnet group, security groups, parameter group and IAM roles as infrastructure as code, and deploy it.
Enable IAM database authentication. Then demonstrate what it replaces: with IAM authentication disabled, connect from another instance in the VPC with no credentials and read and write data. Do this in an isolated lab VPC. Then enable it and show the same connection refused.
Implement least privilege: a role with connect and ReadDataViaQuery only; a role with read and write but not delete; and a role with no Neptune access that can read CloudWatch. Test every denial.
Then demonstrate the granularity limit: show that you cannot restrict a role to one vertex label, and document the application-layer design that compensates.
Configure a customer-managed KMS key at cluster creation, and record that it cannot be changed afterwards.
Enable audit logging and demonstrate that a query is attributable to an IAM principal.
Configure monitoring with every metric above and a threshold for each, including a buffer cache ratio alert and a client-error alert.
Then run the capacity comparison: the same workload on a provisioned instance and on Serverless, recording cost, latency and the scaling behaviour, and produce a cost model with a recommendation.
Deliverable: the infrastructure as code, the unauthenticated-access demonstration, the IAM policies, a test script attempting every forbidden operation with its output, the granularity limitation documented, the KMS configuration, the attributable audit log entry, the alert definitions, and the capacity comparison with a costed recommendation.
# ==================================================================
# *** IAM DATABASE AUTHENTICATION: no users, no passwords, every
# *** request SIGNED. ***
# ==================================================================
# aws neptune modify-db-cluster \
# --db-cluster-identifier identity-graph \
# --enable-iam-database-authentication --apply-immediately
#
# WITH IT ON:
# * NO database users, NO passwords
# * every request SIGNED with AWS SIGNATURE VERSION 4
# * the policy lives in IAM, not in the database
# * credentials ROTATE AUTOMATICALLY with the instance role
# * *** THERE IS NOTHING TO LEAK IN A CONFIGURATION FILE ***
#
# THE COST: your client must SIGN. curl and plain drivers STOP
# WORKING without a signing wrapper:
# # python
# from gremlin_python.driver import client
# from botocore.auth import SigV4Auth
# from botocore.awsrequest import AWSRequest
# # ... sign the request and pass the headers, or use a library
# # that does it (requests-aws4auth for HTTP endpoints)
#
# awscurl --service neptune-db --region eu-west-2 \
# -X POST https://identity-graph.cluster-abc...:8182/openCypher \
# -d 'query=MATCH (n) RETURN count(n)'
#
# *** THIS IS THE MAIN FRICTION PEOPLE HIT, and it is worth
# *** ACCEPTING RATHER THAN DISABLING IAM AUTHENTICATION. ***
# ==================================================================
# *** WITHOUT IAM AUTH, THE CLUSTER HAS NO AUTHENTICATION AT ALL. ***
# ==================================================================
# Anyone who can reach port 8182 inside the VPC can READ AND WRITE
# EVERYTHING. There are no database users to create.
#
# DEMONSTRATE IT, IN AN ISOLATED LAB VPC: disable IAM auth, connect
# from another instance in the VPC with NO CREDENTIALS, and read and
# write. Then enable it and show the same connection refused:
# {"code":"AccessDeniedException",
# "detailedMessage":"Missing Authentication Token"}
#
# SO THE SECURITY POSTURE IS: *** IAM AUTHENTICATION ON, OR THE VPC
# *** AND SECURITY GROUP ARE YOUR ONLY CONTROL. *** State which,
# explicitly, in the security review.
# ==================================================================
# IAM POLICIES: coarser than DynamoDB's.
# ==================================================================
# A read-only role:
# { "Version": "2012-10-17", "Statement": [{
# "Effect": "Allow",
# "Action": ["neptune-db:connect",
# "neptune-db:ReadDataViaQuery"],
# "Resource": "arn:aws:neptune-db:eu-west-2:111122223333:cluster-ABCDEF/*"
# }]}
#
# Read and write, NOT delete:
# "Action": ["neptune-db:connect",
# "neptune-db:ReadDataViaQuery",
# "neptune-db:WriteDataViaQuery"]
# -- and no DeleteDataViaQuery. That is the granularity you get.
#
# Scoped by QUERY LANGUAGE, which is occasionally useful:
# "Condition": {"StringEquals": {"neptune-db:QueryLanguage": "SPARQL"}}
#
# *** THE GRANULARITY LIMIT: THERE IS NO LABEL-LEVEL, VERTEX-LEVEL
# *** OR PROPERTY-LEVEL AUTHORISATION. *** Unlike Neo4j Enterprise,
# you cannot say "this role cannot traverse :Account" or "cannot
# read .email".
#
# SO FINE-GRAINED ACCESS CONTROL IS YOUR APPLICATION'S
# RESPONSIBILITY, and a design that needs it must SAY HOW:
# * an API layer that constructs only permitted queries, or
# * separate clusters per tenant or sensitivity level, or
# * accepting that every caller sees everything
# Demonstrate the limitation in the lab, then document the
# compensating design and its weakness.
# VERIFY THE DENIALS - every one must fail:
# read-only role: a write query -> AccessDeniedException
# read/write role: a delete query -> AccessDeniedException
# no-Neptune role: any query -> AccessDeniedException
# any role: modify-db-cluster -> AccessDeniedException
# ==================================================================
# THE VPC IS THE BOUNDARY, and it does real work.
# ==================================================================
# security group: allow 8182 FROM THE APPLICATION'S SECURITY
# GROUP, not from a CIDR:
# aws ec2 authorize-security-group-ingress \
# --group-id sg-neptune --protocol tcp --port 8182 \
# --source-group sg-application
#
# AN S3 VPC ENDPOINT for the bulk loader, which also keeps that
# traffic OFF THE INTERNET:
# aws ec2 create-vpc-endpoint --vpc-id vpc-abc123 \
# --service-name com.amazonaws.eu-west-2.s3 \
# --route-table-ids rtb-abc123
#
# *** AND THERE IS NO PUBLIC ENDPOINT TO ACCIDENTALLY EXPOSE ***,
# which is a genuine security advantage over several services in
# this programme. The "we left it open to the internet" failure
# mode is structurally unavailable here.
# ==================================================================
# TLS and KMS
# ==================================================================
# TLS IS MANDATORY. HTTPS only, and ssl=true on WebSocket. It
# cannot be disabled on current engine versions.
#
# KMS encrypts storage at rest, and *** THE KEY CHOICE IS MADE AT
# *** CLUSTER CREATION. It cannot be added later, and it cannot be
# *** REMOVED later either. ***
# --storage-encrypted --kms-key-id arn:aws:kms:...:key/abcd-1234
# A customer-managed key gives you rotation, an audit trail of key
# use, and the ability to make the data unreadable by revoking it.
# ==================================================================
# AUDIT LOGGING: the only record of who ran what - and it is
# ATTRIBUTABLE.
# ==================================================================
# parameter group: neptune_enable_audit_log = 1
# cluster: --enable-cloudwatch-logs-exports audit
#
# -> every query, to CloudWatch Logs
#
# *** AND BECAUSE IAM AUTHENTICATION MEANS THE CALLER IS AN IAM
# *** PRINCIPAL, THE AUDIT LOG IS GENUINELY ATTRIBUTABLE *** - which
# is one of the better security properties here, and the reason to
# prefer IAM auth beyond credential hygiene. Demonstrate it: run a
# query as a named role and find the principal in the log.
#
# aws logs filter-log-events \
# --log-group-name /aws/neptune/identity-graph/audit \
# --filter-pattern 'DeleteDataViaQuery'
# ==================================================================
# MONITORING: the Neptune-specific set.
# ==================================================================
# *** BufferCacheHitRatio < 99.9% -> the working set does
# not fit, and every hop becomes a storage read. The closest
# analogue to Neo4j's page cache ratio, important for the same
# reason, and ONE OF THE FEW NEPTUNE PROBLEMS MONEY FIXES. ***
# *** MainRequestQueuePendingRequestsCount > 0 sustained ->
# BACKPRESSURE: too few connections, too small an instance, or
# too many concurrent queries. ***
# NumConnections vs the instance limit
# GremlinRequestsPerSec / OpenCypherRequestsPerSec / SparqlRequestsPerSec
# *** GremlinHttp5xx vs GremlinClientErrors - SEPARATELY. A rising
# CLIENT error rate is usually A DEPLOYMENT THAT SHIPPED AN
# UNSUPPORTED QUERY (Module 3), not an infrastructure problem,
# and conflating the two sends you looking in the wrong place. ***
# NeptuneReplicaLag / NeptuneReplicaLagMaximum
# ServerlessDatabaseCapacity vs the configured range
# CPUUtilization, FreeableMemory
# VolumeBytesUsed storage growth
# LoaderRequestsPerSec during a bulk load
#
# aws cloudwatch put-metric-alarm --alarm-name neptune-buffer-cache \
# --metric-name BufferCacheHitRatio --namespace AWS/Neptune \
# --statistic Average --period 300 --threshold 99.9 \
# --comparison-operator LessThanThreshold --evaluation-periods 3
# ==================================================================
# CAPACITY AND COST: run both, then decide.
# ==================================================================
# PROVISIONED
# per INSTANCE-HOUR by class (db.r6g.large, db.r6g.xlarge, ...)
# + PREDICTABLE
# - WASTES MONEY WHEN IDLE
#
# SERVERLESS
# per NEPTUNE CAPACITY UNIT-HOUR, between a configured min and max
# + scales to the load
# - *** SCALES OVER MINUTES, so it does not absorb a spike ***
# - *** YOU PAY THE MINIMUM CONTINUOUSLY: SERVERLESS IS NOT FREE
# WHEN IDLE. *** A low minimum is both the cheapest idle cost
# AND the slowest to absorb a spike - that is the trade, and
# it is a single number you choose.
#
# PLUS, for both:
# storage per GB-month
# I/O per million requests <- easy to forget, and on
# a scan-heavy workload
# it is not small
# backup beyond the cluster size
# data transfer cross-AZ and out
#
# THE DECISION: Serverless for VARIABLE OR UNKNOWN load and for
# DEVELOPMENT; PROVISIONED when the load is STEADY and the saving
# is MATERIAL.
#
# *** AND THE WAY TO DECIDE IS TO RUN BOTH AND COMPARE ***, which
# is the laboratory:
# workload provisioned r6g.large serverless 1-8 NCU
# monthly cost $______ $______
# p99 steady ___ ms ___ ms
# p99 during a spike ___ ms ___ ms
# idle cost $______ $______
# Then recommend one, with the numbers.
Discussion
No questions on this topic yet. Sign in to ask the first one.