Skip to content

fix: name_prefix, tag propagation, external role support, MCP example#172

Open
Sagargupta16 wants to merge 4 commits intoaws-ia:mainfrom
Sagargupta16:fix/module-improvements
Open

fix: name_prefix, tag propagation, external role support, MCP example#172
Sagargupta16 wants to merge 4 commits intoaws-ia:mainfrom
Sagargupta16:fix/module-improvements

Conversation

@Sagargupta16
Copy link
Copy Markdown

What

Four fixes in one PR (can split if preferred):

  1. Fix name_prefix not affecting resource names (name_prefix for module doesn't affect random prefix #170)

    • name_prefix variable existed but was ignored — resources always used random_string.solution_prefix
    • Introduced local.solution_prefix that uses name_prefix when set, falling back to random string
    • Changed default from "BedrockAgents" to null (preserving random prefix behavior for existing users)
  2. Fix create_agent_role for external role support (Can't reuse already created role #169)

    • When passing agent_resource_role_arn from another resource, the ARN isn't known at plan time
    • Terraform fails with "count cannot be determined until apply"
    • Added create_agent_role boolean (default: true) to replace null-check in count expressions
    • Ref: Terraform docs on count limitations
  3. Propagate default tags to awscc_* resources (Default tags are being ignored, subresources are not getting tags applied. #168)

    • AWS provider default_tags only apply to aws_* resources, not awscc_* (CloudControl)
    • Added merged tag locals that combine var.tags with resource-specific tag variables
    • var.tags now propagates to agents, aliases, knowledge bases, and custom models
  4. Add MCP integration example (MCP Support #106)

    • New examples/agent-with-mcp/ showing Bedrock agent + MCP tools via Lambda action group
    • Documentation explaining the MCP + Bedrock architecture pattern
    • Links to official MCP spec and AWS MCP server implementations

Why

These are 4 of the top-reported issues, all currently unassigned:

References

The `name_prefix` variable was defined but never used for resource names
in main.tf. Resources always used `random_string.solution_prefix.result`
regardless of what `name_prefix` was set to.

Introduce `local.solution_prefix` that uses `name_prefix` when provided,
falling back to the random string when null. Update all resource names
in main.tf and IAM role prefix in iam.tf to use this local.

Change `name_prefix` default from "BedrockAgents" to null so the random
prefix is generated by default (preserving existing behavior for users
who don't set name_prefix).

Closes aws-ia#170
…al roles

When passing `agent_resource_role_arn` from another resource (e.g.,
`aws_iam_role.bedrock_agent_role.arn`), the value is not known until
apply time. This causes Terraform to fail with:

  "The count value depends on resource attributes that cannot be
  determined until apply"

Add a `create_agent_role` boolean variable (default: true) that users
set to false when providing an external role ARN. This replaces the
null-check on `agent_resource_role_arn` in count expressions, which
resolves the apply-time dependency.

Ref: https://developer.hashicorp.com/terraform/language/meta-arguments/count#values-not-known-during-planning

Closes aws-ia#169
AWS provider `default_tags` only apply to `aws_*` resources, not to
`awscc_*` (CloudControl) resources used by this module for agents,
aliases, knowledge bases, and guardrails.

Add merged tag locals that combine the base `tags` variable with
resource-specific tag variables. This ensures tags set in `var.tags`
propagate to all resources, while resource-specific overrides still
take precedence.

Update `var.tags` default from null to {} and improve description to
explain the tag merging behavior.

Closes aws-ia#168

Ref: https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block
Add example showing how to create a Bedrock agent with MCP (Model
Context Protocol) tool integration via Lambda-based action groups.

Includes:
- Terraform configuration for agent + action group
- Documentation explaining MCP + Bedrock architecture
- Links to official MCP spec and AWS MCP server implementations
- Usage example with name_prefix and tags

MCP enables standardized tool integration for AI agents. Bedrock agents
can leverage MCP through Lambda functions that translate between
Bedrock's action group format and MCP tool calls.

Ref: https://modelcontextprotocol.io/
Ref: https://github.com/awslabs/mcp

Addresses aws-ia#106
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant