boto3_asg¶
Connection module for Amazon Autoscale Groups using boto3.¶
Renamed from
boto_asgtoboto3_asgand rewritten to use the boto3autoscaling(andec2) client APIs directly viasaltext.boto3.utils.boto3mod. The legacy boto2 code path (object-style access, retry loops) has been removed.
- depends:
boto3 >= 1.28.0
botocore >= 1.31.0
- configuration:
This module accepts explicit autoscale credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no further configuration is necessary. More Information available at:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html
If IAM roles are not used you need to specify them either in the minion’s config file or as a profile. For example, to specify them in the minion’s config file:
asg.keyid: GKTADJGHEIQSXMKKRBJ08H
asg.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
A region may also be specified in the configuration:
asg.region: us-east-1
It’s also possible to specify key, keyid and region via a profile, either as a passed in dict, or as a string to pull from pillars or minion config:
myprofile:
keyid: GKTADJGHEIQSXMKKRBJ08H
key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
region: us-east-1
Added in version 1.0.0.
- saltext.boto3.modules.boto3_asg.__virtual__()[source]¶
Only load if boto3 is available. Minimum version is enforced via the project’s
pyproject.tomldependency declaration.
- saltext.boto3.modules.boto3_asg.exists(name, region=None, key=None, keyid=None, profile=None)[source]¶
Check to see if an autoscale group exists.
- name (str):
The name of the autoscaling group to check.
- region (str, optional):
The AWS region where the autoscaling group is located.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
CLI Example:
salt myminion boto3_asg.exists myasg region=us-east-1
- saltext.boto3.modules.boto3_asg.get_config(name, region=None, key=None, keyid=None, profile=None)[source]¶
Get the configuration for an autoscale group.
- name (str):
The name of the autoscaling group to get the configuration for.
- region (str, optional):
The AWS region where the autoscaling group is located.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
CLI Example:
salt myminion boto3_asg.get_config myasg region=us-east-1
- saltext.boto3.modules.boto3_asg.create(name, launch_config_name, availability_zones, min_size, max_size, desired_capacity=None, load_balancers=None, default_cooldown=None, health_check_type=None, health_check_period=None, placement_group=None, vpc_zone_identifier=None, tags=None, termination_policies=None, suspended_processes=None, scaling_policies=None, scheduled_actions=None, region=None, notification_arn=None, notification_types=None, key=None, keyid=None, profile=None)[source]¶
Create an autoscale group.
- name (str):
The name of the autoscaling group to create.
- launch_config_name (str):
The name of the launch configuration to use for the autoscaling group.
- availability_zones (list):
A list of availability zones for the autoscaling group.
- min_size (int):
The minimum size of the autoscaling group.
- max_size (int):
The maximum size of the autoscaling group.
- desired_capacity (int, optional):
The desired capacity of the autoscaling group.
- load_balancers (list, optional):
A list of load balancer names to associate with the autoscaling group.
- default_cooldown (int, optional):
The default cooldown period for the autoscaling group.
- health_check_type (str, optional):
The health check type for the autoscaling group.
- health_check_period (int, optional):
The health check period for the autoscaling group.
- placement_group (str, optional):
The placement group for the autoscaling group.
- vpc_zone_identifier (list, optional):
A list of VPC subnet IDs for the autoscaling group.
- tags (list, optional):
A list of tags to associate with the autoscaling group.
- termination_policies (list, optional):
A list of termination policies for the autoscaling group.
- suspended_processes (list, optional):
A list of suspended processes for the autoscaling group.
- scaling_policies (list, optional):
A list of scaling policies for the autoscaling group.
- scheduled_actions (list, optional):
A list of scheduled actions for the autoscaling group.
- region (str, optional):
The AWS region where the autoscaling group is located.
- notification_arn (str, optional):
The ARN of the SNS topic for notifications.
- notification_types (list, optional):
A list of notification types for the autoscaling group.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
CLI Example:
salt myminion boto3_asg.create myasg mylc '["us-east-1a", "us-east-1e"]' 1 10
- saltext.boto3.modules.boto3_asg.update(name, launch_config_name, availability_zones, min_size, max_size, desired_capacity=None, load_balancers=None, default_cooldown=None, health_check_type=None, health_check_period=None, placement_group=None, vpc_zone_identifier=None, tags=None, termination_policies=None, suspended_processes=None, scaling_policies=None, scheduled_actions=None, notification_arn=None, notification_types=None, region=None, key=None, keyid=None, profile=None)[source]¶
Update an autoscale group.
- name (str):
The name of the autoscaling group to update.
- launch_config_name (str):
The name of the launch configuration to use for the autoscaling group.
- availability_zones (list):
A list of availability zones for the autoscaling group.
- min_size (int):
The minimum size of the autoscaling group.
- max_size (int):
The maximum size of the autoscaling group.
- desired_capacity (int, optional):
The desired capacity of the autoscaling group.
- load_balancers (list, optional):
A list of load balancer names to associate with the autoscaling group.
- default_cooldown (int, optional):
The default cooldown period for the autoscaling group.
- health_check_type (str, optional):
The health check type for the autoscaling group.
- health_check_period (int, optional):
The health check period for the autoscaling group.
- placement_group (str, optional):
The placement group for the autoscaling group.
- vpc_zone_identifier (list, optional):
A list of VPC subnet IDs for the autoscaling group.
- tags (list, optional):
A list of tags to associate with the autoscaling group.
- termination_policies (list, optional):
A list of termination policies for the autoscaling group.
- suspended_processes (list, optional):
A list of suspended processes for the autoscaling group.
- scaling_policies (list, optional):
A list of scaling policies for the autoscaling group.
- scheduled_actions (list, optional):
A list of scheduled actions for the autoscaling group.
- notification_arn (str, optional):
The ARN of the SNS topic for notifications.
- notification_types (list, optional):
A list of notification types for the autoscaling group.
- region (str, optional):
The AWS region where the autoscaling group is located.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
CLI Example:
salt myminion boto3_asg.update myasg mylc '["us-east-1a", "us-east-1e"]' 1 10
- saltext.boto3.modules.boto3_asg.delete(name, force=False, region=None, key=None, keyid=None, profile=None)[source]¶
Delete an autoscale group.
- name (str):
The name of the autoscaling group to delete.
- force (bool, optional):
Whether to force the deletion of the autoscaling group.
- region (str, optional):
The AWS region where the autoscaling group is located.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
CLI Example:
salt myminion boto3_asg.delete myasg region=us-east-1
- saltext.boto3.modules.boto3_asg.get_cloud_init_mime(cloud_init)[source]¶
Get a mime multipart encoded string from a cloud-init dict. Currently supports boothooks, scripts and cloud-config.
- cloud_init (dict):
The cloud-init configuration dictionary containing boothooks, scripts, and cloud-config sections.
CLI Example:
salt myminion boto3_asg.get_cloud_init_mime <cloud init>
- saltext.boto3.modules.boto3_asg.launch_configuration_exists(name, region=None, key=None, keyid=None, profile=None)[source]¶
Check for a launch configuration’s existence.
- name (str):
The name of the launch configuration to check for existence.
- region (str, optional):
The AWS region where the launch configuration is located.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
CLI Example:
salt myminion boto3_asg.launch_configuration_exists mylc
- saltext.boto3.modules.boto3_asg.get_all_launch_configurations(region=None, key=None, keyid=None, profile=None)[source]¶
Fetch and return all Launch Configurations with details.
- region (str, optional):
The AWS region where the launch configurations are located.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
CLI Example:
salt myminion boto3_asg.get_all_launch_configurations
- saltext.boto3.modules.boto3_asg.list_launch_configurations(region=None, key=None, keyid=None, profile=None)[source]¶
List all Launch Configuration names.
- region (str, optional):
The AWS region where the launch configurations are located.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
CLI Example:
salt myminion boto3_asg.list_launch_configurations
- saltext.boto3.modules.boto3_asg.describe_launch_configuration(name, region=None, key=None, keyid=None, profile=None)[source]¶
Dump details of a given launch configuration.
- name (str):
The name of the launch configuration to describe.
- region (str, optional):
The AWS region where the launch configuration is located.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
CLI Example:
salt myminion boto3_asg.describe_launch_configuration mylc
- saltext.boto3.modules.boto3_asg.create_launch_configuration(name, image_id, key_name=None, vpc_id=None, vpc_name=None, security_groups=None, user_data=None, instance_type='m1.small', kernel_id=None, ramdisk_id=None, block_device_mappings=None, instance_monitoring=False, spot_price=None, instance_profile_name=None, ebs_optimized=False, associate_public_ip_address=None, region=None, key=None, keyid=None, profile=None)[source]¶
Create a launch configuration.
- name (str):
The name of the launch configuration to create.
- image_id (str):
The ID of the Amazon Machine Image (AMI) to use for the launch configuration.
- key_name (str, optional):
The name of the key pair to use for the instances.
- vpc_id (str, optional):
The ID of the VPC where the launch configuration will be created.
- vpc_name (str, optional):
The name of the VPC where the launch configuration will be created.
- security_groups (list, optional):
A list of security group IDs or names to associate with the instances.
- user_data (str, optional):
The user data to provide when launching the instances.
- instance_type (str, optional):
The instance type for the instances. Default is “m1.small”.
- kernel_id (str, optional):
The ID of the kernel to use for the instances.
- ramdisk_id (str, optional):
The ID of the RAM disk to use for the instances.
- block_device_mappings (list, optional):
A list of block device mapping dictionaries.
- instance_monitoring (bool, optional):
Whether to enable detailed monitoring for the instances. Default is False.
- spot_price (str, optional):
The maximum price to pay for Spot Instances.
- instance_profile_name (str, optional):
The name of the IAM instance profile to associate with the instances.
- ebs_optimized (bool, optional):
Whether the instances should be EBS-optimized. Default is False.
- associate_public_ip_address (bool, optional):
Whether to associate a public IP address with the instances.
- region (str, optional):
The AWS region where the launch configuration will be created.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
CLI Example:
salt myminion boto3_asg.create_launch_configuration mylc image_id=ami-0b9c9f62
- saltext.boto3.modules.boto3_asg.delete_launch_configuration(name, region=None, key=None, keyid=None, profile=None)[source]¶
Delete a launch configuration.
- name (str):
The name of the launch configuration to delete.
- region (str, optional):
The AWS region where the launch configuration is located.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
CLI Example:
salt myminion boto3_asg.delete_launch_configuration mylc
- saltext.boto3.modules.boto3_asg.get_scaling_policy_arn(as_group, scaling_policy_name, region=None, key=None, keyid=None, profile=None)[source]¶
Return the arn for a scaling policy in a specific autoscale group or
Noneif not found. Mainly used as a helper method for boto_cloudwatch_alarm, for linking alarms to scaling policies.- as_group (str):
The name of the AutoScaling group containing the scaling policy.
- scaling_policy_name (str):
The name of the scaling policy for which to retrieve the ARN.
- region (str, optional):
The AWS region where the AutoScaling group is located.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
CLI Example:
salt '*' boto3_asg.get_scaling_policy_arn mygroup mypolicy
- saltext.boto3.modules.boto3_asg.get_all_groups(region=None, key=None, keyid=None, profile=None)[source]¶
Return all AutoScale Groups visible in the account as a list of boto3 describe-response dicts.
- region (str, optional):
The AWS region where the AutoScaling groups are located.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
CLI Example:
salt-call boto3_asg.get_all_groups region=us-east-1 --output yaml
- saltext.boto3.modules.boto3_asg.list_groups(region=None, key=None, keyid=None, profile=None)[source]¶
Return all AutoScale Group names visible in the account.
- region (str, optional):
The AWS region where the AutoScaling groups are located.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
CLI Example:
salt-call boto3_asg.list_groups region=us-east-1
- saltext.boto3.modules.boto3_asg.get_instances(name, lifecycle_state='InService', health_status='Healthy', attribute='private_ip_address', attributes=None, region=None, key=None, keyid=None, profile=None)[source]¶
Return an attribute of all instances in the named autoscale group.
- name (str):
The name of the AutoScaling group.
- lifecycle_state (str, optional):
The desired lifecycle state of the instances to retrieve. Default is “InService”.
- health_status (str, optional):
The desired health status of the instances to retrieve. Default is “Healthy”.
- attribute (str, optional):
The specific instance attribute to return. Default is “private_ip_address”.
- attributes (list, optional):
A list of instance attributes to return. If specified, this overrides the “attribute” parameter.
- region (str, optional):
The AWS region where the AutoScaling group is located.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
CLI Example:
salt-call boto3_asg.get_instances my_autoscale_group_name
- saltext.boto3.modules.boto3_asg.enter_standby(name, instance_ids, should_decrement_desired_capacity=False, region=None, key=None, keyid=None, profile=None)[source]¶
Switch desired instances to StandBy mode
- name (str):
The name of the AutoScaling group.
- instance_ids (list):
A list of instance IDs to switch to StandBy mode.
- should_decrement_desired_capacity (bool, optional):
Whether to decrement the desired capacity of the AutoScaling group. Default is False.
- region (str, optional):
The AWS region where the AutoScaling group is located.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
CLI Example:
salt-call boto3_asg.enter_standby my_autoscale_group_name '["i-xxxxxx"]'
- saltext.boto3.modules.boto3_asg.exit_standby(name, instance_ids, should_decrement_desired_capacity=False, region=None, key=None, keyid=None, profile=None)[source]¶
Exit desired instances from StandBy mode
- name (str):
The name of the AutoScaling group.
- instance_ids (list):
A list of instance IDs to exit from StandBy mode.
- should_decrement_desired_capacity (bool, optional):
Whether to decrement the desired capacity of the AutoScaling group. Default is False.
- region (str, optional):
The AWS region where the AutoScaling group is located.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
CLI Example:
salt-call boto3_asg.exit_standby my_autoscale_group_name '["i-xxxxxx"]'