Repository navigation
Document dynamic references for sensitive parameters - #137
QuiltSimon wants to merge 1 commit into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Confidence Score: 4/5
[Low impact] The PR changes documentation for Terraform users deploying SSO secrets. The documentation appears safe to merge, with non-blocking improvements to secret creation and access requirements. FindingsReviews (1) · Last reviewed commit: "Document dynamic references for sensitiv..." · Reviewed by Greptile |
| - The identity that runs the stack create/update (or the CloudFormation service role, if | ||
| the stack uses one) needs `secretsmanager:GetSecretValue` on the secret (or | ||
| `ssm:GetParameter` and `kms:Decrypt` for `ssm-secure`). |
There was a problem hiding this comment.
Secret access requirements are incomplete
If a Secrets Manager secret uses a customer-managed KMS key, the deploying identity also needs kms:Decrypt and access through the key's policy. Following the listed permissions alone can leave CloudFormation unable to read the secret. Add these requirements, and note that cross-account secrets also need a secret policy that allows the deploying identity.
| ```bash | ||
| aws secretsmanager create-secret \ | ||
| --name quilt/okta-client-secret \ | ||
| --secret-string 'YOUR-OKTA-CLIENT-SECRET' |
There was a problem hiding this comment.
Replacing this placeholder with a real client secret puts it directly in the shell command. The shell can save it in history, and other local processes may see it in the command's arguments. Show the Secrets Manager console or a protected file passed with --secret-string file://... instead.
How this was verified: The example passes the client secret directly as the --secret-string command-line argument.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
sir-sigurd
left a comment
There was a problem hiding this comment.
I tested this on a minimal stack that reproduces the pattern: a NoEcho parameter Ref'd into an AWS::SecretsManager::Secret's SecretString, which is where the client secret parameters end up (KB). I drove it through the CloudFormation API, not through the Quilt template or Terraform. A {{resolve:secretsmanager:...}} string passed as the parameter value does resolve: the stack's secret held the source value. Two parts don't work as written.
1. ssm-secure is rejected. CreateStack fails with SSM Secure reference is not supported in: [AWS::SecretsManager::Secret/Properties/SecretString]. ssm-secure works only in the properties AWS lists, and SecretString isn't one of them. This affects the ssm-secure example, the ssm:GetParameter/kms:Decrypt part of the first note, and the VARIABLES.md tip.
2. The rotation steps don't pick up the new value. "After rotating, run a stack update" leaves the parameter string unchanged, and with an unchanged string the stack's secret keeps the old value. After rotating the source:
- an update with identical inputs is refused:
No updates are to be performed. - an update that changes only another parameter completes and leaves the secret untouched;
- switching the reference to pin the new version's
version-idreports the secretUPDATE_COMPLETEbut writes no new version.
So the redeploy that follows restarts the registry with the old value. Two changes did write a new version: changing a literal value, and moving a version-id pin from one version to another. AWS flags the unpinned-to-pinned case: "CloudFormation doesn't track which version of a secret was used in previous deployments. … Monitor and validate resource updates when making changes to dynamic reference configurations, such as when transitioning from unversioned to versioned dynamic references, and vice versa." (docs). What rotation flow is this section meant to support?
Smaller:
- The read isn't one-time. CloudTrail logged
GetSecretValueon the source, by the caller, during an update that changed only an unrelated parameter. So the identity running Terraform appears to need access on every stack update, not just the first; I didn't test an update with that access removed. With the source secret deleted, stack delete fails:You can't perform this operation on the secret because it was marked for deletion. aws ecs update-service --force-new-deploymentalso needs--clusterand--service.--secret-string 'YOUR-OKTA-CLIENT-SECRET'leaves the secret in shell history.- Greptile's KMS and cross-account notes hold.
- Pre-existing, not from this PR: state still holds the DB password (inside
DBUrl) andAdminPassword, which the module sets itself, so state stays sensitive with this pattern too.
Customers ask how to keep SSO client secrets out of Terraform code and state. Adds an EXAMPLES.md section showing
{{resolve:secretsmanager:...}}/{{resolve:ssm-secure:...}}on the sensitive parameters, with required permissions and the rotation caveat, plus a pointer from VARIABLES.md. Docs only.Made with Cursor