Skip to content
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

Merged
merged 5 commits into from
Dec 14, 2023
Merged

Conversation

lpizzinidev
Copy link
Contributor

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

@github-actions github-actions bot added distinguished-contributor [Pilot] contributed 50+ PRs to the CDK bug This issue is a bug. effort/medium Medium work item – several days of effort p2 labels Dec 8, 2023
@aws-cdk-automation aws-cdk-automation requested a review from a team December 8, 2023 15:04
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Dec 8, 2023
@vinayak-kukreja vinayak-kukreja self-assigned this Dec 8, 2023
Copy link
Contributor

@vinayak-kukreja vinayak-kukreja left a 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) {
Copy link
Contributor

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) {
Copy link
Contributor

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),
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2023-12-08 at 10 32 03 AM

Copy link
Contributor Author

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.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Dec 8, 2023
@mergify mergify bot dismissed vinayak-kukreja’s stale review December 9, 2023 11:19

Pull request has been modified.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Dec 9, 2023
@@ -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';
Copy link
Contributor

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.

@kaizencc kaizencc changed the title fix(secretsmanager): cannot set hourly rotation feat(secretsmanager): set hourly rotation Dec 13, 2023
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a 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.

@kaizencc kaizencc changed the title feat(secretsmanager): set hourly rotation fix(secretsmanager): cannot set hourly rotation Dec 13, 2023
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Dec 13, 2023
@aws-cdk-automation aws-cdk-automation dismissed their stale review December 13, 2023 18:24

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Dec 13, 2023
Copy link
Contributor

@kaizencc kaizencc left a 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.

Comment on lines 153 to 150
if (automaticallyAfterDays !== undefined || scheduleExpression !== undefined) {
rotationRules = {
automaticallyAfterDays,
scheduleExpression,
Copy link
Contributor

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.

@aws-cdk-automation aws-cdk-automation removed pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Dec 13, 2023
@mergify mergify bot dismissed kaizencc’s stale review December 14, 2023 09:17

Pull request has been modified.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Dec 14, 2023
@lpizzinidev lpizzinidev requested a review from kaizencc December 14, 2023 10:51
Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lpizzinidev

Copy link
Contributor

mergify bot commented Dec 14, 2023

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-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Dec 14, 2023
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: f1a3cc9
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 09cb003 into aws:main Dec 14, 2023
12 checks passed
Copy link
Contributor

mergify bot commented Dec 14, 2023

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. distinguished-contributor [Pilot] contributed 50+ PRs to the CDK effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-secretsmanager: Cannot set rotation schedule to be less than a day
4 participants