Guide · Amazon DevOps Guru · Resource Collection

Amazon DevOps Guru Resource Collection for MCP Servers — CloudFormation Stacks, Tags, and UpdateResourceCollection

Amazon DevOps Guru only monitors the AWS resources you explicitly include in its resource collection — there is no account-wide auto-enrollment. Configuring the resource collection correctly determines which of your MCP server's ECS services, Lambda functions, SQS queues, and DynamoDB tables receive ML-powered anomaly detection coverage. This page covers the three collection modes (CloudFormation stacks, tag-based, all resources), the UpdateResourceCollection ADD and REMOVE actions, verifying coverage with GetResourceCollection, the exact tag key DevOps Guru recognizes (devops-guru-resource-collection), and the limits that apply to stack and tag collection. For DevOps Guru concepts and account health, see DevOps Guru Overview. For querying the insights that DevOps Guru generates, see Working with Insights.

TL;DR

Call UpdateResourceCollection with Action: "ADD" and either a CloudFormation.StackNames array (for stack-based coverage) or a Tags array with AppBoundaryKey: "devops-guru-resource-collection" (for tag-based coverage). Call GetResourceCollection with ResourceCollectionType: "AWS_CLOUD_FORMATION" or "AWS_TAGS" to verify what DevOps Guru currently monitors. Stack-based coverage is preferred when your MCP server infrastructure is managed by CloudFormation or CDK — it ties DevOps Guru scope to your deployment unit. Tag-based coverage is preferred for Terraform-managed resources or resources spread across multiple stacks. Remove a stack or tag by calling UpdateResourceCollection with Action: "REMOVE"; DevOps Guru stops generating new insights for removed resources within minutes but historical insights remain queryable.

Collection mode comparison

DevOps Guru supports three mutually compatible collection modes. You can use CloudFormation and tag collection simultaneously — DevOps Guru takes the union of resources from all configured collection sources.

Collection mode How resources are identified Best for MCP server use case Limit
CloudFormation stacks All supported resources within a named CloudFormation stack CDK or CloudFormation deployments — ECS service + SQS queue + DynamoDB table in one stack 500 stacks per account per region
Tag-based Resources tagged with key devops-guru-resource-collection and a matching value Terraform deployments; ad-hoc resources not in a CloudFormation stack; cross-stack groupings 5 tag filters (AppBoundaryKey+TagValues combinations)
All resources All supported resource types in the account and region Dev/test accounts where cost is not a concern; full visibility during initial evaluation No explicit limit; cost grows linearly with resource count

Gotcha — collection modes are regional: DevOps Guru is a regional service. A stack named mcp-server-prod in us-east-1 is a different collection entry than a stack with the same name in eu-west-1. If your MCP server runs in multiple regions, you must configure a DevOps Guru client and resource collection in each region separately.

CloudFormation stack-based collection

Stack-based collection is the simplest and most precise option for teams using CloudFormation or CDK. When you add a stack name, DevOps Guru automatically discovers all supported resources within that stack and begins monitoring them. As the stack is updated (new resources added, old ones removed), DevOps Guru tracks the changes automatically — you do not need to call UpdateResourceCollection again when resources change within an already-enrolled stack.

import {
  DevOpsGuruClient,
  UpdateResourceCollectionCommand,
  GetResourceCollectionCommand,
} from "@aws-sdk/client-devops-guru";

const devopsGuru = new DevOpsGuruClient({ region: process.env.AWS_REGION! });

// Enroll a CloudFormation stack in DevOps Guru monitoring.
// Stack name only — not the full stack ARN.
async function enrollStack(stackName: string): Promise<void> {
  await devopsGuru.send(
    new UpdateResourceCollectionCommand({
      Action: "ADD",
      ResourceCollection: {
        CloudFormation: {
          StackNames: [stackName],
        },
      },
    })
  );
}

// Enroll multiple stacks in a single call (batch up to 500 stack names per region).
async function enrollStacks(stackNames: string[]): Promise<void> {
  // UpdateResourceCollection accepts up to 10 stack names per call.
  // Batch into chunks of 10 for large deployments.
  const chunkSize = 10;
  for (let i = 0; i < stackNames.length; i += chunkSize) {
    const chunk = stackNames.slice(i, i + chunkSize);
    await devopsGuru.send(
      new UpdateResourceCollectionCommand({
        Action: "ADD",
        ResourceCollection: {
          CloudFormation: { StackNames: chunk },
        },
      })
    );
  }
}

// Remove a stack from DevOps Guru coverage.
// DevOps Guru stops generating new insights for the stack's resources
// within minutes; existing insights remain queryable.
async function removeStack(stackName: string): Promise<void> {
  await devopsGuru.send(
    new UpdateResourceCollectionCommand({
      Action: "REMOVE",
      ResourceCollection: {
        CloudFormation: { StackNames: [stackName] },
      },
    })
  );
}

