boto3_ec2¶
Connection module for Amazon EC2 using boto3.¶
Renamed from
boto_ec2toboto3_ec2and rewritten to use the boto3ec2client 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 EC2 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:
ec2.keyid: GKTADJGHEIQSXMKKRBJ08H
ec2.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
A region may also be specified in the configuration:
ec2.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_ec2.get_all_eip_addresses(addresses=None, allocation_ids=None, region=None, key=None, keyid=None, profile=None)[source]¶
Get public addresses of some, or all EIPs associated with the current account.
- addresses (list, optional):
A list of public IP addresses to filter by.
- allocation_ids (list, optional):
A list of allocation IDs to filter by.
- region (str, optional):
The AWS region where the EIPs 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_ec2.get_all_eip_addresses region='us-west-2'
- saltext.boto3.modules.boto3_ec2.get_unassociated_eip_address(domain='standard', region=None, key=None, keyid=None, profile=None)[source]¶
Return the first unassociated EIP (public IP string), or None.
- domain (str, optional):
The domain of the Elastic IP address to filter by. The only permitted value is ‘vpc’.
- region (str, optional):
The AWS region where the EIPs 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_ec2.get_unassociated_eip_address domain='vpc' region='us-west-2'
- saltext.boto3.modules.boto3_ec2.get_eip_address_info(addresses=None, allocation_ids=None, region=None, key=None, keyid=None, profile=None)[source]¶
Get ‘interesting’ info about some, or all EIPs associated with the account.
- addresses (list, optional):
A list of public IP addresses to filter by.
- allocation_ids (list, optional):
A list of allocation IDs to filter by.
- region (str, optional):
The AWS region where the EIPs 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_ec2.get_eip_address_info region='us-west-2'
- saltext.boto3.modules.boto3_ec2.allocate_eip_address(domain=None, region=None, key=None, keyid=None, profile=None)[source]¶
Allocate a new Elastic IP address and return dict of details, or False.
- domain (str, optional):
The domain in which to allocate the Elastic IP address. The only permitted value is ‘vpc’.
- region (str, optional):
The AWS region where the EIP is to be allocated.
- 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_ec2.allocate_eip_address region='us-west-2'
- saltext.boto3.modules.boto3_ec2.release_eip_address(public_ip=None, allocation_id=None, region=None, key=None, keyid=None, profile=None)[source]¶
Free an Elastic IP address. Returns True on success.
- public_ip (str, optional):
The public IP address of the Elastic IP to release.
- allocation_id (str, optional):
The allocation ID of the Elastic IP to release.
- region (str, optional):
The AWS region where the EIP 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_ec2.release_eip_address public_ip='1.2.3.4' region='us-west-2'
- saltext.boto3.modules.boto3_ec2.associate_eip_address(instance_id=None, instance_name=None, public_ip=None, allocation_id=None, network_interface_id=None, network_interface_name=None, private_ip_address=None, allow_reassociation=False, region=None, key=None, keyid=None, profile=None)[source]¶
Associate an Elastic IP address with a running instance or network interface. Returns True on success.
- instance_id (str, optional):
The ID of the instance to associate the Elastic IP with.
- instance_name (str, optional):
The name of the instance to associate the Elastic IP with.
- public_ip (str, optional):
The public IP address of the Elastic IP to associate.
- allocation_id (str, optional):
The allocation ID of the Elastic IP to associate.
- network_interface_id (str, optional):
The ID of the network interface to associate the Elastic IP with.
- network_interface_name (str, optional):
The name of the network interface to associate the Elastic IP with.
- private_ip_address (str, optional):
The private IP address to associate the Elastic IP with.
- allow_reassociation (bool, optional):
Whether to allow reassociation of the Elastic IP. Defaults to False.
- region (str, optional):
The AWS region where the instance or network interface 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_ec2.associate_eip_address instance_id='i-1234567890abcdef0' public_ip='1.2.3.4' region='us-west-2'
- saltext.boto3.modules.boto3_ec2.disassociate_eip_address(public_ip=None, association_id=None, region=None, key=None, keyid=None, profile=None)[source]¶
Disassociate an Elastic IP address. Returns True on success.
- public_ip (str, optional):
The public IP address of the Elastic IP to disassociate.
- association_id (str, optional):
The association ID of the Elastic IP to disassociate.
- region (str, optional):
The AWS region where the EIP 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_ec2.disassociate_eip_address public_ip='1.2.3.4' region='us-west-2'
- saltext.boto3.modules.boto3_ec2.assign_private_ip_addresses(network_interface_name=None, network_interface_id=None, private_ip_addresses=None, secondary_private_ip_address_count=None, allow_reassignment=False, region=None, key=None, keyid=None, profile=None)[source]¶
Assign secondary private IP addresses to an ENI. Returns True on success.
- network_interface_name (str, optional):
The name of the network interface to assign private IP addresses to.
- network_interface_id (str, optional):
The ID of the network interface to assign private IP addresses to.
- private_ip_addresses (list, optional):
A list of private IP addresses to assign to the network interface.
- secondary_private_ip_address_count (int, optional):
The number of secondary private IP addresses to assign to the network interface.
- allow_reassignment (bool, optional):
Whether to allow reassignment of the private IP addresses. Defaults to False.
- region (str, optional):
The AWS region where the network interface 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_ec2.assign_private_ip_addresses network_interface_id='eni-12345678' private_ip_addresses='["10.0.0.1"]' region='us-west-2'
- saltext.boto3.modules.boto3_ec2.unassign_private_ip_addresses(network_interface_name=None, network_interface_id=None, private_ip_addresses=None, region=None, key=None, keyid=None, profile=None)[source]¶
Unassign secondary private IP addresses from an ENI. Returns True on success.
- network_interface_name (str, optional):
The name of the network interface to unassign private IP addresses from.
- network_interface_id (str, optional):
The ID of the network interface to unassign private IP addresses from.
- private_ip_addresses (list, optional):
A list of private IP addresses to unassign from the network interface.
- region (str, optional):
The AWS region where the network interface 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_ec2.unassign_private_ip_addresses region='us-west-2'
- saltext.boto3.modules.boto3_ec2.get_zones(region=None, key=None, keyid=None, profile=None)[source]¶
Get the list of AZ names for the configured region.
- region (str, optional):
The AWS region where the availability zones 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_ec2.get_zones region='us-west-2'
- saltext.boto3.modules.boto3_ec2.find_instances(instance_id=None, name=None, tags=None, region=None, key=None, keyid=None, profile=None, return_objs=False, in_states=None, filters=None)[source]¶
Given instance properties, find and return matching instance ids (default) or the raw boto3 instance dicts (when
return_objsis True).- instance_id (str, optional):
The ID of the instance to find.
- name (str, optional):
The name tag of the instance to find.
- tags (dict, optional):
A dictionary of tags to filter instances by.
- region (str, optional):
The AWS region where the instances 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.
- return_objs (bool, optional):
Whether to return the raw boto3 instance dicts instead of instance IDs.
- in_states (list, optional):
A list of instance states to filter by.
- filters (dict, optional):
Additional filters to apply when searching for instances.
CLI Example:
salt-call boto3_ec2.find_instances region='us-west-2'
- saltext.boto3.modules.boto3_ec2.create_image(ami_name, instance_id=None, instance_name=None, tags=None, region=None, key=None, keyid=None, profile=None, description=None, no_reboot=False, dry_run=False, filters=None)[source]¶
Create an AMI from a single matched instance. Returns AMI id or False.
- ami_name (str):
The name of the AMI to create.
- instance_id (str, optional):
The ID of the instance to create the AMI from.
- instance_name (str, optional):
The name tag of the instance to create the AMI from.
- tags (dict, optional):
A dictionary of tags to apply to the AMI.
- region (str, optional):
The AWS region where the instance 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.
- description (str, optional):
A description for the AMI.
- no_reboot (bool, optional):
Whether to avoid rebooting the instance when creating the AMI. Defaults to False.
- dry_run (bool, optional):
Whether to perform a dry run of the AMI creation. Defaults to False.
- filters (dict, optional):
Additional filters to apply when searching for the source instance.
CLI Example:
salt-call boto3_ec2.create_image ami_name='my-ami' instance_id='i-1234567890abcdef0' region='us-west-2'
- saltext.boto3.modules.boto3_ec2.find_images(ami_name=None, executable_by=None, owners=None, image_ids=None, tags=None, region=None, key=None, keyid=None, profile=None, return_objs=False)[source]¶
Return matching AMI ids, or objects when
return_objsis True. Returns False when no images are found.- ami_name (str, optional):
The name of the AMI to find.
- executable_by (list, optional):
A list of AWS account IDs or ‘self’ to filter AMIs by who can execute them.
- owners (list, optional):
A list of AWS account IDs or ‘self’ to filter AMIs by their owners.
- image_ids (list, optional):
A list of AMI IDs to filter by.
- tags (dict, optional):
A dictionary of tags to filter AMIs by.
- region (str, optional):
The AWS region where the AMIs 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.
- return_objs (bool, optional):
Whether to return the raw boto3 AMI dicts instead of AMI IDs.
CLI Example:
salt-call boto3_ec2.find_images region='us-west-2'
- saltext.boto3.modules.boto3_ec2.terminate(instance_id=None, name=None, region=None, key=None, keyid=None, profile=None, filters=None)[source]¶
Terminate the instance described by instance_id or Name tag.
- instance_id (str, optional):
The ID of the instance to terminate.
- name (str, optional):
The name tag of the instance to terminate.
- region (str, optional):
The AWS region where the instance 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.
- filters (dict, optional):
Additional filters to apply when searching for the instance to terminate.
CLI Example:
salt-call boto3_ec2.terminate region='us-west-2'
- saltext.boto3.modules.boto3_ec2.get_id(name=None, tags=None, region=None, key=None, keyid=None, profile=None, in_states=None, filters=None)[source]¶
Return a single instance id matching the given properties, or None.
- name (str, optional):
The name tag of the instance to find.
- tags (dict, optional):
A dictionary of tags to filter instances by.
- region (str, optional):
The AWS region where the instance 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.
- in_states (list, optional):
A list of instance states to filter by.
- filters (dict, optional):
Additional filters to apply when searching for the instance.
CLI Example:
salt-call boto3_ec2.get_id region='us-west-2'
- saltext.boto3.modules.boto3_ec2.get_tags(instance_id=None, keyid=None, key=None, profile=None, region=None)[source]¶
Return a list of {name: value} tag dicts for an instance.
- instance_id (str, optional):
The ID of the instance to retrieve tags for.
- keyid (str, optional):
The AWS access key ID.
- key (str, optional):
The AWS secret access key.
- profile (str, optional):
The profile to use for AWS credentials.
- region (str, optional):
The AWS region where the instance is located.
CLI Example:
salt-call boto3_ec2.get_tags region='us-west-2'
- saltext.boto3.modules.boto3_ec2.exists(instance_id=None, name=None, tags=None, region=None, key=None, keyid=None, profile=None, in_states=None, filters=None)[source]¶
Return True if any instance matching the given properties exists.
- instance_id (str, optional):
The ID of the instance to check for existence.
- name (str, optional):
The name tag of the instance to check for existence.
- tags (dict, optional):
A dictionary of tags to filter instances by.
- region (str, optional):
The AWS region where the instance 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.
- in_states (list, optional):
A list of instance states to filter by.
- filters (dict, optional):
Additional filters to apply when searching for the instance.
CLI Example:
salt-call boto3_ec2.exists region='us-west-2'
- saltext.boto3.modules.boto3_ec2.run(image_id, name=None, tags=None, key_name=None, security_groups=None, user_data=None, instance_type='m1.small', placement=None, kernel_id=None, ramdisk_id=None, monitoring_enabled=None, vpc_id=None, vpc_name=None, subnet_id=None, subnet_name=None, private_ip_address=None, block_device_map=None, disable_api_termination=None, instance_initiated_shutdown_behavior=None, placement_group=None, client_token=None, security_group_ids=None, security_group_names=None, additional_info=None, tenancy=None, instance_profile_arn=None, instance_profile_name=None, ebs_optimized=None, network_interface_id=None, network_interface_name=None, region=None, key=None, keyid=None, profile=None, network_interfaces=None)[source]¶
Create and start an EC2 instance. Returns
{"instance_id": ...}on success, False otherwise.- instance_id (str, optional):
The ID of the instance to create or start.
- name (str, optional):
The name tag of the instance to create or start.
- tags (dict, optional):
A dictionary of tags to assign to the instance.
- key_name (str, optional):
The name of the key pair to use for the instance.
- security_groups (list, optional):
A list of security group names to associate with the instance.
- user_data (str, optional):
The user data to provide when launching the instance.
- instance_type (str, optional):
The type of instance to create (e.g., “t2.micro”).
- placement (str, optional):
The placement constraint for the instance (e.g., availability zone).
- kernel_id (str, optional):
The ID of the kernel to use for the instance.
- ramdisk_id (str, optional):
The ID of the RAM disk to use for the instance.
- monitoring_enabled (bool, optional):
Whether detailed monitoring is enabled for the instance.
- vpc_id (str, optional):
The ID of the VPC in which to launch the instance.
- vpc_name (str, optional):
The name of the VPC in which to launch the instance.
- subnet_id (str, optional):
The ID of the subnet in which to launch the instance.
- subnet_name (str, optional):
The name of the subnet in which to launch the instance.
- private_ip_address (str, optional):
The private IP address to assign to the instance.
- block_device_map (list, optional):
A list of block device mappings for the instance.
- disable_api_termination (bool, optional):
Whether to disable API termination for the instance.
- instance_initiated_shutdown_behavior (str, optional):
The shutdown behavior for the instance (e.g., “stop” or “terminate”).
- placement_group (str, optional):
The name of the placement group in which to launch the instance.
- client_token (str, optional):
A unique, case-sensitive token to ensure idempotency of the request.
- security_group_ids (list, optional):
A list of security group IDs to associate with the instance.
- security_group_names (list, optional):
A list of security group names to associate with the instance.
- additional_info (str, optional):
Additional information to provide when launching the instance.
- tenancy (str, optional):
The tenancy of the instance (e.g., “default” or “dedicated”).
- instance_profile_arn (str, optional):
The ARN of the instance profile to associate with the instance.
- instance_profile_name (str, optional):
The name of the instance profile to associate with the instance.
- ebs_optimized (bool, optional):
Whether the instance is optimized for EBS I/O.
- network_interface_id (str, optional):
The ID of the network interface to associate with the instance.
- network_interface_name (str, optional):
The name of the network interface to associate with the instance.
- region (str, optional):
The AWS region where the instance should 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.
- network_interfaces (list, optional):
A list of network interfaces to associate with the instance.
CLI Example:
salt-call boto3_ec2.run region='us-west-2'
- saltext.boto3.modules.boto3_ec2.get_key(key_name, region=None, key=None, keyid=None, profile=None)[source]¶
Return
(name, fingerprint)if the key exists, else False.- key_name (str):
The name of the key pair to retrieve.
- region (str, optional):
The AWS region where the key pair 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_ec2.get_key my-key-name region='us-west-2'
- saltext.boto3.modules.boto3_ec2.create_key(key_name, save_path, region=None, key=None, keyid=None, profile=None)[source]¶
Create a new key pair, save the private material to
save_pathand return it.- key_name (str):
The name of the key pair to create.
- save_path (str):
The directory path where the private key material will be saved.
- region (str, optional):
The AWS region where the key pair 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-call boto3_ec2.create_key my-key-name /path/to/save region='us-west-2'
- saltext.boto3.modules.boto3_ec2.import_key(key_name, public_key_material, region=None, key=None, keyid=None, profile=None)[source]¶
Import a key pair by public material. Returns the fingerprint or False.
- key_name (str):
The name of the key pair to import.
- public_key_material (str):
The public key material to import.
- region (str, optional):
The AWS region where the key pair will be imported.
- 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_ec2.import_key my-key-name /path/to/public/key.pub region='us-west-2'
- saltext.boto3.modules.boto3_ec2.delete_key(key_name, region=None, key=None, keyid=None, profile=None)[source]¶
Delete a key pair. Returns True on success.
- key_name (str):
The name of the key pair to delete.
- region (str, optional):
The AWS region where the key pair 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_ec2.delete_key my-key-name region='us-west-2'
- saltext.boto3.modules.boto3_ec2.get_keys(keynames=None, filters=None, region=None, key=None, keyid=None, profile=None)[source]¶
Return a list of key pair names matching
keynamesandfilters.- keynames (list, optional):
A list of key pair names to filter the results.
- filters (dict, optional):
A dictionary of filters to apply when retrieving key pairs.
- region (str, optional):
The AWS region where the key pairs 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_ec2.get_keys
- saltext.boto3.modules.boto3_ec2.get_attribute(attribute, instance_name=None, instance_id=None, region=None, key=None, keyid=None, profile=None, filters=None)[source]¶
Return
{attribute: value}for an EC2 instance, or False.- attribute (str):
The attribute of the EC2 instance to retrieve.
- instance_name (str, optional):
The name of the EC2 instance.
- instance_id (str, optional):
The ID of the EC2 instance.
- region (str, optional):
The AWS region where the EC2 instance 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.
- filters (dict, optional):
A dictionary of filters to apply when retrieving the EC2 instance attribute.
CLI Example:
salt-call boto3_ec2.get_attribute
- saltext.boto3.modules.boto3_ec2.set_attribute(attribute, attribute_value, instance_name=None, instance_id=None, region=None, key=None, keyid=None, profile=None, filters=None)[source]¶
Set an EC2 instance attribute. Returns True on success, False on failure.
- attribute (str):
The attribute of the EC2 instance to set.
- attribute_value (any):
The value to set for the specified attribute.
- instance_name (str, optional):
The name of the EC2 instance.
- instance_id (str, optional):
The ID of the EC2 instance.
- region (str, optional):
The AWS region where the EC2 instance 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.
- filters (dict, optional):
A dictionary of filters to apply when setting the EC2 instance attribute.
CLI Example:
salt-call boto3_ec2.set_attribute attribute=instanceType attribute_value=t2.micro instance_name=my-instance
- saltext.boto3.modules.boto3_ec2.get_network_interface_id(name, region=None, key=None, keyid=None, profile=None)[source]¶
Return
{"result": eni_id}or{"error": {...}}.- name (str):
The name tag of the network interface to retrieve.
- region (str, optional):
The AWS region where the network interface 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_ec2.get_network_interface_id name=my-eni
- saltext.boto3.modules.boto3_ec2.get_network_interface(name=None, network_interface_id=None, region=None, key=None, keyid=None, profile=None)[source]¶
Return
{"result": {...}}or{"error": {...}}.- name (str, optional):
The name tag of the network interface to retrieve.
- network_interface_id (str, optional):
The ID of the network interface to retrieve.
- region (str, optional):
The AWS region where the network interface 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_ec2.get_network_interface name=my-eni
- saltext.boto3.modules.boto3_ec2.create_network_interface(name, subnet_id=None, subnet_name=None, private_ip_address=None, description=None, groups=None, region=None, key=None, keyid=None, profile=None)[source]¶
Create an ENI tagged with
Name=<name>.- name (str):
The name tag of the network interface to create.
- subnet_id (str, optional):
The ID of the subnet in which to create the network interface.
- subnet_name (str, optional):
The name tag of the subnet in which to create the network interface.
- private_ip_address (str, optional):
The private IP address to assign to the network interface.
- description (str, optional):
A description for the network interface.
- groups (list, optional):
A list of security group names or IDs to associate with the network interface.
- region (str, optional):
The AWS region where the network interface should 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-call boto3_ec2.create_network_interface name=my-eni subnet_id=subnet-12345678
- saltext.boto3.modules.boto3_ec2.delete_network_interface(name=None, network_interface_id=None, region=None, key=None, keyid=None, profile=None)[source]¶
Delete an ENI.
- name (str, optional):
The name tag of the network interface to delete.
- network_interface_id (str, optional):
The ID of the network interface to delete.
- region (str, optional):
The AWS region where the network interface 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_ec2.delete_network_interface name=my-eni
- saltext.boto3.modules.boto3_ec2.attach_network_interface(device_index, name=None, network_interface_id=None, instance_name=None, instance_id=None, region=None, key=None, keyid=None, profile=None)[source]¶
Attach an ENI to an instance.
- device_index (int):
The device index for the network interface attachment.
- name (str, optional):
The name tag of the network interface to attach.
- network_interface_id (str, optional):
The ID of the network interface to attach.
- instance_name (str, optional):
The name tag of the instance to attach the network interface to.
- instance_id (str, optional):
The ID of the instance to attach the network interface to.
- region (str, optional):
The AWS region where the network interface and instance 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_ec2.attach_network_interface device_index=1 name=my-eni instance_name=my-instance
- saltext.boto3.modules.boto3_ec2.detach_network_interface(name=None, network_interface_id=None, attachment_id=None, force=False, region=None, key=None, keyid=None, profile=None)[source]¶
Detach an ENI.
- name (str, optional):
The name tag of the network interface to detach.
- network_interface_id (str, optional):
The ID of the network interface to detach.
- attachment_id (str, optional):
The ID of the network interface attachment to detach.
- force (bool, optional):
Whether to force the detachment.
- region (str, optional):
The AWS region where the network interface 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_ec2.detach_network_interface name=my-eni
- saltext.boto3.modules.boto3_ec2.modify_network_interface_attribute(name=None, network_interface_id=None, attr=None, value=None, region=None, key=None, keyid=None, profile=None)[source]¶
Modify an ENI attribute: description, source_dest_check, groups, delete_on_termination.
- name (str, optional):
The name tag of the network interface to modify.
- network_interface_id (str, optional):
The ID of the network interface to modify.
- attr (str, optional):
The attribute of the network interface to modify. Valid values are: description, source_dest_check, groups, delete_on_termination.
- value (varies, optional):
The new value for the specified attribute.
- region (str, optional):
The AWS region where the network interface 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_ec2.modify_network_interface_attribute name=my-eni attr=description value="New description"
- saltext.boto3.modules.boto3_ec2.get_all_volumes(volume_ids=None, filters=None, return_objs=False, region=None, key=None, keyid=None, profile=None)[source]¶
Return a list of volume IDs or describe-volume dicts.
- name (str, optional):
The name tag of the volume to retrieve.
- volume_ids (list, optional):
A list of volume IDs to retrieve.
- filters (dict, optional):
A dictionary of filters to apply when retrieving volumes.
- return_objs (bool, optional):
Whether to return the full volume objects or just the volume IDs.
- region (str, optional):
The AWS region where the volumes 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_ec2.get_all_volumes name=my-volume
- saltext.boto3.modules.boto3_ec2.set_volumes_tags(tag_maps, authoritative=False, dry_run=False, region=None, key=None, keyid=None, profile=None)[source]¶
Apply tags to EBS volumes. See legacy
boto_ec2.set_volumes_tagsfor the schema.- tag_maps (list):
A list of dictionaries containing the filters and tags to apply to the volumes. Each dictionary should have the following structure:
{ "filters": {"volume_ids": ["vol-12345678"], "instance_name": "my-instance"}, "tags": {"Key1": "Value1", "Key2": "Value2"}, "in_states": ["running", "stopped"], # Optional } # Repeat for each volume you want to tag
- authoritative (bool, optional):
Whether to replace existing tags with the new tags (True) or merge them (False).
- dry_run (bool, optional):
If True, checks whether you have the required permissions for the action, without actually making the request.
- region (str, optional):
The AWS region where the volumes 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_ec2.set_volumes_tags tag_maps='[{"filters": {"volume_ids": ["vol-12345678"]}, "tags": {"Key1": "Value1", "Key2": "Value2"}}]'
- saltext.boto3.modules.boto3_ec2.get_all_tags(filters=None, region=None, key=None, keyid=None, profile=None)[source]¶
Describe all tags matching the filter criteria.
- filters (dict, optional):
A dictionary of filters to apply when retrieving tags. The keys should be the filter names and the values should be the filter values. For example:
{"resource_id": ["vol-12345678"], "key": "Key1"}
- region (str, optional):
The AWS region where the resources 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_ec2.get_all_tags filters='{"resource_id": ["vol-12345678"], "key": "Key1"}'
- saltext.boto3.modules.boto3_ec2.create_tags(resource_ids, tags, region=None, key=None, keyid=None, profile=None)[source]¶
Create metadata tags on the given resources.
- resource_ids (list):
A list of resource IDs to tag.
- tags (dict):
A dictionary of tags to apply to the resources. The keys are the tag names and the values are the tag values.
- region (str, optional):
The AWS region where the resources 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_ec2.create_tags resource_ids='["vol-12345678"]' tags='{"Key1": "Value1", "Key2": "Value2"}'
- saltext.boto3.modules.boto3_ec2.delete_tags(resource_ids, tags, region=None, key=None, keyid=None, profile=None)[source]¶
Delete metadata tags from the given resources.
- resource_ids (list):
A list of resource IDs from which to delete tags.
- tags (dict or list):
A dictionary of tags to delete from the resources. The keys are the tag names and the values are the tag values. If a list is provided, it should be a list of tag names to delete.
- region (str, optional):
The AWS region where the resources 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_ec2.delete_tags resource_ids='["vol-12345678"]' tags='{"Key1": "Value1", "Key2": "Value2"}' region='us-west-2'
- saltext.boto3.modules.boto3_ec2.detach_volume(volume_id, instance_id=None, device=None, force=False, wait_for_detachement=False, region=None, key=None, keyid=None, profile=None)[source]¶
Detach an EBS volume. Returns True on success.
- volume_id (str):
The ID of the EBS volume to detach.
- instance_id (str, optional):
The ID of the instance from which to detach the volume.
- device (str, optional):
The device name to detach.
- force (bool, optional):
Whether to force the detachment.
- wait_for_detachement (bool, optional):
Whether to wait for the volume to be fully detached before returning.
- region (str, optional):
The AWS region where the volume 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_ec2.detach_volume volume_id='vol-12345678' instance_id='i-12345678' device='/dev/sdh' force=True wait_for_detachement=True
- saltext.boto3.modules.boto3_ec2.delete_volume(volume_id, instance_id=None, device=None, force=False, region=None, key=None, keyid=None, profile=None)[source]¶
Delete an EBS volume. Set
force=Trueto force-detach first.- volume_id (str):
The ID of the EBS volume to delete.
- instance_id (str, optional):
The ID of the instance from which to detach the volume before deletion.
- device (str, optional):
The device name to detach before deletion.
- force (bool, optional):
Whether to force the detachment before deletion.
- region (str, optional):
The AWS region where the volume 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_ec2.delete_volume volume_id='vol-12345678' instance_id='i-12345678' device='/dev/sdh' force=True
- saltext.boto3.modules.boto3_ec2.attach_volume(volume_id, instance_id, device, region=None, key=None, keyid=None, profile=None)[source]¶
Attach an EBS volume. Returns True on success.
- volume_id (str):
The ID of the EBS volume to attach.
- instance_id (str):
The ID of the instance to which to attach the volume.
- device (str):
The device name to attach the volume as.
- region (str, optional):
The AWS region where the volume and instance 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_ec2.attach_volume volume_id='vol-12345678' instance_id='i-12345678' device='/dev/sdh'
- saltext.boto3.modules.boto3_ec2.create_volume(zone_name, size=None, snapshot_id=None, volume_type=None, iops=None, encrypted=False, kms_key_id=None, wait_for_creation=False, region=None, key=None, keyid=None, profile=None)[source]¶
Create an EBS volume. Returns
{"result": vol_id}or{"error": ...}.- zone_name (str):
The availability zone in which to create the volume.
- size (int, optional):
The size of the volume in GiB.
- snapshot_id (str, optional):
The ID of the snapshot from which to create the volume.
- volume_type (str, optional):
The type of the volume (e.g., ‘gp2’, ‘io1’).
- iops (int, optional):
The number of IOPS for the volume (required for ‘io1’ type).
- encrypted (bool, optional):
Whether the volume should be encrypted.
- kms_key_id (str, optional):
The ID of the KMS key to use for encryption.
- wait_for_creation (bool, optional):
Whether to wait for the volume to become available before returning.
- region (str, optional):
The AWS region where the volume should 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-call boto3_ec2.create_volume zone_name='us-west-2a' size=10 volume_type='gp2' encrypted=True
- saltext.boto3.modules.boto3_ec2.describe_instance_metadata_options(instance_id, region=None, key=None, keyid=None, profile=None)[source]¶
Return the current Instance Metadata Service (IMDS) options for an instance.
- instance_id
The ID of the EC2 instance.
- region (str, optional):
The AWS region where the instance 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_ec2.describe_instance_metadata_options i-0123456789abcdef0 region='us-west-2'
- saltext.boto3.modules.boto3_ec2.modify_instance_metadata_options(instance_id, http_tokens=None, http_put_response_hop_limit=None, http_endpoint=None, http_protocol_ipv6=None, instance_metadata_tags=None, region=None, key=None, keyid=None, profile=None)[source]¶
Modify the Instance Metadata Service (IMDS) options for an instance.
- instance_id (str):
The ID of the EC2 instance.
- http_tokens (str, optional):
optionalorrequired.requiredenforces IMDSv2.- http_put_response_hop_limit (int, optional):
Integer 1-64. Desired HTTP PUT response hop limit for metadata requests.
- http_endpoint (str, optional):
enabledordisabled.- http_protocol_ipv6 (str, optional):
enabledordisabled.- instance_metadata_tags (str, optional):
enabledordisabled.- region (str, optional):
The AWS region where the instance 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_ec2.modify_instance_metadata_options i-01234 http_tokens=required
- saltext.boto3.modules.boto3_ec2.require_imdsv2(instance_id, region=None, key=None, keyid=None, profile=None)[source]¶
Convenience wrapper to enforce IMDSv2 on an instance by setting
HttpTokens=requiredandHttpEndpoint=enabled.- instance_id (str):
The ID of the EC2 instance.
- region (str, optional):
The AWS region where the instance 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. The ID of the EC2 instance.
CLI Example:
salt '*' boto3_ec2.require_imdsv2 i-0123456789abcdef0