Skip to content

Commit 63a01b0

Browse files
feat(bootstrap): add getRequiredBootstrapPolicies for compute-type-aware policy selection
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1e2d05c commit 63a01b0

3 files changed

Lines changed: 81 additions & 0 deletions

File tree

cdk/src/bootstrap/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@
1919

2020
export { infrastructurePolicy, applicationPolicy, observabilityPolicy, allPolicies } from './policies';
2121
export { BOOTSTRAP_VERSION, computeBootstrapHash } from './version';
22+
export { getRequiredBootstrapPolicies } from './required-policies';
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* MIT No Attribution
3+
*
4+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
* the Software without restriction, including without limitation the rights to
8+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
* the Software, and to permit persons to whom the Software is furnished to do so.
10+
*
11+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17+
* SOFTWARE.
18+
*/
19+
20+
const CORE_POLICIES = [
21+
'infrastructure',
22+
'application',
23+
'observability',
24+
'compute-agentcore',
25+
] as const;
26+
27+
const COMPUTE_VARIANT_POLICIES: Record<string, string[]> = {
28+
ecs: ['compute-ecs'],
29+
};
30+
31+
export function getRequiredBootstrapPolicies(computeType: string): string[] {
32+
const base: string[] = [...CORE_POLICIES];
33+
const variants = COMPUTE_VARIANT_POLICIES[computeType];
34+
if (variants) base.push(...variants);
35+
return base;
36+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* MIT No Attribution
3+
*
4+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
* the Software without restriction, including without limitation the rights to
8+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
* the Software, and to permit persons to whom the Software is furnished to do so.
10+
*
11+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17+
* SOFTWARE.
18+
*/
19+
20+
import { getRequiredBootstrapPolicies } from '../../src/bootstrap/required-policies';
21+
22+
describe('getRequiredBootstrapPolicies', () => {
23+
it('returns core policies plus compute-agentcore for default', () => {
24+
const result = getRequiredBootstrapPolicies('agentcore');
25+
expect(result).toEqual(['infrastructure', 'application', 'observability', 'compute-agentcore']);
26+
});
27+
28+
it('includes compute-ecs when compute type is ecs', () => {
29+
const result = getRequiredBootstrapPolicies('ecs');
30+
expect(result).toContain('compute-ecs');
31+
expect(result).toContain('compute-agentcore');
32+
});
33+
34+
it('always includes compute-agentcore regardless of type', () => {
35+
const result = getRequiredBootstrapPolicies('ecs');
36+
expect(result).toContain('compute-agentcore');
37+
});
38+
39+
it('returns core policies for unknown compute type', () => {
40+
const result = getRequiredBootstrapPolicies('unknown');
41+
expect(result).toEqual(['infrastructure', 'application', 'observability', 'compute-agentcore']);
42+
expect(result).not.toContain('compute-ecs');
43+
});
44+
});

0 commit comments

Comments
 (0)