// Verify which CloudFormation stacks are currently enrolled.
async function listEnrolledStacks(): Promise<string[]> {
  const stackNames: string[] = [];
  let nextToken: string | undefined;

  do {
    const { ResourceCollection, NextToken } = await devopsGuru.send(
      new GetResourceCollectionCommand({
        ResourceCollectionType: "AWS_CLOUD_FORMATION",
        NextToken: nextToken,
      })
    );

    const names = ResourceCollection?.CloudFormation?.StackNames ?? [];
    stackNames.push(...names);
    nextToken = NextToken;
  } while (nextToken);

  return stackNames;
}

Gotcha — stack names, not ARNs: UpdateResourceCollection accepts the stack name (e.g., mcp-server-prod), not the full stack ARN. Passing an ARN string causes a validation error. The stack must exist in the same region as the DevOps Guru client.

Gotcha — nested stacks are not automatically included: If your CDK app creates a parent stack that contains nested stacks, DevOps Guru only monitors resources in the parent stack directly — it does not recursively descend into nested stacks. Enroll each nested stack explicitly by its name.

Tag-based collection

Tag-based collection monitors resources that have the tag key devops-guru-resource-collection with any value you specify in the TagValues array. This is the right choice for Terraform-managed MCP server infrastructure, resources created outside CloudFormation, or when you want to group resources from multiple stacks under a single DevOps Guru scope (for example, an ECS service in one stack and its DynamoDB session store in a separate shared-services stack).

import {
  UpdateResourceCollectionCommand,
  GetResourceCollectionCommand,
} from "@aws-sdk/client-devops-guru";

// The tag KEY that DevOps Guru recognizes is fixed — always
// "devops-guru-resource-collection". The tag VALUE is your
// application boundary name (e.g., "mcp-server-prod").
const DEVOPS_GURU_TAG_KEY = "devops-guru-resource-collection";

// Add tag-based collection for resources tagged with
// devops-guru-resource-collection=mcp-server-prod.
async function enrollTagBasedCollection(
  appBoundaryValues: string[]
): Promise<void> {
  await devopsGuru.send(
    new UpdateResourceCollectionCommand({
      Action: "ADD",
      ResourceCollection: {
        Tags: [
          {
            AppBoundaryKey: DEVOPS_GURU_TAG_KEY,
            TagValues: appBoundaryValues, // e.g., ["mcp-server-prod", "mcp-server-staging"]
          },
        ],
      },
    })
  );
}

// Verify current tag-based collection config.
async function listTagCollectionFilters(): Promise<
  Array<{ appBoundaryKey: string; tagValues: string[] }>
> {
  const filters: Array<{ appBoundaryKey: string; tagValues: string[] }> = [];
  let nextToken: string | undefined;

  do {
    const { ResourceCollection, NextToken } = await devopsGuru.send(
      new GetResourceCollectionCommand({
        ResourceCollectionType: "AWS_TAGS",
        NextToken: nextToken,
      })
    );

    for (const tag of ResourceCollection?.Tags ?? []) {
      filters.push({
        appBoundaryKey: tag.AppBoundaryKey!,
        tagValues: tag.TagValues ?? [],
      });
    }
    nextToken = NextToken;
  } while (nextToken);

  return filters;
}

Applying the tag to MCP server resources

Apply the tag to each AWS resource you want DevOps Guru to monitor. For Terraform:

# Terraform example — tag ECS service and SQS queue
resource "aws_ecs_service" "mcp_server" {
  name            = "mcp-server"
  # ... other config ...

  tags = {
    "devops-guru-resource-collection" = "mcp-server-prod"
  }
}

resource "aws_sqs_queue" "tool_queue" {
  name = "mcp-tool-queue"

  tags = {
    "devops-guru-resource-collection" = "mcp-server-prod"
  }
}

For CloudFormation / CDK:

// CDK — apply devops-guru-resource-collection tag to all constructs
// under the stack using Tags.of() to apply recursively.
import * as cdk from "aws-cdk-lib";
import { Construct } from "constructs";

export class McpServerStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    // ... define ECS service, SQS queue, Lambda, DynamoDB table ...

    // Apply the DevOps Guru tag to all resources in this stack.
    cdk.Tags.of(this).add(
      "devops-guru-resource-collection",
      "mcp-server-prod"
    );
  }
}

Gotcha — tag propagation delay: When you tag a resource and add the corresponding AppBoundaryKey/TagValues to DevOps Guru's collection, it takes up to 15 minutes for DevOps Guru to discover newly tagged resources and begin ingesting their metrics. Do not expect immediate coverage after tagging.

Gotcha — ECS services require the tag on the service, not the task definition: DevOps Guru resolves ECS coverage from the ECS service resource, not from the task definition. Apply the devops-guru-resource-collection tag to the aws_ecs_service (Terraform) or CfnService (CDK) resource, not to the task definition.

Gotcha — 5 tag filter limit: DevOps Guru supports a maximum of 5 tag filter combinations (AppBoundaryKey + TagValues arrays) per account per region. Each filter can include multiple tag values. If you have more than 5 application boundaries, consolidate tag values into fewer filters rather than creating separate filters per environment.

Practical MCP server coverage example

