|
| 1 | +import { AccessLevelList } from '../../shared/access-level'; |
| 2 | +import { PolicyStatement, Operator } from '../../shared'; |
| 3 | + |
| 4 | +/** |
| 5 | + * Statement provider for service [application-signals-mcp](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncloudwatchapplicationsignalsmcpserver.html). |
| 6 | + * |
| 7 | + * @param sid [SID](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_sid.html) of the statement |
| 8 | + */ |
| 9 | +export class ApplicationSignalsMcp extends PolicyStatement { |
| 10 | + public servicePrefix = 'application-signals-mcp'; |
| 11 | + |
| 12 | + /** |
| 13 | + * Statement provider for service [application-signals-mcp](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncloudwatchapplicationsignalsmcpserver.html). |
| 14 | + * |
| 15 | + * @param sid [SID](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_sid.html) of the statement |
| 16 | + */ |
| 17 | + constructor(sid?: string) { |
| 18 | + super(sid); |
| 19 | + } |
| 20 | + |
| 21 | + /** |
| 22 | + * Grants permission to invoke read-only Application Signals MCP tools (list_monitored_services, get_service_detail, query_service_metrics, list_service_operations, get_slo, list_slos, search_transaction_spans, query_sampled_traces, list_slis, get_enablement_guide, list_change_events, list_group_services, audit_group_health, get_group_dependencies, get_group_changes, list_grouping_attribute_definitions, audit_services, audit_slos, audit_service_operations, analyze_canary_failures) |
| 23 | + * |
| 24 | + * Access Level: Read |
| 25 | + * |
| 26 | + * https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Application-Signals.html |
| 27 | + */ |
| 28 | + public toCallReadOnlyTool() { |
| 29 | + return this.to('CallReadOnlyTool'); |
| 30 | + } |
| 31 | + |
| 32 | + /** |
| 33 | + * Grants permission to connect to and interact with the Application Signals MCP server (initialize, list tools, list resources, list prompts) |
| 34 | + * |
| 35 | + * Access Level: Read |
| 36 | + * |
| 37 | + * https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Application-Signals.html |
| 38 | + */ |
| 39 | + public toInvokeMcp() { |
| 40 | + return this.to('InvokeMcp'); |
| 41 | + } |
| 42 | + |
| 43 | + protected accessLevelList: AccessLevelList = { |
| 44 | + Read: [ |
| 45 | + 'CallReadOnlyTool', |
| 46 | + 'InvokeMcp' |
| 47 | + ] |
| 48 | + }; |
| 49 | + |
| 50 | + /** |
| 51 | + * Adds a resource of type mcp-server to the statement |
| 52 | + * |
| 53 | + * https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Application-Signals.html |
| 54 | + * |
| 55 | + * @param resourceName - Identifier for the resourceName. |
| 56 | + * @param account - Account of the resource; defaults to `*`, unless using the CDK, where the default is the current Stack's account. |
| 57 | + * @param region - Region of the resource; defaults to `*`, unless using the CDK, where the default is the current Stack's region. |
| 58 | + * @param partition - Partition of the AWS account [aws, aws-cn, aws-us-gov]; defaults to `aws`, unless using the CDK, where the default is the current Stack's partition. |
| 59 | + * |
| 60 | + * Possible conditions: |
| 61 | + * - .ifAwsResourceTag() |
| 62 | + */ |
| 63 | + public onMcpServer(resourceName: string, account?: string, region?: string, partition?: string) { |
| 64 | + return this.on(`arn:${ partition ?? this.defaultPartition }:application-signals-mcp:${ region ?? this.defaultRegion }:${ account ?? this.defaultAccount }:mcp-server/${ resourceName }`); |
| 65 | + } |
| 66 | + |
| 67 | + /** |
| 68 | + * Filters access by tag key-value pairs attached to the resource |
| 69 | + * |
| 70 | + * https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-resourcetag |
| 71 | + * |
| 72 | + * Applies to resource types: |
| 73 | + * - mcp-server |
| 74 | + * |
| 75 | + * @param tagKey The tag key to check |
| 76 | + * @param value The value(s) to check |
| 77 | + * @param operator Works with [string operators](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html#Conditions_String). **Default:** `StringLike` |
| 78 | + */ |
| 79 | + public ifAwsResourceTag(tagKey: string, value: string | string[], operator?: Operator | string) { |
| 80 | + return this.if(`aws:ResourceTag/${ tagKey }`, value, operator ?? 'StringLike'); |
| 81 | + } |
| 82 | +} |
0 commit comments