Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/build.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions cdk/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ const stack = new AgentStack(
},
);

const computeType = app.node.tryGetContext('compute_type') ?? 'agentcore';
Tags.of(stack).add('compute_type', computeType);

const githubTagKeys = [
'sha',
'ref',
Expand Down
24 changes: 24 additions & 0 deletions cdk/test/stacks/github-tags.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ function synthWithTags(context: Record<string, string> = {}): Template {
env: { account: '123456789012', region: 'us-east-1' },
});

const computeType = app.node.tryGetContext('compute_type') ?? 'agentcore';
Tags.of(stack).add('compute_type', computeType);

const githubTagKeys = [
'sha', 'ref', 'ref-type', 'actor', 'head-ref',
'base-ref', 'pr-number', 'run-id', 'run-attempt',
Expand Down Expand Up @@ -125,4 +128,25 @@ describe('github:* resource tags', () => {
expect(tags.find(t => t.Key === 'github:sha')!.Value).toBe('none');
expect(tags.find(t => t.Key === 'github:head-ref')!.Value).toBe('none');
});

test('compute_type tag defaults to "agentcore" when no context is provided', () => {
const resources = templateWithDefaults.findResources('AWS::DynamoDB::Table');
const firstResource = Object.values(resources)[0];
const tags: Array<{ Key: string; Value: string }> = firstResource?.Properties?.Tags ?? [];

const tag = tags.find(t => t.Key === 'compute_type');
expect(tag).toBeDefined();
expect(tag!.Value).toBe('agentcore');
});

test('compute_type tag reflects context value when provided', () => {
const template = synthWithTags({ compute_type: 'ecs' });
const resources = template.findResources('AWS::DynamoDB::Table');
const firstResource = Object.values(resources)[0];
const tags: Array<{ Key: string; Value: string }> = firstResource?.Properties?.Tags ?? [];

const tag = tags.find(t => t.Key === 'compute_type');
expect(tag).toBeDefined();
expect(tag!.Value).toBe('ecs');
});
});