Rotate a cluster secret in AWS PCS
Rotate your cluster secret to comply with security requirements and address potential compromises. This process requires putting your cluster into maintenance mode.
Note
By default, AWS PCS encrypts the cluster secret with an AWS managed key. If you encrypt it with a customer managed key instead, make sure the key policy grants the AWS PCS service-linked role access to the key. Otherwise, AWS PCS can't rotate the secret. For more information, see Use a customer managed key to encrypt the cluster secret.
Prerequisites
-
IAM role with
secretsmanager:RotateSecretpermission -
Cluster in
ACTIVEorUPDATE_FAILEDstate
Procedure
-
Notify cluster users of the upcoming maintenance window.
-
Put the cluster into maintenance mode by scaling all compute node groups to 0 capacity.
-
Use the UpdateComputeNodeGroup API to set both minInstanceCount and maxInstanceCount to 0 for all compute node groups.
-
Wait until all nodes stop.
-
(Optional) Drain scheduler queues with Slurm commands before you terminate capacity for graceful job handling.
Note
Rotation requires zero running instances. If instances are still running when you start rotation, rotation fails with the following error:
All instances must be terminated before you rotate a secret. Set the minimum instance count to 0 to terminate active instances.
Note
A compute node group can report
ACTIVEwhile instances are still terminating during scale-down. It can also reportACTIVEbefore any instance exists during scale-up. Scaling can take several minutes, up to about 30 minutes. While a compute node group isUPDATING,get-compute-node-groupreturns the pre-update scaling values, and AWS PCS refuses further update requests until the update completes. Don't treatACTIVEas confirmation that instances exist. -
-
Initiate rotation through Secrets Manager.
-
Console method:
-
Navigate to Secrets Manager, select your cluster secret, and choose Rotate secret.
-
-
API method:
-
Use Secrets Manager
rotate-secretAPI.
-
-
-
Confirm that rotation succeeded.
Note
The
rotate-secretcall returns HTTP 200 even if rotation later fails. The outcome arrives later, as a separateRotationFailedorRotationSucceededevent. The 200 response only confirms that AWS PCS accepted the request, not that rotation succeeded.-
Run
describe-secretand confirm that theAWSCURRENTstaging label moved to the new version and thatlastRotatedDateupdated. -
Alternatively, wait for a
RotationSucceededevent in AWS CloudTrail.
Note
Use
describe-secretrather thanlist-secret-version-idsto inspect versions.list-secret-version-idscan omit theAWSPENDINGversion even when you specify--include-deprecated. -
-
After successful rotation, restore cluster capacity.
-
Use the UpdateComputeNodeGroup API to reset node groups to desired min/max capacity.
-
For AWS PCS-managed login nodes: No additional action required.
-
For BYO login nodes:
-
Connect to login nodes.
-
Update
/etc/slurm/slurm.keywith the new secret from Secrets Manager. -
Restart the Slurm Auth and Cred Kiosk Daemon (sackd).
-
-
Recover from a stranded pending version
A failed rotation can strand a version at the AWSPENDING staging label and block
later rotations with the following error:
A previous rotation isn't complete. That rotation will be reattempted.
The cancel-rotate-secret command alone doesn't remove the
AWSPENDING staging label, and it sets RotationEnabled to
false. To clear the stranded version, remove the AWSPENDING staging
label from the pending version:
aws secretsmanager update-secret-version-stage \ --secret-idsecret-arn\ --version-stage AWSPENDING \ --remove-from-version-idpending-version-id
Verify the rotation
To confirm that the Slurm controller is reachable and that nodes are healthy, use
scontrol ping and scontrol show nodes. Don't use sinfo to
check a cluster that has no queues, because sinfo shows nothing in that case and
isn't a valid check.
To confirm that nodes use the current key, compare the SHA-256 hash of the base64-decoded
AWSCURRENT secret with the hash of /etc/slurm/slurm.key on the
nodes:
sha256sum /etc/slurm/slurm.key
Compare the node hash against the AWSPREVIOUS version as well to prove that
nodes aren't on a stale key. We recommend that you compare hashes rather than print key
material.