ComputeOptimizerAutomation / Client / create_automation_rule
create_automation_rule¶
- ComputeOptimizerAutomation.Client.create_automation_rule(**kwargs)¶
Creates a new automation rule to apply recommended actions to resources based on specified criteria.
See also: AWS API Documentation
Request Syntax
response = client.create_automation_rule( name='string', description='string', ruleType='OrganizationRule'|'AccountRule', organizationConfiguration={ 'ruleApplyOrder': 'BeforeAccountRules'|'AfterAccountRules', 'accountIds': [ 'string', ] }, priority='string', recommendedActionTypes=[ 'SnapshotAndDeleteUnattachedEbsVolume'|'UpgradeEbsVolumeType', ], criteria={ 'region': [ { 'comparison': 'StringEquals'|'StringNotEquals'|'StringEqualsIgnoreCase'|'StringNotEqualsIgnoreCase'|'StringLike'|'StringNotLike'|'NumericEquals'|'NumericNotEquals'|'NumericLessThan'|'NumericLessThanEquals'|'NumericGreaterThan'|'NumericGreaterThanEquals', 'values': [ 'string', ] }, ], 'resourceArn': [ { 'comparison': 'StringEquals'|'StringNotEquals'|'StringEqualsIgnoreCase'|'StringNotEqualsIgnoreCase'|'StringLike'|'StringNotLike'|'NumericEquals'|'NumericNotEquals'|'NumericLessThan'|'NumericLessThanEquals'|'NumericGreaterThan'|'NumericGreaterThanEquals', 'values': [ 'string', ] }, ], 'ebsVolumeType': [ { 'comparison': 'StringEquals'|'StringNotEquals'|'StringEqualsIgnoreCase'|'StringNotEqualsIgnoreCase'|'StringLike'|'StringNotLike'|'NumericEquals'|'NumericNotEquals'|'NumericLessThan'|'NumericLessThanEquals'|'NumericGreaterThan'|'NumericGreaterThanEquals', 'values': [ 'string', ] }, ], 'ebsVolumeSizeInGib': [ { 'comparison': 'StringEquals'|'StringNotEquals'|'StringEqualsIgnoreCase'|'StringNotEqualsIgnoreCase'|'StringLike'|'StringNotLike'|'NumericEquals'|'NumericNotEquals'|'NumericLessThan'|'NumericLessThanEquals'|'NumericGreaterThan'|'NumericGreaterThanEquals', 'values': [ 123, ] }, ], 'estimatedMonthlySavings': [ { 'comparison': 'StringEquals'|'StringNotEquals'|'StringEqualsIgnoreCase'|'StringNotEqualsIgnoreCase'|'StringLike'|'StringNotLike'|'NumericEquals'|'NumericNotEquals'|'NumericLessThan'|'NumericLessThanEquals'|'NumericGreaterThan'|'NumericGreaterThanEquals', 'values': [ 123.0, ] }, ], 'resourceTag': [ { 'comparison': 'StringEquals'|'StringNotEquals'|'StringEqualsIgnoreCase'|'StringNotEqualsIgnoreCase'|'StringLike'|'StringNotLike'|'NumericEquals'|'NumericNotEquals'|'NumericLessThan'|'NumericLessThanEquals'|'NumericGreaterThan'|'NumericGreaterThanEquals', 'key': 'string', 'values': [ 'string', ] }, ], 'lookBackPeriodInDays': [ { 'comparison': 'StringEquals'|'StringNotEquals'|'StringEqualsIgnoreCase'|'StringNotEqualsIgnoreCase'|'StringLike'|'StringNotLike'|'NumericEquals'|'NumericNotEquals'|'NumericLessThan'|'NumericLessThanEquals'|'NumericGreaterThan'|'NumericGreaterThanEquals', 'values': [ 123, ] }, ], 'restartNeeded': [ { 'comparison': 'StringEquals'|'StringNotEquals'|'StringEqualsIgnoreCase'|'StringNotEqualsIgnoreCase'|'StringLike'|'StringNotLike'|'NumericEquals'|'NumericNotEquals'|'NumericLessThan'|'NumericLessThanEquals'|'NumericGreaterThan'|'NumericGreaterThanEquals', 'values': [ 'string', ] }, ] }, schedule={ 'scheduleExpression': 'string', 'scheduleExpressionTimezone': 'string', 'executionWindowInMinutes': 123 }, status='Active'|'Inactive', tags=[ { 'key': 'string', 'value': 'string' }, ], clientToken='string' )
- Parameters:
name (string) –
[REQUIRED]
The name of the automation rule.
description (string) – A description of the automation rule.
ruleType (string) –
[REQUIRED]
The type of rule.
Note
Only the management account or a delegated administrator can set the ruleType to be OrganizationRule.
organizationConfiguration (dict) –
Configuration for organization-level rules. Required for OrganizationRule type.
ruleApplyOrder (string) –
Specifies when organization rules should be applied relative to account rules.
accountIds (list) –
List of specific Amazon Web Services account IDs where the organization rule should be applied.
(string) –
priority (string) – A string representation of a decimal number between 0 and 1 (having up to 30 digits after the decimal point) that determines the priority of the rule. When multiple rules match the same recommended action, Compute Optimizer assigns the action to the rule with the lowest priority value (highest priority), even if that rule is scheduled to run later than other matching rules.
recommendedActionTypes (list) –
[REQUIRED]
The types of recommended actions this rule will automate.
(string) –
Recommended action type enumeration
criteria (dict) –
A set of conditions that specify which recommended action qualify for implementation. When a rule is active and a recommended action matches these criteria, Compute Optimizer implements the action at the scheduled run time.
region (list) –
Filter criteria for Amazon Web Services regions where resources must be located.
(dict) –
Criteria condition for filtering based on string values, including comparison operators and target values.
comparison (string) –
The comparison operator used to evaluate the string criteria, such as equals, not equals, or contains.
values (list) –
List of string values to compare against when applying the criteria condition.
(string) –
resourceArn (list) –
Filter criteria for specific resource ARNs to include or exclude.
(dict) –
Criteria condition for filtering based on string values, including comparison operators and target values.
comparison (string) –
The comparison operator used to evaluate the string criteria, such as equals, not equals, or contains.
values (list) –
List of string values to compare against when applying the criteria condition.
(string) –
ebsVolumeType (list) –
Filter criteria for EBS volume types, such as gp2, gp3, io1, io2, st1, or sc1.
(dict) –
Criteria condition for filtering based on string values, including comparison operators and target values.
comparison (string) –
The comparison operator used to evaluate the string criteria, such as equals, not equals, or contains.
values (list) –
List of string values to compare against when applying the criteria condition.
(string) –
ebsVolumeSizeInGib (list) –
Filter criteria for EBS volume sizes in gibibytes (GiB).
(dict) –
Defines a condition for filtering based on integer values with comparison operators.
comparison (string) –
The comparison operator to use, such as equals, greater than, less than, etc.
values (list) –
The list of integer values to compare against using the specified comparison operator.
(integer) –
estimatedMonthlySavings (list) –
Filter criteria for estimated monthly cost savings from the recommended action.
(dict) –
Defines a condition for filtering based on double/floating-point numeric values with comparison operators.
comparison (string) –
The comparison operator to use, such as equals, greater than, less than, etc.
values (list) –
The list of double values to compare against using the specified comparison operator.
(float) –
resourceTag (list) –
Filter criteria for resource tags, allowing filtering by tag key and value combinations.
(dict) –
Criteria condition for filtering resources based on their tags, including comparison operators and values.
comparison (string) –
The comparison operator used to evaluate the tag criteria, such as equals, not equals, or contains.
key (string) –
The tag key to use for comparison when filtering resources.
values (list) –
List of tag values to compare against when filtering resources.
(string) –
lookBackPeriodInDays (list) –
Filter criteria for the lookback period in days used to analyze resource utilization.
(dict) –
Defines a condition for filtering based on integer values with comparison operators.
comparison (string) –
The comparison operator to use, such as equals, greater than, less than, etc.
values (list) –
The list of integer values to compare against using the specified comparison operator.
(integer) –
restartNeeded (list) –
Filter criteria indicating whether the recommended action requires a resource restart.
(dict) –
Criteria condition for filtering based on string values, including comparison operators and target values.
comparison (string) –
The comparison operator used to evaluate the string criteria, such as equals, not equals, or contains.
values (list) –
List of string values to compare against when applying the criteria condition.
(string) –
schedule (dict) –
[REQUIRED]
The schedule for when the rule should run.
scheduleExpression (string) –
The expression that defines when the schedule runs.
cronexpression is supported. Acronexpression consists of six fields separated by white spaces: (minuteshoursday_of_monthmonthday_of_weekyear)Note
You can schedule rules to run at most once per day. Your cron expression must use specific values (not wildcards) for the minutes and hours fields. For example: (
30 12 * * *) runs daily at 12:30 PM UTC.scheduleExpressionTimezone (string) –
The timezone to use when interpreting the schedule expression.
executionWindowInMinutes (integer) –
The time window in minutes during which the automation rule can start implementing recommended actions.
status (string) –
[REQUIRED]
The status of the rule
tags (list) –
The tags to associate with the rule.
(dict) –
A key-value pair used to categorize and organize Amazon Web Services resources and automation rules.
key (string) – [REQUIRED]
The tag key, which can be up to 128 characters long.
value (string) – [REQUIRED]
The tag value, which can be up to 256 characters long.
clientToken (string) –
A unique identifier to ensure idempotency of the request.
This field is autopopulated if not provided.
- Return type:
dict
- Returns:
Response Syntax
{ 'ruleArn': 'string', 'ruleId': 'string', 'name': 'string', 'description': 'string', 'ruleType': 'OrganizationRule'|'AccountRule', 'ruleRevision': 123, 'organizationConfiguration': { 'ruleApplyOrder': 'BeforeAccountRules'|'AfterAccountRules', 'accountIds': [ 'string', ] }, 'priority': 'string', 'recommendedActionTypes': [ 'SnapshotAndDeleteUnattachedEbsVolume'|'UpgradeEbsVolumeType', ], 'criteria': { 'region': [ { 'comparison': 'StringEquals'|'StringNotEquals'|'StringEqualsIgnoreCase'|'StringNotEqualsIgnoreCase'|'StringLike'|'StringNotLike'|'NumericEquals'|'NumericNotEquals'|'NumericLessThan'|'NumericLessThanEquals'|'NumericGreaterThan'|'NumericGreaterThanEquals', 'values': [ 'string', ] }, ], 'resourceArn': [ { 'comparison': 'StringEquals'|'StringNotEquals'|'StringEqualsIgnoreCase'|'StringNotEqualsIgnoreCase'|'StringLike'|'StringNotLike'|'NumericEquals'|'NumericNotEquals'|'NumericLessThan'|'NumericLessThanEquals'|'NumericGreaterThan'|'NumericGreaterThanEquals', 'values': [ 'string', ] }, ], 'ebsVolumeType': [ { 'comparison': 'StringEquals'|'StringNotEquals'|'StringEqualsIgnoreCase'|'StringNotEqualsIgnoreCase'|'StringLike'|'StringNotLike'|'NumericEquals'|'NumericNotEquals'|'NumericLessThan'|'NumericLessThanEquals'|'NumericGreaterThan'|'NumericGreaterThanEquals', 'values': [ 'string', ] }, ], 'ebsVolumeSizeInGib': [ { 'comparison': 'StringEquals'|'StringNotEquals'|'StringEqualsIgnoreCase'|'StringNotEqualsIgnoreCase'|'StringLike'|'StringNotLike'|'NumericEquals'|'NumericNotEquals'|'NumericLessThan'|'NumericLessThanEquals'|'NumericGreaterThan'|'NumericGreaterThanEquals', 'values': [ 123, ] }, ], 'estimatedMonthlySavings': [ { 'comparison': 'StringEquals'|'StringNotEquals'|'StringEqualsIgnoreCase'|'StringNotEqualsIgnoreCase'|'StringLike'|'StringNotLike'|'NumericEquals'|'NumericNotEquals'|'NumericLessThan'|'NumericLessThanEquals'|'NumericGreaterThan'|'NumericGreaterThanEquals', 'values': [ 123.0, ] }, ], 'resourceTag': [ { 'comparison': 'StringEquals'|'StringNotEquals'|'StringEqualsIgnoreCase'|'StringNotEqualsIgnoreCase'|'StringLike'|'StringNotLike'|'NumericEquals'|'NumericNotEquals'|'NumericLessThan'|'NumericLessThanEquals'|'NumericGreaterThan'|'NumericGreaterThanEquals', 'key': 'string', 'values': [ 'string', ] }, ], 'lookBackPeriodInDays': [ { 'comparison': 'StringEquals'|'StringNotEquals'|'StringEqualsIgnoreCase'|'StringNotEqualsIgnoreCase'|'StringLike'|'StringNotLike'|'NumericEquals'|'NumericNotEquals'|'NumericLessThan'|'NumericLessThanEquals'|'NumericGreaterThan'|'NumericGreaterThanEquals', 'values': [ 123, ] }, ], 'restartNeeded': [ { 'comparison': 'StringEquals'|'StringNotEquals'|'StringEqualsIgnoreCase'|'StringNotEqualsIgnoreCase'|'StringLike'|'StringNotLike'|'NumericEquals'|'NumericNotEquals'|'NumericLessThan'|'NumericLessThanEquals'|'NumericGreaterThan'|'NumericGreaterThanEquals', 'values': [ 'string', ] }, ] }, 'schedule': { 'scheduleExpression': 'string', 'scheduleExpressionTimezone': 'string', 'executionWindowInMinutes': 123 }, 'status': 'Active'|'Inactive', 'tags': [ { 'key': 'string', 'value': 'string' }, ], 'createdTimestamp': datetime(2015, 1, 1) }
Response Structure
(dict) –
ruleArn (string) –
The Amazon Resource Name (ARN) of the created rule.
ruleId (string) –
The unique identifier of the created rule.
name (string) –
The name of the automation rule. Must be 1-128 characters long and contain only alphanumeric characters, underscores, and hyphens.
description (string) –
A description of the automation rule. Can be up to 1024 characters long and contain alphanumeric characters, underscores, hyphens, spaces, and certain special characters.
ruleType (string) –
The type of automation rule. Can be either OrganizationRule for organization-wide rules or AccountRule for account-specific rules.
ruleRevision (integer) –
The revision number of the automation rule. This is incremented each time the rule is updated.
organizationConfiguration (dict) –
Configuration settings for organization-wide rules, including rule application order and target account IDs.
ruleApplyOrder (string) –
Specifies when organization rules should be applied relative to account rules.
accountIds (list) –
List of specific Amazon Web Services account IDs where the organization rule should be applied.
(string) –
priority (string) –
The priority level of the automation rule, used to determine execution order when multiple rules apply to the same resource.
recommendedActionTypes (list) –
List of recommended action types that this rule can execute, such as SnapshotAndDeleteUnattachedEbsVolume or UpgradeEbsVolumeType.
(string) –
Recommended action type enumeration
criteria (dict) –
A set of conditions that specify which recommended action qualify for implementation. When a rule is active and a recommended action matches these criteria, Compute Optimizer implements the action at the scheduled run time. You can specify up to 20 conditions per filter criteria and 20 values per condition.
region (list) –
Filter criteria for Amazon Web Services regions where resources must be located.
(dict) –
Criteria condition for filtering based on string values, including comparison operators and target values.
comparison (string) –
The comparison operator used to evaluate the string criteria, such as equals, not equals, or contains.
values (list) –
List of string values to compare against when applying the criteria condition.
(string) –
resourceArn (list) –
Filter criteria for specific resource ARNs to include or exclude.
(dict) –
Criteria condition for filtering based on string values, including comparison operators and target values.
comparison (string) –
The comparison operator used to evaluate the string criteria, such as equals, not equals, or contains.
values (list) –
List of string values to compare against when applying the criteria condition.
(string) –
ebsVolumeType (list) –
Filter criteria for EBS volume types, such as gp2, gp3, io1, io2, st1, or sc1.
(dict) –
Criteria condition for filtering based on string values, including comparison operators and target values.
comparison (string) –
The comparison operator used to evaluate the string criteria, such as equals, not equals, or contains.
values (list) –
List of string values to compare against when applying the criteria condition.
(string) –
ebsVolumeSizeInGib (list) –
Filter criteria for EBS volume sizes in gibibytes (GiB).
(dict) –
Defines a condition for filtering based on integer values with comparison operators.
comparison (string) –
The comparison operator to use, such as equals, greater than, less than, etc.
values (list) –
The list of integer values to compare against using the specified comparison operator.
(integer) –
estimatedMonthlySavings (list) –
Filter criteria for estimated monthly cost savings from the recommended action.
(dict) –
Defines a condition for filtering based on double/floating-point numeric values with comparison operators.
comparison (string) –
The comparison operator to use, such as equals, greater than, less than, etc.
values (list) –
The list of double values to compare against using the specified comparison operator.
(float) –
resourceTag (list) –
Filter criteria for resource tags, allowing filtering by tag key and value combinations.
(dict) –
Criteria condition for filtering resources based on their tags, including comparison operators and values.
comparison (string) –
The comparison operator used to evaluate the tag criteria, such as equals, not equals, or contains.
key (string) –
The tag key to use for comparison when filtering resources.
values (list) –
List of tag values to compare against when filtering resources.
(string) –
lookBackPeriodInDays (list) –
Filter criteria for the lookback period in days used to analyze resource utilization.
(dict) –
Defines a condition for filtering based on integer values with comparison operators.
comparison (string) –
The comparison operator to use, such as equals, greater than, less than, etc.
values (list) –
The list of integer values to compare against using the specified comparison operator.
(integer) –
restartNeeded (list) –
Filter criteria indicating whether the recommended action requires a resource restart.
(dict) –
Criteria condition for filtering based on string values, including comparison operators and target values.
comparison (string) –
The comparison operator used to evaluate the string criteria, such as equals, not equals, or contains.
values (list) –
List of string values to compare against when applying the criteria condition.
(string) –
schedule (dict) –
The schedule configuration for when the automation rule should execute, including cron expression, timezone, and execution window.
scheduleExpression (string) –
The expression that defines when the schedule runs.
cronexpression is supported. Acronexpression consists of six fields separated by white spaces: (minuteshoursday_of_monthmonthday_of_weekyear)Note
You can schedule rules to run at most once per day. Your cron expression must use specific values (not wildcards) for the minutes and hours fields. For example: (
30 12 * * *) runs daily at 12:30 PM UTC.scheduleExpressionTimezone (string) –
The timezone to use when interpreting the schedule expression.
executionWindowInMinutes (integer) –
The time window in minutes during which the automation rule can start implementing recommended actions.
status (string) –
The current status of the automation rule. Can be Active or Inactive.
tags (list) –
A list of key-value pairs used to categorize and organize the automation rule. Maximum of 200 tags allowed.
(dict) –
A key-value pair used to categorize and organize Amazon Web Services resources and automation rules.
key (string) –
The tag key, which can be up to 128 characters long.
value (string) –
The tag value, which can be up to 256 characters long.
createdTimestamp (datetime) –
The timestamp when the automation rule was created.
Exceptions
ComputeOptimizerAutomation.Client.exceptions.InvalidParameterValueExceptionComputeOptimizerAutomation.Client.exceptions.ForbiddenExceptionComputeOptimizerAutomation.Client.exceptions.OptInRequiredExceptionComputeOptimizerAutomation.Client.exceptions.ThrottlingExceptionComputeOptimizerAutomation.Client.exceptions.IdempotentParameterMismatchExceptionComputeOptimizerAutomation.Client.exceptions.ResourceNotFoundExceptionComputeOptimizerAutomation.Client.exceptions.AccessDeniedExceptionComputeOptimizerAutomation.Client.exceptions.InternalServerExceptionComputeOptimizerAutomation.Client.exceptions.ServiceUnavailableExceptionComputeOptimizerAutomation.Client.exceptions.IdempotencyTokenInUseExceptionComputeOptimizerAutomation.Client.exceptions.ServiceQuotaExceededException