-
Notifications
You must be signed in to change notification settings - Fork 46
feat(bootstrap): resource-action-map for synth-time validation #165
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
base: main
Are you sure you want to change the base?
Changes from all commits
eeb4f5e
fe1778e
0d7733a
9f9c480
95b154a
71d06a5
7f9886a
a4ea01a
f782707
58ad265
75cfb09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 1.2.0 | ||
| 1.3.0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /** | ||
| * MIT No Attribution | ||
| * | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| * the Software without restriction, including without limitation the rights to | ||
| * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| * the Software, and to permit persons to whom the Software is furnished to do so. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| * SOFTWARE. | ||
| */ | ||
|
|
||
| export { | ||
| RESOURCE_ACTION_MAP, | ||
| getActionsForResource, | ||
| getAllMappedActions, | ||
| } from './resource-action-map'; | ||
| export type { ResourceActions, LifecyclePhase } from './resource-action-map'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /** | ||
| * MIT No Attribution | ||
| * | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| * the Software without restriction, including without limitation the rights to | ||
| * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| * the Software, and to permit persons to whom the Software is furnished to do so. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| * SOFTWARE. | ||
| */ | ||
|
|
||
| /** | ||
| * Verification helpers over the bootstrap resource-action map. | ||
| * | ||
| * This module deliberately holds NO map data. It previously carried a second, | ||
| * parallel copy: this directory's version had CRUD depth but no production | ||
| * consumer, while ``../resource-action-map.ts`` was create-only and wired into | ||
| * the live synth-coverage gate. Two maps with disjoint test suites and no shared | ||
| * consumer drift by construction, and adding a resource type to only one of them | ||
| * is silent. The CRUD depth was merged INTO the live map (#124); what remains | ||
| * here are the query helpers the preflight/validation layer (#125/#126) reads it | ||
| * through. | ||
| */ | ||
|
|
||
| import { | ||
| RESOURCE_ACTION_MAP, | ||
| actionsForResource, | ||
| type ResourceActions, | ||
| } from '../resource-action-map'; | ||
|
|
||
| export { RESOURCE_ACTION_MAP } from '../resource-action-map'; | ||
| export type { ResourceActions, LifecyclePhase } from '../resource-action-map'; | ||
|
|
||
| /** | ||
| * Returns the ResourceActions entry for a given CloudFormation resource type, | ||
| * or undefined if the type is not mapped. | ||
| */ | ||
| export function getActionsForResource(cfnType: string): ResourceActions | undefined { | ||
| return RESOURCE_ACTION_MAP[cfnType]; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the set of all unique IAM actions referenced across all map entries, | ||
| * across every lifecycle phase. | ||
| */ | ||
| export function getAllMappedActions(): Set<string> { | ||
| const actions = new Set<string>(); | ||
| for (const cfnType of Object.keys(RESOURCE_ACTION_MAP)) { | ||
| for (const action of actionsForResource(cfnType)) { | ||
| actions.add(action); | ||
| } | ||
| } | ||
| return actions; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /** | ||
| * MIT No Attribution | ||
| * | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| * the Software without restriction, including without limitation the rights to | ||
| * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| * the Software, and to permit persons to whom the Software is furnished to do so. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| * SOFTWARE. | ||
| */ | ||
|
|
||
| const CORE_POLICIES = [ | ||
| 'infrastructure', | ||
| 'application', | ||
| 'observability', | ||
| ] as const; | ||
|
|
||
| const COMPUTE_VARIANT_POLICIES: Record<string, string[]> = { | ||
| agentcore: ['compute-agentcore'], | ||
| ecs: ['compute-ecs'], | ||
|
scottschreckengaust marked this conversation as resolved.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. B1 (blocking). The ECS gate on |
||
| }; | ||
|
|
||
| export function getRequiredBootstrapPolicies(computeType: string): string[] { | ||
| const base: string[] = [...CORE_POLICIES]; | ||
| const variants = COMPUTE_VARIANT_POLICIES[computeType]; | ||
| if (variants) base.push(...variants); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. B3 — silent under-scoping. An unknown or misspelled compute type falls through to core-only with no error, and |
||
| return base; | ||
| } | ||
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, but please re-derive before granting: the
AWS::SQS::QueuePolicyresources come fromenforceSSL: trueon the queues, not the DLQ redrive policy (redrive is a queue attribute, not a separate resource).enforceSSLemits aDenystatement, whichsqs:AddPermissioncannot express — soSetQueueAttributes, already granted, is presumably what CFN fires, which is whymainhasAWS::SQS::QueuePolicyinCFN_TYPES_WITHOUT_EXEC_ROLE_IAM. Can you confirm from CloudTrail on a real deploy? If it isSetQueueAttributes, the least-privilege answer is to drop both grants and the map entry.