-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
fix(secretsmanager): cannot set hourly rotation #28303
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @lpizzinidev , thank you for the contribution. Just some minor comments :)
let automaticallyAfterDays: number | undefined; | ||
let scheduleExpression: string | undefined; | ||
if (props.automaticallyAfter) { | ||
if (props.automaticallyAfter.toMilliseconds() > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
props.automaticallyAfter.toMilliseconds()
I think this is repeating and we can keep this as a variable.
if (props.automaticallyAfter.toMilliseconds() > Duration.days(1000).toMilliseconds()) { | ||
throw new Error(`automaticallyAfter must not be greater than 1000 days, got ${props.automaticallyAfter.toDays()} days`); | ||
} | ||
if (props.automaticallyAfter.toHours() > 23) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: How about >=24
, just easier to interpret for me. Thoughts?
@@ -21,6 +21,7 @@ class TestStack extends cdk.Stack { | |||
handler: 'index.handler', | |||
code: lambda.Code.fromInline('NOOP'), | |||
}), | |||
automaticallyAfter: cdk.Duration.hours(4), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running the integ test to verify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, I see the integ test fails due to the schedule not working. I still see the schedule is at 30 days.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't update tree.json
, should be good now.
Pull request has been modified.
@@ -2,6 +2,7 @@ import { Construct } from 'constructs'; | |||
import { ISecret, Secret } from './secret'; | |||
import { CfnRotationSchedule } from './secretsmanager.generated'; | |||
import * as ec2 from '../../aws-ec2'; | |||
import { Schedule } from '../../aws-events'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AHhhh I suppose this is ok because the schedule is not exposed in anyway, but we STILL need to get this into class into core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, long term we need to get schedule
into core so we can use that instead of using the one in aws-events.
if (automaticallyAfterDays !== undefined || scheduleExpression !== undefined) { | ||
rotationRules = { | ||
automaticallyAfterDays, | ||
scheduleExpression, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lpizzinidev I don't like this implementation because we are returning both automaticallyAfterDays
and scheduleExpression
knowing full well that one is undefined. We're then relying on this information elsewhere, which is okay for now, but is an assumption we'll have to maintain forever.
Instead, I think we should just localize on scheduleExpression
. We can keep the automaticallyAfter
prop, but wire it to scheduleExpression
all the time. We can specify rate(5 days)
if we get a unit in days, or rate(4 hours)
if the unit is in hours.
scheduleExpression
can do everything automaticallyAfterDays
can do, and more, so lets standardize on that.
Pull request has been modified.
2942018
to
6467667
Compare
6467667
to
66413dc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @lpizzinidev
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Allows to set hourly rotation up to 4 hours on secrets as per official docs.
Closes #28261.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license