create_experiment_template
Create AWS FIS experiment templates to define chaos engineering scenarios with targets, actions, and stop conditions for testing system resilience.
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 for the 'create_experiment_template' tool. It is decorated with @require_write_mode and uses boto3 to create an AWS FIS experiment template, returning formatted JSON.@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)Registers the create_experiment_template handler as a tool in the FastMCP server instance.app.tool()(create_experiment_template)
- aws_fis_mcp/tools.py:19-31 (helper)Decorator applied to the handler that enforces write mode requirement, preventing execution unless --allow-writes is 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
- aws_fis_mcp/tools.py:14-18 (helper)Global function to set the write mode flag used by the require_write_mode decorator.def set_write_mode(enabled: bool) -> None: """Set the global write mode.""" global _WRITE_MODE_ENABLED _WRITE_MODE_ENABLED = enabled
- aws_fis_mcp/server.py:14-14 (registration)Import of the create_experiment_template handler from tools module for use in server registration.create_experiment_template,