-
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
feat(scheduler-targets-alpha): InspectorStartAssessmentRun
Target
#27850
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8d713f8
feat(scheduler-targets): InspectorStartAssessmentRun Target
go-to-k 1ae40ba
change an integ test
go-to-k e15ffa1
comment in integ
go-to-k d6810b6
comment in integ
go-to-k 133a802
fix for the review
go-to-k 7d2abdd
fix to remove empty object as props
go-to-k 9bef18e
Merge branch 'main' into feat/scheduler-targets-inspector
go-to-k bcbde6b
Merge branch 'main' of https://github.com/go-to-k/aws-cdk into feat/s…
go-to-k 4cf5364
Update README.md
go-to-k f5c09dd
run integ test and updated the steps
vinayak-kukreja 2cbb82f
Merge branch 'main' into feat/scheduler-targets-inspector
vinayak-kukreja File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
export * from './codebuild-start-build'; | ||
export * from './event-bridge-put-events'; | ||
export * from './target'; | ||
export * from './inspector-start-assessment-run'; | ||
export * from './lambda-invoke'; | ||
export * from './sns-publish'; | ||
export * from './sqs-send-message'; | ||
export * from './stepfunctions-start-execution'; | ||
export * from './sqs-send-message'; | ||
export * from './target'; |
37 changes: 37 additions & 0 deletions
37
packages/@aws-cdk/aws-scheduler-targets-alpha/lib/inspector-start-assessment-run.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { ISchedule, IScheduleTarget } from '@aws-cdk/aws-scheduler-alpha'; | ||
import { Names } from 'aws-cdk-lib'; | ||
import { IRole, PolicyStatement } from 'aws-cdk-lib/aws-iam'; | ||
import { CfnAssessmentTemplate } from 'aws-cdk-lib/aws-inspector'; | ||
import { ScheduleTargetBase, ScheduleTargetBaseProps } from './target'; | ||
import { sameEnvDimension } from './util'; | ||
|
||
/** | ||
* Use an Amazon Inspector as a target for AWS EventBridge Scheduler. | ||
*/ | ||
export class InspectorStartAssessmentRun extends ScheduleTargetBase implements IScheduleTarget { | ||
constructor( | ||
private readonly template: CfnAssessmentTemplate, | ||
private readonly props: ScheduleTargetBaseProps = {}, | ||
) { | ||
super(props, template.attrArn); | ||
} | ||
|
||
protected addTargetActionToRole(schedule: ISchedule, role: IRole): void { | ||
if (!sameEnvDimension(this.template.stack.region, schedule.env.region)) { | ||
throw new Error(`Cannot assign assessment template in region ${this.template.stack.region} to the schedule ${Names.nodeUniqueId(schedule.node)} in region ${schedule.env.region}. Both the schedule and the assessment template must be in the same region.`); | ||
} | ||
|
||
if (!sameEnvDimension(this.template.stack.account, schedule.env.account)) { | ||
throw new Error(`Cannot assign assessment template in account ${this.template.stack.account} to the schedule ${Names.nodeUniqueId(schedule.node)} in account ${schedule.env.region}. Both the schedule and the assessment template must be in the same account.`); | ||
} | ||
|
||
if (this.props.role && !sameEnvDimension(this.props.role.env.account, this.template.stack.account)) { | ||
throw new Error(`Cannot grant permission to execution role in account ${this.props.role.env.account} to invoke target ${Names.nodeUniqueId(this.template.node)} in account ${this.template.stack.account}. Both the target and the execution role must be in the same account.`); | ||
} | ||
|
||
role.addToPrincipalPolicy(new PolicyStatement({ | ||
actions: ['inspector:StartAssessmentRun'], | ||
resources: ['*'], | ||
})); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you please order these alphabetically?