create_experiment_template
Define AWS Fault Injection Service experiment templates to configure chaos engineering tests with targets, actions, and stop conditions.
Instructions
Create a new AWS FIS experiment template.
Args:
name: Name for the experiment template
description: Description of the experiment template
targets: Dictionary of targets configuration
actions: Dictionary of actions configuration
role_arn: ARN of the IAM role to use for the experiment
stop_conditions: List of stop conditions
region: AWS region to use (default: us-east-1)
Returns:
JSON string containing the created template information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| description | Yes | ||
| targets | Yes | ||
| actions | Yes | ||
| role_arn | Yes | ||
| stop_conditions | Yes | ||
| region | No | us-east-1 |
Implementation Reference
- aws_fis_mcp/tools.py:239-288 (handler)The handler function that implements the core logic of the 'create_experiment_template' tool. It uses the AWS FIS boto3 client to create a new experiment template, handles serialization, and requires write mode to be enabled.@require_write_mode def create_experiment_template( name: str, description: str, targets: Dict[str, Dict[str, Any]], actions: Dict[str, Dict[str, Any]], role_arn: str, stop_conditions: List[Dict[str, Any]], region: str = "us-east-1" ) -> str: """ Create a new AWS FIS experiment template. Args: name: Name for the experiment template description: Description of the experiment template targets: Dictionary of targets configuration actions: Dictionary of actions configuration role_arn: ARN of the IAM role to use for the experiment stop_conditions: List of stop conditions region: AWS region to use (default: us-east-1) Returns: JSON string containing the created template information """ try: fis = boto3.client('fis', region_name=region) response = fis.create_experiment_template( clientToken=str(uuid.uuid4()), description=description, targets=targets, actions=actions, stopConditions=stop_conditions, roleArn=role_arn, tags={'Name': name} ) # Format the response for better readability template = response.get('experimentTemplate', {}) formatted_template = { 'id': template.get('id'), 'description': template.get('description'), 'creationTime': template.get('creationTime').isoformat() if template.get('creationTime') else None, 'tags': template.get('tags', {}) } return json.dumps(formatted_template, indent=2) except Exception as e: return f"Error creating experiment template: {str(e)}"
- aws_fis_mcp/server.py:31-31 (registration)The line where the create_experiment_template tool is registered with the FastMCP server application using the @tool decorator.app.tool()(create_experiment_template)
- aws_fis_mcp/server.py:7-19 (registration)Import statement in server.py that brings in the create_experiment_template function from the tools module for registration.from aws_fis_mcp.tools import ( list_experiment_templates, get_experiment_template, list_experiments, get_experiment, start_experiment, stop_experiment, create_experiment_template, delete_experiment_template, list_action_types, generate_template_example, set_write_mode, )
- aws_fis_mcp/tools.py:19-31 (helper)The require_write_mode decorator applied to the handler, which enforces that write operations are only allowed when explicitly enabled.def require_write_mode(func): """Decorator to require write mode for destructive operations.""" @wraps(func) def wrapper(*args, **kwargs): if not _WRITE_MODE_ENABLED: return json.dumps({ "error": "Write operations are disabled", "message": f"The '{func.__name__}' operation requires write mode. Please restart the server with --allow-writes flag to enable write operations.", "operation": func.__name__, "read_only_mode": True }, indent=2) return func(*args, **kwargs) return wrapper