-
Notifications
You must be signed in to change notification settings - Fork 91
feat(toolkit-lib): validate command #1508
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
80d4a5e
feat(toolkit): validate command
kaizencc c5ec73e
chore: tests
kaizencc fedcdd7
chore: self mutation
github-actions[bot] cba71a4
refactor(toolkit): use schema types from cloud-assembly-schema for va…
kaizencc 15f2989
test(toolkit): improve validate test coverage
kaizencc b3352c5
chore(toolkit): cleanup validate method style
kaizencc a13e1c8
chore(toolkit): use friendlier validation messages with emojis
kaizencc 437ad34
refactor(toolkit): align validate with new schema types from PR #1515
kaizencc d94c288
chore(toolkit): address review feedback on validate method
kaizencc 4520aab
refactor(toolkit): use Manifest.loadValidationReport for schema-valid…
kaizencc a77be5f
chore(toolkit): use human-friendly messages for validate
kaizencc 152e026
fix(toolkit): add version field to validation report test fixtures
kaizencc 85e1659
chore: self mutation
github-actions[bot] 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 hidden or 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 hidden or 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
33 changes: 33 additions & 0 deletions
33
packages/@aws-cdk/toolkit-lib/lib/actions/validate/index.ts
This file contains hidden or 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,33 @@ | ||
| import type { PolicyValidationReportJson, PolicyValidationReportConclusion, PluginReportJson } from '@aws-cdk/cloud-assembly-schema'; | ||
| import type { StackSelector } from '../../api/cloud-assembly'; | ||
|
|
||
| export interface ValidateOptions { | ||
| /** | ||
| * Select the stacks to validate | ||
| */ | ||
| readonly stacks?: StackSelector; | ||
| } | ||
|
|
||
| /** | ||
| * The result of the validate action | ||
| */ | ||
| export interface ValidateResult { | ||
| /** | ||
| * Whether validation passed or failed overall. | ||
| * 'success' if no plugins reported failures (or no plugins ran). | ||
| * 'failure' if any plugin reported a failure. | ||
| */ | ||
| readonly conclusion: PolicyValidationReportConclusion; | ||
|
|
||
| /** | ||
| * The title of the validation report | ||
| */ | ||
| readonly title?: string; | ||
|
|
||
| /** | ||
| * Reports from each validation plugin | ||
| */ | ||
| readonly pluginReports: PluginReportJson[]; | ||
| } | ||
|
|
||
| export type { PolicyValidationReportJson, PolicyValidationReportConclusion, PluginReportJson }; |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -22,4 +22,5 @@ export type ToolkitAction = | |
| | 'refactor' | ||
| | 'diagnose' | ||
| | 'orphan' | ||
| | 'flags'; | ||
| | 'flags' | ||
| | 'validate'; | ||
This file contains hidden or 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
9 changes: 9 additions & 0 deletions
9
...it-lib/test/_fixtures/stack-with-malformed-validation-report/cdk.out/Stack1.template.json
This file contains hidden or 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,9 @@ | ||
| { | ||
| "Resources": { | ||
| "MyBucketF68F3FF0": { | ||
| "Type": "AWS::S3::Bucket", | ||
| "UpdateReplacePolicy": "Retain", | ||
| "DeletionPolicy": "Retain" | ||
| } | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
...k/toolkit-lib/test/_fixtures/stack-with-malformed-validation-report/cdk.out/manifest.json
This file contains hidden or 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,21 @@ | ||
| { | ||
| "version": "53.0.0", | ||
| "artifacts": { | ||
| "Stack1": { | ||
| "type": "aws:cloudformation:stack", | ||
| "environment": "aws://123456789012/us-east-1", | ||
| "properties": { | ||
| "templateFile": "Stack1.template.json", | ||
| "terminationProtection": false, | ||
| "validateOnSynth": false | ||
| }, | ||
| "displayName": "Stack1" | ||
| }, | ||
| "Tree": { | ||
| "type": "cdk:tree", | ||
| "properties": { | ||
| "file": "tree.json" | ||
| } | ||
| } | ||
| } | ||
| } |
4 changes: 4 additions & 0 deletions
4
...st/_fixtures/stack-with-malformed-validation-report/cdk.out/policy-validation-report.json
This file contains hidden or 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,4 @@ | ||
| { | ||
| "title": "Validation Report", | ||
| "someUnexpectedField": true | ||
| } |
17 changes: 17 additions & 0 deletions
17
...s-cdk/toolkit-lib/test/_fixtures/stack-with-malformed-validation-report/cdk.out/tree.json
This file contains hidden or 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,17 @@ | ||
| { | ||
| "version": "tree-0.1", | ||
| "tree": { | ||
| "id": "App", | ||
| "path": "", | ||
| "children": { | ||
| "Stack1": { | ||
| "id": "Stack1", | ||
| "path": "Stack1", | ||
| "constructInfo": { | ||
| "fqn": "aws-cdk-lib.Stack", | ||
| "version": "0.0.0" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
...dk/toolkit-lib/test/_fixtures/stack-with-no-title-validation/cdk.out/Stack1.template.json
This file contains hidden or 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,9 @@ | ||
| { | ||
| "Resources": { | ||
| "MyBucketF68F3FF0": { | ||
| "Type": "AWS::S3::Bucket", | ||
| "UpdateReplacePolicy": "Retain", | ||
| "DeletionPolicy": "Retain" | ||
| } | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
.../@aws-cdk/toolkit-lib/test/_fixtures/stack-with-no-title-validation/cdk.out/manifest.json
This file contains hidden or 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,21 @@ | ||
| { | ||
| "version": "53.0.0", | ||
| "artifacts": { | ||
| "Stack1": { | ||
| "type": "aws:cloudformation:stack", | ||
| "environment": "aws://123456789012/us-east-1", | ||
| "properties": { | ||
| "templateFile": "Stack1.template.json", | ||
| "terminationProtection": false, | ||
| "validateOnSynth": false | ||
| }, | ||
| "displayName": "Stack1" | ||
| }, | ||
| "Tree": { | ||
| "type": "cdk:tree", | ||
| "properties": { | ||
| "file": "tree.json" | ||
| } | ||
| } | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
...t-lib/test/_fixtures/stack-with-no-title-validation/cdk.out/policy-validation-report.json
This file contains hidden or 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,17 @@ | ||
| { | ||
| "version": "1.0.0", | ||
| "pluginReports": [ | ||
| { | ||
| "pluginName": "TestPlugin", | ||
| "conclusion": "failure", | ||
| "violations": [ | ||
| { | ||
| "ruleName": "no-public-buckets", | ||
| "description": "S3 Buckets must not be publicly accessible", | ||
| "severity": "error", | ||
| "violatingConstructs": [] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
17 changes: 17 additions & 0 deletions
17
...ages/@aws-cdk/toolkit-lib/test/_fixtures/stack-with-no-title-validation/cdk.out/tree.json
This file contains hidden or 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,17 @@ | ||
| { | ||
| "version": "tree-0.1", | ||
| "tree": { | ||
| "id": "App", | ||
| "path": "", | ||
| "children": { | ||
| "Stack1": { | ||
| "id": "Stack1", | ||
| "path": "Stack1", | ||
| "constructInfo": { | ||
| "fqn": "aws-cdk-lib.Stack", | ||
| "version": "0.0.0" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
...cdk/toolkit-lib/test/_fixtures/stack-with-passing-validation/cdk.out/Stack1.template.json
This file contains hidden or 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,9 @@ | ||
| { | ||
| "Resources": { | ||
| "MyBucketF68F3FF0": { | ||
| "Type": "AWS::S3::Bucket", | ||
| "UpdateReplacePolicy": "Retain", | ||
| "DeletionPolicy": "Retain" | ||
| } | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
...s/@aws-cdk/toolkit-lib/test/_fixtures/stack-with-passing-validation/cdk.out/manifest.json
This file contains hidden or 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,21 @@ | ||
| { | ||
| "version": "53.0.0", | ||
| "artifacts": { | ||
| "Stack1": { | ||
| "type": "aws:cloudformation:stack", | ||
| "environment": "aws://123456789012/us-east-1", | ||
| "properties": { | ||
| "templateFile": "Stack1.template.json", | ||
| "terminationProtection": false, | ||
| "validateOnSynth": false | ||
| }, | ||
| "displayName": "Stack1" | ||
| }, | ||
| "Tree": { | ||
| "type": "cdk:tree", | ||
| "properties": { | ||
| "file": "tree.json" | ||
| } | ||
| } | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
...it-lib/test/_fixtures/stack-with-passing-validation/cdk.out/policy-validation-report.json
This file contains hidden or 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,12 @@ | ||
| { | ||
| "version": "1.0.0", | ||
| "title": "Validation Report", | ||
| "pluginReports": [ | ||
| { | ||
| "pluginName": "TestPlugin", | ||
| "pluginVersion": "1.0.0", | ||
| "conclusion": "success", | ||
| "violations": [] | ||
| } | ||
| ] | ||
| } |
17 changes: 17 additions & 0 deletions
17
packages/@aws-cdk/toolkit-lib/test/_fixtures/stack-with-passing-validation/cdk.out/tree.json
This file contains hidden or 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,17 @@ | ||
| { | ||
| "version": "tree-0.1", | ||
| "tree": { | ||
| "id": "App", | ||
| "path": "", | ||
| "children": { | ||
| "Stack1": { | ||
| "id": "Stack1", | ||
| "path": "Stack1", | ||
| "constructInfo": { | ||
| "fqn": "aws-cdk-lib.Stack", | ||
| "version": "0.0.0" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
...-cdk/toolkit-lib/test/_fixtures/stack-with-validation-report/cdk.out/Stack1.template.json
This file contains hidden or 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,9 @@ | ||
| { | ||
| "Resources": { | ||
| "MyBucketF68F3FF0": { | ||
| "Type": "AWS::S3::Bucket", | ||
| "UpdateReplacePolicy": "Retain", | ||
| "DeletionPolicy": "Retain" | ||
| } | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
...es/@aws-cdk/toolkit-lib/test/_fixtures/stack-with-validation-report/cdk.out/manifest.json
This file contains hidden or 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,21 @@ | ||
| { | ||
| "version": "53.0.0", | ||
| "artifacts": { | ||
| "Stack1": { | ||
| "type": "aws:cloudformation:stack", | ||
| "environment": "aws://123456789012/us-east-1", | ||
| "properties": { | ||
| "templateFile": "Stack1.template.json", | ||
| "terminationProtection": false, | ||
| "validateOnSynth": false | ||
| }, | ||
| "displayName": "Stack1" | ||
| }, | ||
| "Tree": { | ||
| "type": "cdk:tree", | ||
| "properties": { | ||
| "file": "tree.json" | ||
| } | ||
| } | ||
| } | ||
| } |
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.
Should be an artifact in the manifest, no?
Although I can live with this for a bit.
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.
https://github.com/orgs/aws/projects/178/views/44?pane=issue&itemId=189647151
i tracked it and will do it separately