Open nitrocode opened 3 weeks ago
Voting for Prioritization
Volunteering to Work on This Issue
@nitrocode - Are you talking about the 6 random characters after your secret's name? See Docs. This is the actual ARN of your secret and and versions of the secret's value will not change the ARN. The 6 characters would change only if you delete the secret entirely and recreate it (as you mentioned in your description).
For my knowledge, what is your usecase? Why are secrets being deleted and recreated rather than updating their values?
@dimaman2001 the secrets aren't getting recreated. I update the secrets using auto rotation. When the secrets update, the version changes. When the version changes, the policy requires the 6 question marks or the IAM role is unable to retrieve the new secret version.
We have a number of workarounds now to swap out the versioned string to the 6 question marks which works. However it could be easier to set up if it was natively supported instead of needing the above workarounds.
Love this idea!
Suggestion: name the exported property "partial_arn" or similar.
Reasoning: In the GetSecretValue documentation, the secret_id parameter is documented as:
The ARN or name of the secret to retrieve. To retrieve a secret from another account, you must use an ARN. For an ARN, we recommend that you specify a complete ARN rather than a partial ARN.
Where partial arn refers to the "versionless" arn described in this request.
This is as close as I can find for AWS terminology of this form of "arn."
Thanks for the comment
The partial arn sounds like it only has the arn without the specific version but also without the 6 question marks which is needed for iam principals to access all versions of a secret. Unless I'm mistaken?
+ arn = "arn:aws:secretsmanager:us-east-1:123456789012:secret:service/secret-gqLY34"
+ versionless_arn = "arn:aws:secretsmanager:us-east-1:123456789012:secret:service/secret-??????"
+ partial_arn = "arn:aws:secretsmanager:us-east-1:123456789012:secret:service/secret"
I updated the above description to clarify the differences between arn, partial arn, and versionless arn.
Description
When using the data source
aws_secretsmanager_secret
, we get the exact versioned ARN which makes it cumbersome to allow versionless access to these secrets in IAM policies.https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access_iam-policies.html
Here is an example of three workarounds used to replace the last 6 characters with questionmarks so the policy is allowed to retrieve all versions of the secret in secrets manager.
There must be an easier way by adding a new
versionless_arn
outputAffected Resource(s) and/or Data Source(s)
Potential Terraform Configuration
Option 1: data source change
Which should return
Option 2: new function
I spoke with @apparentlymart in slack and he mentioned the following
So perhaps a
secretsmanager_versionless_arn
or similar function?References
Would you like to implement a fix?
No