-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SecretsManager: is there feature to set a day of week rather that specifying number #31002
Comments
Hey @PreranaAmirapu , thanks for reaching out. Here is a doc explaining variations of cron expressions - https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotate-secrets_schedule.html#rotate-secrets_schedule-cron I ran the below code and it added lambda successfully - # a sample rotation lambda for secret rotation
rotation_lambda = aws_lambda.Function(
self, "RotationLambda",
runtime=aws_lambda.Runtime.PYTHON_3_8,
handler="index.handler",
code=aws_lambda.Code.from_inline("def handler(event, context): return 'Hello, CDK!';"),
)
rotation_lambda.add_permission("SecretRotationPermission",
principal= iam.ServicePrincipal("secretsmanager.amazonaws.com"),
action="lambda:InvokeFunction",
source_arn="arn:aws:secretsmanager:us-east-1:111111111111:secret:testSecret-rn4rW4",
)
cfn_rotation_schedule = secretmanager.CfnRotationSchedule(
self, "RotationSchedule",
secret_id="arn:aws:secretsmanager:us-east-1:111111111111:secret:testSecret-rn4rW4",
rotation_lambda_arn=rotation_lambda.function_arn,
rotation_rules=secretmanager.CfnRotationSchedule.RotationRulesProperty(
schedule_expression="cron(0 8 ? * SUN *)",
)
) Here is a snapshot of this being attached- Let us know if this works! |
my code:
error: even though I have added the above permission , it is not applying |
@PreranaAmirapu , so looks like the code is working ? right ? |
I'm getting this error |
@PreranaAmirapu , this error only indicates that function policy needs to be added which is added in the given code.
aws lambda add-permission
--function-name secrets_manager
--principal secretsmanager.amazonaws.com
--action lambda:InvokeFunction
--statement-id SecretsManagerAccess Replace function name with your lambda function name. Let me know if this works |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Describe the bug
this is the code I have written where it rotates after 7 days , but i want my secret to rotate on sunday only. I have tried below code but it is not working
Expected Behavior
rotate on every sunday
Current Behavior
it is not throwing error but the lambda is not attaching to the secret
Reproduction Steps
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.147.0
Framework Version
No response
Node.js Version
v22.4.1
OS
mac
Language
Python
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: