diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3fd3cc4b..7d04a1c8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - variant: [agentcore] + compute_type: [agentcore] outputs: self_mutation_happened: ${{ steps.self_mutation.outputs.self_mutation_happened }} env: @@ -96,7 +96,7 @@ jobs: esac - name: Generate CDK context env: - VARIANT: ${{ matrix.variant }} + COMPUTE_TYPE: ${{ matrix.compute_type }} TAG_SHA: ${{ steps.tags.outputs.sha }} TAG_REF: ${{ steps.tags.outputs.ref }} TAG_REF_TYPE: ${{ steps.tags.outputs.ref-type }} @@ -111,7 +111,7 @@ jobs: TAG_REPOSITORY: ${{ github.repository }} run: | jq -n \ - --arg computeVariant "$VARIANT" \ + --arg compute_type "$COMPUTE_TYPE" \ --arg stackName "backgroundagent-dev" \ --arg sha "$TAG_SHA" \ --arg ref "$TAG_REF" \ @@ -126,7 +126,7 @@ jobs: --arg workflow "$TAG_WORKFLOW" \ --arg repository "$TAG_REPOSITORY" \ '{ - "computeVariant": $computeVariant, + "compute_type": $compute_type, "stackName": $stackName, "github:sha": $sha, "github:ref": $ref, @@ -155,10 +155,10 @@ jobs: run: mise run install - name: build run: mise run build - - name: Upload CDK artifact (${{ matrix.variant }}) + - name: Upload CDK artifact (${{ matrix.compute_type }}) uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: - name: cdk-${{ matrix.variant }}-out + name: cdk-${{ matrix.compute_type }}-out path: | cdk/cdk.out/ cdk/cdk.context.json diff --git a/cdk/src/main.ts b/cdk/src/main.ts index 496cfbd4..bf1c1a45 100644 --- a/cdk/src/main.ts +++ b/cdk/src/main.ts @@ -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', diff --git a/cdk/test/stacks/github-tags.test.ts b/cdk/test/stacks/github-tags.test.ts index a273fa7c..96bd1d44 100644 --- a/cdk/test/stacks/github-tags.test.ts +++ b/cdk/test/stacks/github-tags.test.ts @@ -44,6 +44,9 @@ function synthWithTags(context: Record = {}): 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', @@ -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'); + }); });