Skip to content

create_experiment_template async

create_experiment_template(
    client_token: ClientToken,
    description: ExperimentTemplateDescription,
    stop_conditions: CreateExperimentTemplateStopConditionInputList,
    actions: CreateExperimentTemplateActionInputMap,
    role_arn: RoleArn,
    *,
    config_overrides: Optional[AsyncfisClientConfig] = None,
    targets: Optional[CreateExperimentTemplateTargetInputMap] = None,
    tags: Optional[TagMap] = None,
    log_configuration: Optional[CreateExperimentTemplateLogConfigurationInput] = None,
    experiment_options: Optional[CreateExperimentTemplateExperimentOptionsInput] = None,
    experiment_report_configuration: Optional[
        CreateExperimentTemplateReportConfigurationInput
    ] = None,
) -> CreateExperimentTemplateResponse

Creates an experiment template.

An experiment template includes the following components:

  • Targets: A target can be a specific resource in your Amazon Web Services environment, or one or more resources that match criteria that you specify, for example, resources that have specific tags.

  • Actions: The actions to carry out on the target. You can specify multiple actions, the duration of each action, and when to start each action during an experiment.

  • Stop conditions: If a stop condition is triggered while an experiment is running, the experiment is automatically stopped. You can define a stop condition as a CloudWatch alarm.

For more information, see experiment templates in the Fault Injection Service User Guide.

Parameters:

Raises:

Source code in docs_src/capo_fis/_services/async_fis.py
async def create_experiment_template(
    self,
    client_token: "capo_fis.types.client_token.ClientToken",
    description: "capo_fis.types.experiment_template_description.ExperimentTemplateDescription",
    stop_conditions: "capo_fis.types.create_experiment_template_stop_condition_input_list.CreateExperimentTemplateStopConditionInputList",
    actions: "capo_fis.types.create_experiment_template_action_input_map.CreateExperimentTemplateActionInputMap",
    role_arn: "capo_fis.types.role_arn.RoleArn",
    *,
    config_overrides: Optional[AsyncfisClientConfig] = None,
    targets: Optional[
        "capo_fis.types.create_experiment_template_target_input_map.CreateExperimentTemplateTargetInputMap"
    ] = None,
    tags: Optional["capo_fis.types.tag_map.TagMap"] = None,
    log_configuration: Optional[
        "capo_fis.types.create_experiment_template_log_configuration_input.CreateExperimentTemplateLogConfigurationInput"
    ] = None,
    experiment_options: Optional[
        "capo_fis.types.create_experiment_template_experiment_options_input.CreateExperimentTemplateExperimentOptionsInput"
    ] = None,
    experiment_report_configuration: Optional[
        "capo_fis.types.create_experiment_template_report_configuration_input.CreateExperimentTemplateReportConfigurationInput"
    ] = None,
) -> "capo_fis.types.create_experiment_template_response.CreateExperimentTemplateResponse":
    """<p>Creates an experiment template. </p> <p>An experiment template includes the following components:</p> <ul> <li> <p> <b>Targets</b>: A target can be a specific resource in your Amazon Web Services environment, or one or more resources that match criteria that you specify, for example, resources that have specific tags.</p> </li> <li> <p> <b>Actions</b>: The actions to carry out on the target. You can specify multiple actions, the duration of each action, and when to start each action during an experiment.</p> </li> <li> <p> <b>Stop conditions</b>: If a stop condition is triggered while an experiment is running, the experiment is automatically stopped. You can define a stop condition as a CloudWatch alarm.</p> </li> </ul> <p>For more information, see <a href="https://docs.aws.amazon.com/fis/latest/userguide/experiment-templates.html">experiment templates</a> in the <i>Fault Injection Service User Guide</i>.</p>

    Args:
        client_token: <p>Unique, case-sensitive identifier that you provide to ensure the idempotency of the request.</p>
        description: <p>A description for the experiment template.</p>
        stop_conditions: <p>The stop conditions.</p>
        targets: <p>The targets for the experiment.</p>
        actions: <p>The actions for the experiment.</p>
        role_arn: <p>The Amazon Resource Name (ARN) of an IAM role that grants the FIS service permission to perform service actions on your behalf.</p>
        tags: <p>The tags to apply to the experiment template.</p>
        log_configuration: <p>The configuration for experiment logging.</p>
        experiment_options: <p>The experiment options for the experiment template.</p>
        experiment_report_configuration: <p>The experiment report configuration for the experiment template.</p>

    Raises:
        capo_fis.errors.conflict_exception.ConflictException: <p>The request could not be processed because of a conflict.</p>
        capo_fis.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource cannot be found.</p>
        capo_fis.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>You have exceeded your service quota.</p>
        capo_fis.errors.validation_exception.ValidationException: <p>The specified input is not valid, or fails to satisfy the constraints for the request.</p>
        capo_fis.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_fis.types.create_experiment_template_request.CreateExperimentTemplateRequest]",
    ) -> AsyncOperationResponse[
        "capo_fis.types.create_experiment_template_response.CreateExperimentTemplateResponse"
    ]:
        import capo_fis._operations.fault_injection_simulator.create_experiment_template

        (
            output,
            http_response,
        ) = await capo_fis._operations.fault_injection_simulator.create_experiment_template.async_create_experiment_template(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateExperimentTemplate")
    )
    input_: capo_fis.types.create_experiment_template_request.CreateExperimentTemplateRequest = {
        "client_token": client_token,
        "description": description,
        "stop_conditions": stop_conditions,
        "actions": actions,
        "role_arn": role_arn,
    }
    if targets is not None:
        input_["targets"] = targets
    if tags is not None:
        input_["tags"] = tags
    if log_configuration is not None:
        input_["log_configuration"] = log_configuration
    if experiment_options is not None:
        input_["experiment_options"] = experiment_options
    if experiment_report_configuration is not None:
        input_["experiment_report_configuration"] = experiment_report_configuration

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output