Skip to content

feat(bedrock-agentcore-alpha): allow tagging service-created runtime application log group#37997

Open
gingeekrishna wants to merge 8 commits into
aws:mainfrom
gingeekrishna:fix/37983-application-log-group-tags
Open

feat(bedrock-agentcore-alpha): allow tagging service-created runtime application log group#37997
gingeekrishna wants to merge 8 commits into
aws:mainfrom
gingeekrishna:fix/37983-application-log-group-tags

Conversation

@gingeekrishna
Copy link
Copy Markdown

@gingeekrishna gingeekrishna commented May 25, 2026

Issue # (if applicable)

Closes #37983.


Adds applicationLogGroupTags to RuntimeProps so users can apply tags to the AgentCore-managed CloudWatch Log Group at /aws/bedrock-agentcore/runtimes/{agentRuntimeId}-DEFAULT.

Because the log group is provisioned by the AgentCore service (not by CloudFormation), CDK cannot tag it via the runtime resource itself. When applicationLogGroupTags is provided, CDK pre-creates the log group with RemovalPolicy.RETAIN so the required tags are present from the first runtime invocation onward.

Reason for this change

The AgentCore service automatically creates a CloudWatch Log Group at /aws/bedrock-agentcore/runtimes/{agentRuntimeId}-DEFAULT for runtime application logs. The existing RuntimeProps.tags only tags the AWS::BedrockAgentCore::Runtime resource itself — there is no supported way to tag this service-created log group through CDK.

This is a blocker in environments that enforce mandatory resource tags for PII data isolation, cost allocation, retention/compliance automation, or access governance.

Description of changes

  • Added applicationLogGroupTags?: { [key: string]: string } to RuntimeProps.
  • When the prop is provided and non-empty, the Runtime constructor pre-creates a AWS::Logs::LogGroup with:
    • logGroupName computed from the runtime's AgentRuntimeId CloudFormation attribute (no hardcoding).
    • RemovalPolicy.RETAIN so logs are preserved if the stack is deleted.
    • Tags applied via Tags.of(logGroup).add(key, value).
  • Reuses the existing validateTags() method for consistent key/value validation.
  • When the prop is absent or empty, no extra resource is created — zero impact on existing stacks.
  • JSDoc documents the orphaned log group risk when a runtime is replaced and its agentRuntimeId changes.
  • README updated with usage example and retention behaviour note.

Describe any new or updated permissions being added

