tag_pipeline_resource
Add or update tags for AWS CodePipeline resources to organize, track costs, and manage access control across pipeline components.
Instructions
Add or update tags for a pipeline resource
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pipelineName | Yes | Name of the pipeline | |
| tags | Yes | List of tags to add or update |
Implementation Reference
- src/tools/tag_pipeline_resource.ts:36-75 (handler)The main handler function that executes the tool logic: retrieves pipeline ARN and applies tags using AWS CodePipeline SDK.export async function tagPipelineResource( codePipelineManager: CodePipelineManager, input: { pipelineName: string; tags: Array<{ key: string; value: string }>; } ) { const { pipelineName, tags } = input; const codepipeline = codePipelineManager.getCodePipeline(); // First, get the pipeline ARN const pipelineResponse = await codepipeline.getPipeline({ name: pipelineName }).promise(); const resourceArn = pipelineResponse.metadata?.pipelineArn; if (!resourceArn) { throw new Error(`Could not find ARN for pipeline: ${pipelineName}`); } // Tag the resource await codepipeline.tagResource({ resourceArn, tags: tags.map(tag => ({ key: tag.key, value: tag.value })) }).promise(); return { content: [ { type: "text", text: JSON.stringify({ message: "Pipeline resource tagged successfully", resourceArn, tags }, null, 2), }, ], }; }
- Input schema definition for the tag_pipeline_resource tool, specifying pipelineName and tags array.export const tagPipelineResourceSchema = { name: "tag_pipeline_resource", description: "Add or update tags for a pipeline resource", inputSchema: { type: "object", properties: { pipelineName: { type: "string", description: "Name of the pipeline" }, tags: { type: "array", description: "List of tags to add or update", items: { type: "object", properties: { key: { type: "string", description: "Tag key" }, value: { type: "string", description: "Tag value" } }, required: ["key", "value"] } } }, required: ["pipelineName", "tags"], }, } as const;
- src/index.ts:110-128 (registration)Registration of the tool schema in the list of available tools returned by ListToolsRequest handler.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ listPipelinesSchema, getPipelineStateSchema, listPipelineExecutionsSchema, approveActionSchema, retryStageSchema, triggerPipelineSchema, getPipelineExecutionLogsSchema, stopPipelineExecutionSchema, // Add new tool schemas getPipelineDetailsSchema, tagPipelineResourceSchema, createPipelineWebhookSchema, getPipelineMetricsSchema, ], }; });
- src/index.ts:195-200 (registration)Dispatch registration mapping tool name to handler function in the CallToolRequest handler switch statement.case "tag_pipeline_resource": { return await tagPipelineResource(codePipelineManager, input as { pipelineName: string; tags: Array<{ key: string; value: string }>; }); }