CfnExperiment
- class aws_cdk.aws_evidently.CfnExperiment(scope, id, *, metric_goals, name, online_ab_config, project, treatments, description=None, randomization_salt=None, remove_segment=None, running_status=None, sampling_rate=None, segment=None, tags=None)
Bases:
CfnResource
A CloudFormation
AWS::Evidently::Experiment
.Creates or updates an Evidently experiment . Before you create an experiment, you must create the feature to use for the experiment.
An experiment helps you make feature design decisions based on evidence and data. An experiment can test as many as five variations at once. Evidently collects experiment data and analyzes it by statistical methods, and provides clear recommendations about which variations perform better.
- CloudformationResource:
AWS::Evidently::Experiment
- Link:
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-evidently-experiment.html
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_evidently as evidently cfn_experiment = evidently.CfnExperiment(self, "MyCfnExperiment", metric_goals=[evidently.CfnExperiment.MetricGoalObjectProperty( desired_change="desiredChange", entity_id_key="entityIdKey", metric_name="metricName", value_key="valueKey", # the properties below are optional event_pattern="eventPattern", unit_label="unitLabel" )], name="name", online_ab_config=evidently.CfnExperiment.OnlineAbConfigObjectProperty( control_treatment_name="controlTreatmentName", treatment_weights=[evidently.CfnExperiment.TreatmentToWeightProperty( split_weight=123, treatment="treatment" )] ), project="project", treatments=[evidently.CfnExperiment.TreatmentObjectProperty( feature="feature", treatment_name="treatmentName", variation="variation", # the properties below are optional description="description" )], # the properties below are optional description="description", randomization_salt="randomizationSalt", remove_segment=False, running_status=evidently.CfnExperiment.RunningStatusObjectProperty( status="status", # the properties below are optional analysis_complete_time="analysisCompleteTime", desired_state="desiredState", reason="reason" ), sampling_rate=123, segment="segment", tags=[CfnTag( key="key", value="value" )] )
Create a new
AWS::Evidently::Experiment
.- Parameters:
scope (
Construct
) –scope in which this resource is defined.
id (
str
) –scoped id of the resource.
metric_goals (
Union
[IResolvable
,Sequence
[Union
[MetricGoalObjectProperty
,Dict
[str
,Any
],IResolvable
]]]) – An array of structures that defines the metrics used for the experiment, and whether a higher or lower value for each metric is the goal. You can use up to three metrics in an experiment.name (
str
) – A name for the new experiment.online_ab_config (
Union
[IResolvable
,OnlineAbConfigObjectProperty
,Dict
[str
,Any
]]) – A structure that contains the configuration of which variation to use as the “control” version. The “control” version is used for comparison with other variations. This structure also specifies how much experiment traffic is allocated to each variation.project (
str
) – The name or the ARN of the project where this experiment is to be created.treatments (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,TreatmentObjectProperty
,Dict
[str
,Any
]]]]) – An array of structures that describe the configuration of each feature variation used in the experiment.description (
Optional
[str
]) – An optional description of the experiment.randomization_salt (
Optional
[str
]) – When Evidently assigns a particular user session to an experiment, it must use a randomization ID to determine which variation the user session is served. This randomization ID is a combination of the entity ID andrandomizationSalt
. If you omitrandomizationSalt
, Evidently uses the experiment name as therandomizationSalt
.remove_segment (
Union
[bool
,IResolvable
,None
]) – Set this totrue
to remove the segment that is associated with this experiment. You can’t use this parameter if the experiment is currently running.running_status (
Union
[IResolvable
,RunningStatusObjectProperty
,Dict
[str
,Any
],None
]) – A structure that you can use to start and stop the experiment.sampling_rate (
Union
[int
,float
,None
]) – The portion of the available audience that you want to allocate to this experiment, in thousandths of a percent. The available audience is the total audience minus the audience that you have allocated to overrides or current launches of this feature. This is represented in thousandths of a percent. For example, specify 10,000 to allocate 10% of the available audience.segment (
Optional
[str
]) – Specifies an audience segment to use in the experiment. When a segment is used in an experiment, only user sessions that match the segment pattern are used in the experiment. For more information, see Segment rule pattern syntax .tags (
Optional
[Sequence
[Union
[CfnTag
,Dict
[str
,Any
]]]]) – Assigns one or more tags (key-value pairs) to the experiment. Tags can help you organize and categorize your resources. You can also use them to scope user permissions by granting a user permission to access or change only resources with certain tag values. Tags don’t have any semantic meaning to AWS and are interpreted strictly as strings of characters. You can associate as many as 50 tags with an experiment. For more information, see Tagging AWS resources .
Methods
- add_deletion_override(path)
Syntactic sugar for
addOverride(path, undefined)
.- Parameters:
path (
str
) – The path of the value to delete.- Return type:
None
- add_depends_on(target)
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
- Parameters:
target (
CfnResource
) –- Return type:
None
- add_metadata(key, value)
Add a value to the CloudFormation Resource Metadata.
- Parameters:
key (
str
) –value (
Any
) –
- See:
- Return type:
None
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.
- add_override(path, value)
Adds an override to the synthesized CloudFormation resource.
To add a property override, either use
addPropertyOverride
or prefixpath
with “Properties.” (i.e.Properties.TopicName
).If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal
.
in the property name, prefix with a\
. In most programming languages you will need to write this as"\\."
because the\
itself will need to be escaped.For example:
cfn_resource.add_override("Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes", ["myattribute"]) cfn_resource.add_override("Properties.GlobalSecondaryIndexes.1.ProjectionType", "INCLUDE")
would add the overrides Example:
"Properties": { "GlobalSecondaryIndexes": [ { "Projection": { "NonKeyAttributes": [ "myattribute" ] ... } ... }, { "ProjectionType": "INCLUDE" ... }, ] ... }
The
value
argument toaddOverride
will not be processed or translated in any way. Pass raw JSON values in here with the correct capitalization for CloudFormation. If you pass CDK classes or structs, they will be rendered with lowercased key names, and CloudFormation will reject the template.- Parameters:
path (
str
) –The path of the property, you can use dot notation to override values in complex types. Any intermdediate keys will be created as needed.
value (
Any
) –The value. Could be primitive or complex.
- Return type:
None
- add_property_deletion_override(property_path)
Adds an override that deletes the value of a property from the resource definition.
- Parameters:
property_path (
str
) – The path to the property.- Return type:
None
- add_property_override(property_path, value)
Adds an override to a resource property.
Syntactic sugar for
addOverride("Properties.<...>", value)
.- Parameters:
property_path (
str
) – The path of the property.value (
Any
) – The value.
- Return type:
None
- apply_removal_policy(policy=None, *, apply_to_update_replace_policy=None, default=None)
Sets the deletion policy of the resource based on the removal policy specified.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.
The resource can be deleted (
RemovalPolicy.DESTROY
), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN
).- Parameters:
policy (
Optional
[RemovalPolicy
]) –apply_to_update_replace_policy (
Optional
[bool
]) – Apply the same deletion policy to the resource’s “UpdateReplacePolicy”. Default: truedefault (
Optional
[RemovalPolicy
]) – The default policy to apply in case the removal policy is not defined. Default: - Default value is resource specific. To determine the default value for a resoure, please consult that specific resource’s documentation.
- Return type:
None
- get_att(attribute_name)
Returns a token for an runtime attribute of this resource.
Ideally, use generated attribute accessors (e.g.
resource.arn
), but this can be used for future compatibility in case there is no generated attribute.- Parameters:
attribute_name (
str
) – The name of the attribute.- Return type:
- get_metadata(key)
Retrieve a value value from the CloudFormation Resource Metadata.
- Parameters:
key (
str
) –- See:
- Return type:
Any
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.
- inspect(inspector)
Examines the CloudFormation resource and discloses attributes.
- Parameters:
inspector (
TreeInspector
) –tree inspector to collect and process attributes.
- Return type:
None
- override_logical_id(new_logical_id)
Overrides the auto-generated logical ID with a specific ID.
- Parameters:
new_logical_id (
str
) – The new logical ID to use for this stack element.- Return type:
None
- to_string()
Returns a string representation of this construct.
- Return type:
str
- Returns:
a string representation of this resource
Attributes
- CFN_RESOURCE_TYPE_NAME = 'AWS::Evidently::Experiment'
- attr_arn
The ARN of the experiment.
For example,
arn:aws:evidently:us-west-2:0123455678912:project/myProject/experiment/myExperiment
- CloudformationAttribute:
Arn
- cfn_options
Options for this resource, such as condition, update policy etc.
- cfn_resource_type
AWS resource type.
- creation_stack
return:
the stack trace of the point where this Resource was created from, sourced from the +metadata+ entry typed +aws:cdk:logicalId+, and with the bottom-most node +internal+ entries filtered.
- description
An optional description of the experiment.
- logical_id
The logical ID for this CloudFormation stack element.
The logical ID of the element is calculated from the path of the resource node in the construct tree.
To override this value, use
overrideLogicalId(newLogicalId)
.- Returns:
the logical ID as a stringified token. This value will only get resolved during synthesis.
- metric_goals
An array of structures that defines the metrics used for the experiment, and whether a higher or lower value for each metric is the goal.
You can use up to three metrics in an experiment.
- name
A name for the new experiment.
- node
The construct tree node associated with this construct.
- online_ab_config
A structure that contains the configuration of which variation to use as the “control” version.
The “control” version is used for comparison with other variations. This structure also specifies how much experiment traffic is allocated to each variation.
- project
The name or the ARN of the project where this experiment is to be created.
- randomization_salt
When Evidently assigns a particular user session to an experiment, it must use a randomization ID to determine which variation the user session is served.
This randomization ID is a combination of the entity ID and
randomizationSalt
. If you omitrandomizationSalt
, Evidently uses the experiment name as therandomizationSalt
.
- ref
Return a string that will be resolved to a CloudFormation
{ Ref }
for this element.If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through
Lazy.any({ produce: resource.ref })
.
- remove_segment
Set this to
true
to remove the segment that is associated with this experiment.You can’t use this parameter if the experiment is currently running.
- running_status
A structure that you can use to start and stop the experiment.
- sampling_rate
The portion of the available audience that you want to allocate to this experiment, in thousandths of a percent.
The available audience is the total audience minus the audience that you have allocated to overrides or current launches of this feature.
This is represented in thousandths of a percent. For example, specify 10,000 to allocate 10% of the available audience.
- segment
Specifies an audience segment to use in the experiment.
When a segment is used in an experiment, only user sessions that match the segment pattern are used in the experiment.
For more information, see Segment rule pattern syntax .
- stack
The stack in which this element is defined.
CfnElements must be defined within a stack scope (directly or indirectly).
- tags
Assigns one or more tags (key-value pairs) to the experiment.
Tags can help you organize and categorize your resources. You can also use them to scope user permissions by granting a user permission to access or change only resources with certain tag values.
Tags don’t have any semantic meaning to AWS and are interpreted strictly as strings of characters.
You can associate as many as 50 tags with an experiment.
For more information, see Tagging AWS resources .
- treatments
An array of structures that describe the configuration of each feature variation used in the experiment.
Static Methods
- classmethod is_cfn_element(x)
Returns
true
if a construct is a stack element (i.e. part of the synthesized cloudformation template).Uses duck-typing instead of
instanceof
to allow stack elements from different versions of this library to be included in the same stack.- Parameters:
x (
Any
) –- Return type:
bool
- Returns:
The construct as a stack element or undefined if it is not a stack element.
- classmethod is_cfn_resource(construct)
Check whether the given construct is a CfnResource.
- Parameters:
construct (
IConstruct
) –- Return type:
bool
- classmethod is_construct(x)
Return whether the given object is a Construct.
- Parameters:
x (
Any
) –- Return type:
bool
MetricGoalObjectProperty
- class CfnExperiment.MetricGoalObjectProperty(*, desired_change, entity_id_key, metric_name, value_key, event_pattern=None, unit_label=None)
Bases:
object
Use this structure to tell Evidently whether higher or lower values are desired for a metric that is used in an experiment.
- Parameters:
desired_change (
str
) –INCREASE
means that a variation with a higher number for this metric is performing better.DECREASE
means that a variation with a lower number for this metric is performing better.entity_id_key (
str
) – The entity, such as a user or session, that does an action that causes a metric value to be recorded. An example isuserDetails.userID
.metric_name (
str
) – A name for the metric. It can include up to 255 characters.value_key (
str
) – The JSON path to reference the numerical metric value in the event.event_pattern (
Optional
[str
]) – The EventBridge event pattern that defines how the metric is recorded. For more information about EventBridge event patterns, see Amazon EventBridge event patterns .unit_label (
Optional
[str
]) – A label for the units that the metric is measuring.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_evidently as evidently metric_goal_object_property = evidently.CfnExperiment.MetricGoalObjectProperty( desired_change="desiredChange", entity_id_key="entityIdKey", metric_name="metricName", value_key="valueKey", # the properties below are optional event_pattern="eventPattern", unit_label="unitLabel" )
Attributes
- desired_change
INCREASE
means that a variation with a higher number for this metric is performing better.DECREASE
means that a variation with a lower number for this metric is performing better.
- entity_id_key
The entity, such as a user or session, that does an action that causes a metric value to be recorded.
An example is
userDetails.userID
.
- event_pattern
The EventBridge event pattern that defines how the metric is recorded.
For more information about EventBridge event patterns, see Amazon EventBridge event patterns .
- metric_name
A name for the metric.
It can include up to 255 characters.
- unit_label
A label for the units that the metric is measuring.
- value_key
The JSON path to reference the numerical metric value in the event.
OnlineAbConfigObjectProperty
- class CfnExperiment.OnlineAbConfigObjectProperty(*, control_treatment_name=None, treatment_weights=None)
Bases:
object
A structure that contains the configuration of which variation to use as the “control” version.
The “control” version is used for comparison with other variations. This structure also specifies how much experiment traffic is allocated to each variation.
- Parameters:
control_treatment_name (
Optional
[str
]) – The name of the variation that is to be the default variation that the other variations are compared to.treatment_weights (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,TreatmentToWeightProperty
,Dict
[str
,Any
]]],None
]) – A set of key-value pairs. The keys are treatment names, and the values are the portion of experiment traffic to be assigned to that treatment. Specify the traffic portion in thousandths of a percent, so 20,000 for a variation would allocate 20% of the experiment traffic to that variation.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_evidently as evidently online_ab_config_object_property = evidently.CfnExperiment.OnlineAbConfigObjectProperty( control_treatment_name="controlTreatmentName", treatment_weights=[evidently.CfnExperiment.TreatmentToWeightProperty( split_weight=123, treatment="treatment" )] )
Attributes
- control_treatment_name
The name of the variation that is to be the default variation that the other variations are compared to.
- treatment_weights
A set of key-value pairs.
The keys are treatment names, and the values are the portion of experiment traffic to be assigned to that treatment. Specify the traffic portion in thousandths of a percent, so 20,000 for a variation would allocate 20% of the experiment traffic to that variation.
RunningStatusObjectProperty
- class CfnExperiment.RunningStatusObjectProperty(*, status, analysis_complete_time=None, desired_state=None, reason=None)
Bases:
object
Use this structure to start and stop the experiment.
- Parameters:
status (
str
) – To start the experiment now, specifySTART
for this parameter. If this experiment is currently running and you want to stop it now, specifySTOP
.analysis_complete_time (
Optional
[str
]) – If you are using AWS CloudFormation to start the experiment, use this field to specify when the experiment is to end. The format is as a UNIX timestamp. For more information about this format, see The Current Epoch Unix Timestamp .desired_state (
Optional
[str
]) – If you are using AWS CloudFormation to stop this experiment, specify eitherCOMPLETED
orCANCELLED
here to indicate how to classify this experiment.reason (
Optional
[str
]) – If you are using AWS CloudFormation to stop this experiment, this is an optional field that you can use to record why the experiment is being stopped or cancelled.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_evidently as evidently running_status_object_property = evidently.CfnExperiment.RunningStatusObjectProperty( status="status", # the properties below are optional analysis_complete_time="analysisCompleteTime", desired_state="desiredState", reason="reason" )
Attributes
- analysis_complete_time
If you are using AWS CloudFormation to start the experiment, use this field to specify when the experiment is to end.
The format is as a UNIX timestamp. For more information about this format, see The Current Epoch Unix Timestamp .
- desired_state
If you are using AWS CloudFormation to stop this experiment, specify either
COMPLETED
orCANCELLED
here to indicate how to classify this experiment.
- reason
If you are using AWS CloudFormation to stop this experiment, this is an optional field that you can use to record why the experiment is being stopped or cancelled.
- status
To start the experiment now, specify
START
for this parameter.If this experiment is currently running and you want to stop it now, specify
STOP
.
TreatmentObjectProperty
- class CfnExperiment.TreatmentObjectProperty(*, feature, treatment_name, variation, description=None)
Bases:
object
A structure that defines one treatment in an experiment.
A treatment is a variation of the feature that you are including in the experiment.
- Parameters:
feature (
str
) – The name of the feature for this experiment.treatment_name (
str
) – A name for this treatment. It can include up to 127 characters.variation (
str
) – The name of the variation to use for this treatment.description (
Optional
[str
]) – The description of the treatment.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_evidently as evidently treatment_object_property = evidently.CfnExperiment.TreatmentObjectProperty( feature="feature", treatment_name="treatmentName", variation="variation", # the properties below are optional description="description" )
Attributes
- description
The description of the treatment.
- feature
The name of the feature for this experiment.
- treatment_name
A name for this treatment.
It can include up to 127 characters.
- variation
The name of the variation to use for this treatment.
TreatmentToWeightProperty
- class CfnExperiment.TreatmentToWeightProperty(*, split_weight, treatment)
Bases:
object
This structure defines how much experiment traffic to allocate to one treatment used in the experiment.
- Parameters:
split_weight (
Union
[int
,float
]) – The portion of experiment traffic to allocate to this treatment. Specify the traffic portion in thousandths of a percent, so 20,000 allocated to a treatment would allocate 20% of the experiment traffic to that treatment.treatment (
str
) – The name of the treatment.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_evidently as evidently treatment_to_weight_property = evidently.CfnExperiment.TreatmentToWeightProperty( split_weight=123, treatment="treatment" )
Attributes
- split_weight
The portion of experiment traffic to allocate to this treatment.
Specify the traffic portion in thousandths of a percent, so 20,000 allocated to a treatment would allocate 20% of the experiment traffic to that treatment.