A production MCP server deployment typically spans several resources. Here is a complete example of configuring DevOps Guru to cover a Terraform-managed MCP server stack using tag-based collection:

// Infrastructure setup: apply tags to all MCP server resources.
// Run this Terraform apply BEFORE calling enrollTagBasedCollection.
// Resources: ECS Fargate service, SQS tool queue, DynamoDB session store,
//            Lambda tool handler, API Gateway HTTP API.

// DevOps Guru enrollment script (run once during initial setup or via
// your infrastructure provisioning pipeline).
async function enrollMcpServerProduction(): Promise<void> {
  const APP_BOUNDARY_VALUE = "mcp-server-prod";

  // Step 1: Enroll the tag-based collection.
  await devopsGuru.send(
    new UpdateResourceCollectionCommand({
      Action: "ADD",
      ResourceCollection: {
        Tags: [
          {
            AppBoundaryKey: "devops-guru-resource-collection",
            TagValues: [APP_BOUNDARY_VALUE],
          },
        ],
      },
    })
  );
  console.log(
    `DevOps Guru tag collection enrolled for value: ${APP_BOUNDARY_VALUE}`
  );

  // Step 2: Verify coverage (wait up to 15 min for new resources to appear).
  const filters = await listTagCollectionFilters();
  console.log("Current tag filters:", JSON.stringify(filters, null, 2));

  // Step 3: Check account health to confirm resources are being analyzed.
  const { OpenReactiveInsights, OpenProactiveInsights, ResourceHours } =
    await devopsGuru.send(new DescribeAccountHealthCommand({}));

  console.log("Account health after enrollment:");
  console.log("  Open reactive insights:", OpenReactiveInsights);
  console.log("  Open proactive insights:", OpenProactiveInsights);
  // ResourceHours will be 0 until metrics begin accumulating.
  console.log("  Resource-hours this month:", ResourceHours);
}

The resources DevOps Guru will find and monitor (assuming they are tagged with devops-guru-resource-collection=mcp-server-prod):

Removing resources from collection

To stop DevOps Guru from monitoring a set of resources, call UpdateResourceCollection with Action: "REMOVE". DevOps Guru stops generating new insights for the removed resources within minutes. Existing insights generated before the removal remain queryable via ListInsights until they expire (insights are retained for 90 days after closing).

// Remove a CloudFormation stack from DevOps Guru coverage.
async function removeStackCoverage(stackName: string): Promise<void> {
  await devopsGuru.send(
    new UpdateResourceCollectionCommand({
      Action: "REMOVE",
      ResourceCollection: {
        CloudFormation: { StackNames: [stackName] },
      },
    })
  );
  console.log(`Stack ${stackName} removed from DevOps Guru monitoring.`);
}

// Remove a tag-based filter entirely by removing the AppBoundaryKey+TagValues
// combination. After removal, resources with that tag are no longer monitored.
async function removeTagBasedCoverage(
  appBoundaryValue: string
): Promise<void> {
  await devopsGuru.send(
    new UpdateResourceCollectionCommand({
      Action: "REMOVE",
      ResourceCollection: {
        Tags: [
          {
            AppBoundaryKey: "devops-guru-resource-collection",
            TagValues: [appBoundaryValue],
          },
        ],
      },
    })
  );
}

When to remove resources: Remove stacks or tag filters when you decommission an MCP server environment. Leaving deleted stacks in the resource collection does not cause errors (DevOps Guru simply finds no resources in a deleted stack), but it clutters the GetResourceCollection output and may prevent you from adding new stacks if you approach the 500-stack limit.

Failure patterns table

Error / symptom Root cause Fix
AccessDeniedException on first UpdateResourceCollection Missing iam:CreateServiceLinkedRole permission for devops-guru.amazonaws.com Add iam:CreateServiceLinkedRole to the calling principal's policy, or pre-create the service-linked role with aws iam create-service-linked-role
Stack added successfully but no insights after 48 hours Stack contains no supported resource types, or resources have insufficient CloudWatch metric history (<24h) Confirm ECS/Lambda/SQS/DynamoDB resources are in the stack; ensure the stack has been running for at least 24h with normal traffic
GetResourceCollection returns empty StackNames after UpdateResourceCollection ADD Collection update is eventually consistent — takes up to 60 seconds to reflect Wait 60 seconds and retry GetResourceCollection
Tag-based resources not appearing after tagging Tag propagation and DevOps Guru discovery takes up to 15 minutes; tag applied to task definition instead of ECS service Wait 15 minutes; verify tag is on the ECS service resource (not task definition)
ValidationException: stack name looks like an ARN Passing full stack ARN instead of stack name to CloudFormation.StackNames Use stack name only (e.g., mcp-server-prod), not arn:aws:cloudformation:...
No proactive insights after weeks of monitoring Proactive insights require at least 2 weeks of continuous metric history; insufficient baseline or traffic too low to train ML model Ensure consistent traffic (synthetic if necessary); proactive insights are only generated for metrics with meaningful variance, not flat-line metrics