None. The execution role already has logs:CreateLogGroup and related permissions scoped to /aws/bedrock-agentcore/runtimes/*.

Description of how you validated changes

Added 5 unit tests under describe('Runtime applicationLogGroupTags tests'):

  1. Log group is synthesized with the correct Fn::Join-based name and all specified tags in a single assertion (avoids false positives from separate resource matches).
  2. No log group created when prop is omitted.
  3. No log group created when prop is {}.
  4. ValidationError thrown for an aws:-prefixed tag key.
  5. DeletionPolicy: Retain / UpdateReplacePolicy: Retain verified.

Integration test added at test/agentcore/runtime/integ.runtime-application-log-group-tags.ts. Snapshot generation requires a full build pipeline (blocked locally due to environment constraints) — see exemption request below.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

…application log group

Adds `applicationLogGroupTags` to `RuntimeProps` so users can apply tags to
the AgentCore-managed CloudWatch Log Group at
`/aws/bedrock-agentcore/runtimes/{agentRuntimeId}-DEFAULT`.

Because the log group is provisioned by the AgentCore service (not by
CloudFormation), CDK cannot tag it via the runtime resource itself. When
`applicationLogGroupTags` is provided, CDK pre-creates the log group with
`RemovalPolicy.RETAIN` so the required tags are present from the first
runtime invocation onward.

fixes aws#37983
Copilot AI review requested due to automatic review settings May 25, 2026 17:51
@github-actions github-actions Bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2 labels May 25, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for tagging the AgentCore runtime application CloudWatch Log Group by pre-creating it in CDK when tags are provided.

Changes:

  • Introduces applicationLogGroupTags prop on RuntimeProps and creates a /aws/bedrock-agentcore/runtimes/{agentRuntimeId}-DEFAULT log group with RemovalPolicy.RETAIN.
  • Applies user-specified tags to the pre-created log group.
  • Adds unit tests covering creation/non-creation, invalid tag keys, and retain policies.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/@aws-cdk/aws-bedrock-agentcore-alpha/lib/runtime/runtime.ts Adds a new runtime prop and pre-creates/tag the application log group with retain policy.
packages/@aws-cdk/aws-bedrock-agentcore-alpha/test/agentcore/runtime/runtime.test.ts Adds tests validating log group creation, tagging behavior, validation, and retention.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter fails with the following errors:

❌ Features must contain a change to an integration test file and the resulting snapshot.

If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.

✅ A exemption request has been requested. Please wait for a maintainer's review.

@gingeekrishna
Copy link
Copy Markdown
Author

Exemption Request
The failing check (pr-triage-manager) is caused by a pre-existing infrastructure issue in aws-github-ops/aws-issue-triage-manager@main using deprecated set-output commands (unrelated to this PR's changes). Tracked upstream: aws-github-ops/aws-issue-triage-manager#42

@aws-cdk-automation aws-cdk-automation added the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label May 25, 2026
…nLogGroupTags

- Combine LogGroupName and Tags assertions into a single hasResourceProperties
  call to prevent false positives from separate resource matches (Copilot review)
- Expand JSDoc to document orphaned log group risk on runtime replacement (Copilot review)
- Add README section with usage example and retention behaviour note
- Add integration test for applicationLogGroupTags feature
@gingeekrishna
Copy link
Copy Markdown
Author

Exemption Request

  1. Integration test snapshot: The integ test file (integ.runtime-application-log-group-tags.ts) has been added. Snapshot generation requires a full build pipeline (the aws-bedrockagentcore generated L1 files are not present in the local environment). Unit tests provide comprehensive coverage of all synthesis paths. Requesting exemption for the snapshot until a maintainer can run the integ runner.

  2. pr-triage-manager pipeline failure: Caused by a pre-existing infrastructure issue in aws-github-ops/aws-issue-triage-manager@main using deprecated set-output commands — unrelated to this PR. Tracked upstream: Replace deprecated set-output usage with GITHUB_OUTPUT environment files aws-github-ops/aws-issue-triage-manager#42

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

Comment thread packages/@aws-cdk/aws-bedrock-agentcore-alpha/README.md Outdated
… comments

- README: remove unused agentcore import from code example
- integ test: update header comment to match actual test intent and add
  listTagsForResource assertion to verify log group tags after deployment
- unit tests: extract shared App/Stack/artifact setup into beforeEach to
  eliminate repeated boilerplate across test cases
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread packages/@aws-cdk/aws-bedrock-agentcore-alpha/README.md
…ogGroupTags

- Add migration caveat to RuntimeProps JSDoc warning about ResourceAlreadyExistsException when adding applicationLogGroupTags to an existing runtime whose log group was already created by the service
- Add same migration caveat to README documentation
- Rename test 'fails when...' to 'Should throw when...' for consistency with other tests in the describe block
@gingeekrishna gingeekrishna requested a review from Copilot May 26, 2026 05:48
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread packages/@aws-cdk/aws-bedrock-agentcore-alpha/lib/runtime/runtime.ts Outdated
Comment thread packages/@aws-cdk/aws-bedrock-agentcore-alpha/README.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment on lines +161 to +162
* **Retention behaviour**: the pre-created log group always uses
* `RemovalPolicy.RETAIN`. This means:
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread packages/@aws-cdk/aws-bedrock-agentcore-alpha/lib/runtime/runtime.ts Outdated
…omments

- Rename JSDoc heading 'Retention behaviour' to 'Removal behavior' with clarifying note distinguishing RemovalPolicy from CloudWatch Logs retention period
- Extract Tags.of() outside loop in constructor to avoid repeated tag-manager lookup
- Rephrase README wording: Tags.of(runtime) does not propagate to service-created log group
- Replace brittle resourceCountIs('AWS::Logs::LogGroup', 0) assertions with targeted checks that filter by bedrock-agentcore name pattern
- Loosen error-message regex from exact-quote match to case-insensitive substring match
- Append ':*' suffix to log group ARN in integ test to match CloudWatch Logs ARN format expected by listTagsForResource
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2 pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(aws-bedrock-agentcore-alpha): allow tagging service-created runtime application log group

4 participants