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

feat(scheduler-targets-alpha): InspectorStartAssessmentRun Target #27850

Merged
merged 11 commits into from
Nov 30, 2023

Conversation

go-to-k
Copy link
Contributor

@go-to-k go-to-k commented Nov 6, 2023

This PR adds InspectorStartAssessmentRun Target for EventBridge Scheduler.

In the issue, the inspector.CfnAssessmentTarget is used in the InspectorStartAssessmentRun. But it should be a CfnAssessmentTemplate so I fixed.

  export class InspectorStartAssessmentRun extends ScheduleTargetBase implements IScheduleTarget {
    constructor(
      private readonly target: inspector.CfnAssessmentTarget, // <- here
      private readonly props: ScheduleTargetBaseProps,
    ) {

Closes #27453.


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 effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 star-contributor [Pilot] contributed between 25-49 PRs to the CDK labels Nov 6, 2023
@aws-cdk-automation aws-cdk-automation requested a review from a team November 6, 2023 09:46
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.

@go-to-k go-to-k marked this pull request as ready for review November 6, 2023 12:13
@aws-cdk-automation aws-cdk-automation dismissed their stale review November 6, 2023 12:14

✅ 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 Nov 6, 2023
Copy link
Contributor

@lpizzinidev lpizzinidev left a comment

Choose a reason for hiding this comment

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

Looks good 👍
Just some minor adjustments in my opinion.

export class InspectorStartAssessmentRun extends ScheduleTargetBase implements IScheduleTarget {
constructor(
private readonly template: CfnAssessmentTemplate,
private readonly props: ScheduleTargetBaseProps,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private readonly props: ScheduleTargetBaseProps,
private readonly props: ScheduleTargetBaseProps = {},

Let's provide a default object to simplify constructor initialization.

@@ -27,6 +27,7 @@ The following targets are supported:
1. `targets.LambdaInvoke`: [Invoke an AWS Lambda function](#invoke-a-lambda-function))
2. `targets.StepFunctionsStartExecution`: [Start an AWS Step Function](#start-an-aws-step-function)
3. `targets.CodeBuildStartBuild`: [Start a CodeBuild job](#start-a-codebuild-job)
4. `targets.InspectorStartAssessmentRun`: [Start an Amazon Inspector assessment run](#start-an-aws-inspector-assessment-run)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
4. `targets.InspectorStartAssessmentRun`: [Start an Amazon Inspector assessment run](#start-an-aws-inspector-assessment-run)
4. `targets.InspectorStartAssessmentRun`: [Start an Amazon Inspector assessment run](#start-an-amazon-inspector-assessment-run)

@@ -2,3 +2,4 @@ export * from './target';
export * from './lambda-invoke';
export * from './stepfunctions-start-execution';
export * from './codebuild-start-build';
export * from './inspector-start-assessment-run';
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please order these alphabetically?

@go-to-k
Copy link
Contributor Author

go-to-k commented Nov 7, 2023

@lpizzinidev

Thanks! I changed them.

Copy link
Contributor

@lpizzinidev lpizzinidev left a comment

Choose a reason for hiding this comment

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

Thanks!
Just some minor adjustment after setting a default value for the props parameter and it will be good to go for me.


new Schedule(this, 'Schedule', {
schedule: ScheduleExpression.rate(Duration.minutes(60)),
target: new targets.InspectorStartAssessmentRun(assessmentTemplate, {}),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
target: new targets.InspectorStartAssessmentRun(assessmentTemplate, {}),
target: new targets.InspectorStartAssessmentRun(assessmentTemplate),

Properties are now optional, let's keep the documentation more concise.


new scheduler.Schedule(stack, 'Schedule', {
schedule: scheduler.ScheduleExpression.rate(cdk.Duration.minutes(10)),
target: new InspectorStartAssessmentRun(assessmentTemplate, {}),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
target: new InspectorStartAssessmentRun(assessmentTemplate, {}),
target: new InspectorStartAssessmentRun(assessmentTemplate),

});

test('creates IAM role and IAM policy for inspector assessment template in the same account', () => {
const inspectorTarget = new InspectorStartAssessmentRun(template, {});
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const inspectorTarget = new InspectorStartAssessmentRun(template, {});
const inspectorTarget = new InspectorStartAssessmentRun(template);

Can you please remove the optional parameters here as well? where possible.

@go-to-k
Copy link
Contributor Author

go-to-k commented Nov 7, 2023

@lpizzinidev

Thanks! I missed the modification. I changed.

Copy link
Contributor

@lpizzinidev lpizzinidev left a comment

Choose a reason for hiding this comment

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

Thanks 👍

@aws-cdk-automation aws-cdk-automation added pr/needs-maintainer-review This PR needs a review from a Core Team Member and removed pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Nov 7, 2023
@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

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 @go-to-k , thank you for this contribution.

I have just updated the ReadMe. I ran the integ test and added the information that helped me running these.

@vinayak-kukreja vinayak-kukreja changed the title feat(scheduler-targets): InspectorStartAssessmentRun Target feat(scheduler-targets-alpha): InspectorStartAssessmentRun Target Nov 30, 2023
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

Copy link
Contributor

mergify bot commented Nov 30, 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).

@mergify mergify bot merged commit 073958f into aws:main Nov 30, 2023
14 checks passed
@go-to-k go-to-k deleted the feat/scheduler-targets-inspector branch December 1, 2023 00:56
chenjane-dev pushed a commit to chenjane-dev/aws-cdk that referenced this pull request Dec 5, 2023
…ws#27850)

This PR adds InspectorStartAssessmentRun Target for EventBridge Scheduler.

In [the issue](aws#27453), the `inspector.CfnAssessmentTarget` is used in the `InspectorStartAssessmentRun`. But it should be a `CfnAssessmentTemplate` so I fixed.

```ts
  export class InspectorStartAssessmentRun extends ScheduleTargetBase implements IScheduleTarget {
    constructor(
      private readonly target: inspector.CfnAssessmentTarget, // <- here
      private readonly props: ScheduleTargetBaseProps,
    ) {
```

Closes aws#27453.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 pr/needs-maintainer-review This PR needs a review from a Core Team Member star-contributor [Pilot] contributed between 25-49 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-scheduler-targets-alpha): Add InspectorStartAssessmentRun Target
4 participants