Skip to content

Commit ed0cf6b

Browse files
test(bootstrap): add dual-config synth-coverage test (agentcore + ecs)
Validates that all resource types in the synthesized CloudFormation template have entries in the resource-action-map. Tests agentcore from existing cdk.out and attempts ECS synth gracefully skipping when AWS credentials are unavailable. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 83099e1 commit ed0cf6b

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

cdk/test/bootstrap/resource-action-map.test.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
* SOFTWARE.
1818
*/
1919

20+
import { execFileSync } from 'node:child_process';
21+
import { readFileSync, existsSync } from 'node:fs';
22+
import { join } from 'node:path';
23+
2024
import { Stack } from 'aws-cdk-lib';
2125

2226
import { allPolicies } from '../../src/bootstrap/policies';
@@ -184,3 +188,48 @@ describe('resource-action-map', () => {
184188
});
185189
});
186190
});
191+
192+
describe('Synth coverage', () => {
193+
const SKIP_TYPES = new Set([
194+
'AWS::CDK::Metadata',
195+
'Custom::AWS',
196+
'Custom::S3AutoDeleteObjects',
197+
'Custom::VpcRestrictDefaultSG',
198+
]);
199+
200+
function getResourceTypes(templatePath: string): string[] {
201+
if (!existsSync(templatePath)) return [];
202+
const template = JSON.parse(readFileSync(templatePath, 'utf-8'));
203+
const resources = template.Resources as Record<string, { Type: string }>;
204+
return [...new Set(Object.values(resources).map(r => r.Type))];
205+
}
206+
207+
it('all agentcore resource types have map entries', () => {
208+
const templatePath = join(__dirname, '..', '..', 'cdk.out', 'backgroundagent-dev.template.json');
209+
const types = getResourceTypes(templatePath);
210+
if (types.length === 0) return;
211+
const unmapped = types.filter(t => !SKIP_TYPES.has(t) && !RESOURCE_ACTION_MAP[t]);
212+
expect(unmapped).toEqual([]);
213+
});
214+
215+
it('all ecs resource types have map entries', () => {
216+
const ecsOutDir = join(__dirname, '..', '..', 'cdk.out.ecs');
217+
const ecsTemplatePath = join(ecsOutDir, 'backgroundagent-dev.template.json');
218+
// Try to synth with ecs config — skip if unavailable (no AWS creds, etc.)
219+
if (!existsSync(ecsTemplatePath)) {
220+
try {
221+
execFileSync('npx', ['cdk', 'synth', '-q', '-c', 'compute_type=ecs', '-o', ecsOutDir], {
222+
cwd: join(__dirname, '..', '..'),
223+
stdio: 'pipe',
224+
timeout: 120000,
225+
});
226+
} catch {
227+
return; // synth unavailable — skip gracefully
228+
}
229+
}
230+
const types = getResourceTypes(ecsTemplatePath);
231+
if (types.length === 0) return;
232+
const unmapped = types.filter(t => !SKIP_TYPES.has(t) && !RESOURCE_ACTION_MAP[t]);
233+
expect(unmapped).toEqual([]);
234+
});
235+
});

0 commit comments

Comments
 (0)