INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
Make a package repository and optionally sign it and packages present Given the repodir (directory to create repository in), create a Debian repository and optionally sign it and packages present. This state is best used with onchanges linked to your package building states. repodir The direct...
def make_repo(repodir, keyid=None, env=None, use_passphrase=False, gnupghome='/etc/salt/gpgkeys', runas='root', timeout=15.0): ''' Make a package repository and optionally sign it and packages present Given the repodir (dir...
Generate a Vault token for minion minion_id minion_id The id of the minion that requests a token signature Cryptographic signature which validates that the request is indeed sent by the minion (or the master, see impersonated_by_master). impersonated_by_master If the maste...
def generate_token(minion_id, signature, impersonated_by_master=False): ''' Generate a Vault token for minion minion_id minion_id The id of the minion that requests a token signature Cryptographic signature which validates that the request is indeed sent by the minion (or the m...
Unseal Vault server This function uses the 'keys' from the 'vault' configuration to unseal vault server vault: keys: - n63/TbrQuL3xaIW7ZZpuXj/tIfnK1/MbVxO4vT3wYD2A - S9OwCvMRhErEA4NVVELYBs6w/Me6+urgUr24xGK44Uy3 - F1j4b7JKq850NS6Kboiy5laJ0xY8dWJvB3fcwA+SraYl - 1cYtvjKJNDVa...
def unseal(): ''' Unseal Vault server This function uses the 'keys' from the 'vault' configuration to unseal vault server vault: keys: - n63/TbrQuL3xaIW7ZZpuXj/tIfnK1/MbVxO4vT3wYD2A - S9OwCvMRhErEA4NVVELYBs6w/Me6+urgUr24xGK44Uy3 - F1j4b7JKq850NS6Kboiy5laJ0xY8dWJvB3fcwA+Sr...
Validate that either minion with id minion_id, or the master, signed the request
def _validate_signature(minion_id, signature, impersonated_by_master): ''' Validate that either minion with id minion_id, or the master, signed the request ''' pki_dir = __opts__['pki_dir'] if impersonated_by_master: public_key = '{0}/master.pub'.format(pki_dir) else: public_...
Get the policies that should be applied to a token for minion_id
def _get_policies(minion_id, config): ''' Get the policies that should be applied to a token for minion_id ''' _, grains, _ = salt.utils.minions.get_minion_data(minion_id, __opts__) policy_patterns = config.get( 'policies', ['saltstac...
Expands the pattern for any list-valued mappings, such that for any list of length N in the mappings present in the pattern, N copies of the pattern are returned, each with an element of the list substituted. pattern: A pattern to expand, for example ``by-role/{grains[roles]}`` mappings: ...
def _expand_pattern_lists(pattern, **mappings): ''' Expands the pattern for any list-valued mappings, such that for any list of length N in the mappings present in the pattern, N copies of the pattern are returned, each with an element of the list substituted. pattern: A pattern to expand, ...
Validate the current token exists and is still valid
def _selftoken_expired(): ''' Validate the current token exists and is still valid ''' try: verify = __opts__['vault'].get('verify', None) url = '{0}/v1/auth/token/lookup-self'.format(__opts__['vault']['url']) if 'token' not in __opts__['vault']['auth']: return True ...
Create Vault url for token creation
def _get_token_create_url(config): ''' Create Vault url for token creation ''' role_name = config.get('role_name', None) auth_path = '/v1/auth/token/create' base_url = config['url'] return '/'.join(x.strip('/') for x in (base_url, auth_path, role_name) if x)
Given function name, find and return matching Lambda information.
def _find_function(name, region=None, key=None, keyid=None, profile=None): ''' Given function name, find and return matching Lambda information. ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) for funcs in __utils__['boto3.paged_call'](conn.list_functio...
Given a function name, check to see if the given function name exists. Returns True if the given function exists and returns False if the given function does not exist. CLI Example: .. code-block:: bash salt myminion boto_lambda.function_exists myfunction
def function_exists(FunctionName, region=None, key=None, keyid=None, profile=None): ''' Given a function name, check to see if the given function name exists. Returns True if the given function exists and returns False if the given function does not exist. CLI Example: .. ...
.. versionadded:: 2017.7.0 Given a valid config, create a function. Environment The parent object that contains your environment's configuration settings. This is a dictionary of the form: .. code-block:: python { 'Variables': { 'Variab...
def create_function(FunctionName, Runtime, Role, Handler, ZipFile=None, S3Bucket=None, S3Key=None, S3ObjectVersion=None, Description="", Timeout=3, MemorySize=128, Publish=False, WaitForRole=False, RoleRetries=5, region=None, key=None, keyi...
Given a function name and optional version qualifier, delete it. Returns {deleted: true} if the function was deleted and returns {deleted: false} if the function was not deleted. CLI Example: .. code-block:: bash salt myminion boto_lambda.delete_function myfunction
def delete_function(FunctionName, Qualifier=None, region=None, key=None, keyid=None, profile=None): ''' Given a function name and optional version qualifier, delete it. Returns {deleted: true} if the function was deleted and returns {deleted: false} if the function was not deleted. CLI Example: ...
Given a function name describe its properties. Returns a dictionary of interesting properties. CLI Example: .. code-block:: bash salt myminion boto_lambda.describe_function myfunction
def describe_function(FunctionName, region=None, key=None, keyid=None, profile=None): ''' Given a function name describe its properties. Returns a dictionary of interesting properties. CLI Example: .. code-block:: bash salt myminion boto_lambda.describe_function myf...
.. versionadded:: 2017.7.0 Update the named lambda function to the configuration. Environment The parent object that contains your environment's configuration settings. This is a dictionary of the form: .. code-block:: python { 'Variables': { ...
def update_function_config(FunctionName, Role=None, Handler=None, Description=None, Timeout=None, MemorySize=None, region=None, key=None, keyid=None, profile=None, VpcConfig=None, WaitForRole=False, RoleRetries=5, ...
Upload the given code to the named lambda function. Returns {updated: true} if the function was updated and returns {updated: False} if the function was not updated. CLI Example: .. code-block:: bash salt myminion boto_lamba.update_function_code my_function ZipFile=function.zip
def update_function_code(FunctionName, ZipFile=None, S3Bucket=None, S3Key=None, S3ObjectVersion=None, Publish=False, region=None, key=None, keyid=None, profile=None): ''' Upload the given code to the named lambda function. Returns {updated: true} if the fun...
Add a permission to a lambda function. Returns {added: true} if the permission was added and returns {added: False} if the permission was not added. CLI Example: .. code-block:: bash salt myminion boto_lamba.add_permission my_function my_id "lambda:*" \\ s3.amazona...
def add_permission(FunctionName, StatementId, Action, Principal, SourceArn=None, SourceAccount=None, Qualifier=None, region=None, key=None, keyid=None, profile=None): ''' Add a permission to a lambda function. Returns {added: true} if the permission was added and retur...
Remove a permission from a lambda function. Returns {removed: true} if the permission was removed and returns {removed: False} if the permission was not removed. CLI Example: .. code-block:: bash salt myminion boto_lamba.remove_permission my_function my_id
def remove_permission(FunctionName, StatementId, Qualifier=None, region=None, key=None, keyid=None, profile=None): ''' Remove a permission from a lambda function. Returns {removed: true} if the permission was removed and returns {removed: False} if the permission was not removed. ...
Get resource permissions for the given lambda function Returns dictionary of permissions, by statement ID CLI Example: .. code-block:: bash salt myminion boto_lamba.get_permissions my_function permissions: {...}
def get_permissions(FunctionName, Qualifier=None, region=None, key=None, keyid=None, profile=None): ''' Get resource permissions for the given lambda function Returns dictionary of permissions, by statement ID CLI Example: .. code-block:: bash salt myminion boto_lamba...
List all Lambda functions visible in the current scope. CLI Example: .. code-block:: bash salt myminion boto_lambda.list_functions
def list_functions(region=None, key=None, keyid=None, profile=None): ''' List all Lambda functions visible in the current scope. CLI Example: .. code-block:: bash salt myminion boto_lambda.list_functions ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) ...
List the versions available for the given function. Returns list of function versions CLI Example: .. code-block:: yaml versions: - {...} - {...}
def list_function_versions(FunctionName, region=None, key=None, keyid=None, profile=None): ''' List the versions available for the given function. Returns list of function versions CLI Example: .. code-block:: yaml versions: - {...} - {...} ...
Given a valid config, create an alias to a function. Returns {created: true} if the alias was created and returns {created: False} if the alias was not created. CLI Example: .. code-block:: bash salt myminion boto_lamba.create_alias my_function my_alias $LATEST "An alias"
def create_alias(FunctionName, Name, FunctionVersion, Description="", region=None, key=None, keyid=None, profile=None): ''' Given a valid config, create an alias to a function. Returns {created: true} if the alias was created and returns {created: False} if the alias was not created. ...
Given function name and alias name, find and return matching alias information.
def _find_alias(FunctionName, Name, FunctionVersion=None, region=None, key=None, keyid=None, profile=None): ''' Given function name and alias name, find and return matching alias information. ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) args = { ...
Given a function name and alias name, check to see if the given alias exists. Returns True if the given alias exists and returns False if the given alias does not exist. CLI Example: .. code-block:: bash salt myminion boto_lambda.alias_exists myfunction myalias
def alias_exists(FunctionName, Name, region=None, key=None, keyid=None, profile=None): ''' Given a function name and alias name, check to see if the given alias exists. Returns True if the given alias exists and returns False if the given alias does not exist. CLI Example: .....
Given a function name and alias name describe the properties of the alias. Returns a dictionary of interesting properties. CLI Example: .. code-block:: bash salt myminion boto_lambda.describe_alias myalias
def describe_alias(FunctionName, Name, region=None, key=None, keyid=None, profile=None): ''' Given a function name and alias name describe the properties of the alias. Returns a dictionary of interesting properties. CLI Example: .. code-block:: bash salt myminion boto_...
Update the named alias to the configuration. Returns {updated: true} if the alias was updated and returns {updated: False} if the alias was not updated. CLI Example: .. code-block:: bash salt myminion boto_lamba.update_alias my_lambda my_alias $LATEST
def update_alias(FunctionName, Name, FunctionVersion=None, Description=None, region=None, key=None, keyid=None, profile=None): ''' Update the named alias to the configuration. Returns {updated: true} if the alias was updated and returns {updated: False} if the alias was not updated. ...
Identifies a stream as an event source for a Lambda function. It can be either an Amazon Kinesis stream or an Amazon DynamoDB stream. AWS Lambda invokes the specified function when records are posted to the stream. Returns {created: true} if the event source mapping was created and returns {created: Fa...
def create_event_source_mapping(EventSourceArn, FunctionName, StartingPosition, Enabled=True, BatchSize=100, region=None, key=None, keyid=None, profile=None): ''' Identifies a stream as an event source for a Lambda function. It can be either an...
Given an event source and function name, return a list of mapping IDs CLI Example: .. code-block:: bash salt myminion boto_lambda.get_event_source_mapping_ids arn:::: myfunction
def get_event_source_mapping_ids(EventSourceArn, FunctionName, region=None, key=None, keyid=None, profile=None): ''' Given an event source and function name, return a list of mapping IDs CLI Example: .. code-block:: bash salt myminion boto_lambda.get_event_sou...
Given an event source mapping ID or an event source ARN and FunctionName, delete the event source mapping Returns {deleted: true} if the mapping was deleted and returns {deleted: false} if the mapping was not deleted. CLI Example: .. code-block:: bash salt myminion boto_lambda.delete_eve...
def delete_event_source_mapping(UUID=None, EventSourceArn=None, FunctionName=None, region=None, key=None, keyid=None, profile=None): ''' Given an event source mapping ID or an event source ARN and FunctionName, delete the event source mapping Returns {deleted: true} if t...
Given an event source mapping ID or an event source ARN and FunctionName, check whether the mapping exists. Returns True if the given alias exists and returns False if the given alias does not exist. CLI Example: .. code-block:: bash salt myminion boto_lambda.alias_exists myfunction myal...
def event_source_mapping_exists(UUID=None, EventSourceArn=None, FunctionName=None, region=None, key=None, keyid=None, profile=None): ''' Given an event source mapping ID or an event source ARN and FunctionName, check whether the mapping exists....
Given an event source mapping ID or an event source ARN and FunctionName, obtain the current settings of that mapping. Returns a dictionary of interesting properties. CLI Example: .. code-block:: bash salt myminion boto_lambda.describe_event_source_mapping uuid
def describe_event_source_mapping(UUID=None, EventSourceArn=None, FunctionName=None, region=None, key=None, keyid=None, profile=None): ''' Given an event source mapping ID or an event source ARN and FunctionName, obtain the current settings...
Update the event source mapping identified by the UUID. Returns {updated: true} if the alias was updated and returns {updated: False} if the alias was not updated. CLI Example: .. code-block:: bash salt myminion boto_lamba.update_event_source_mapping uuid FunctionName=new_function
def update_event_source_mapping(UUID, FunctionName=None, Enabled=None, BatchSize=None, region=None, key=None, keyid=None, profile=None): ''' Update the event source mapping identified by the UUID. Returns {updated: true} if the alias was updat...
Update the cache file for the bucket.
def update(): ''' Update the cache file for the bucket. ''' metadata = _init() if S3_SYNC_ON_UPDATE: # sync the buckets to the local cache log.info('Syncing local cache from S3...') for saltenv, env_meta in six.iteritems(metadata): for bucket_files in _find_file...
Look through the buckets cache file for a match. If the field is found, it is retrieved from S3 only if its cached version is missing, or if the MD5 does not match.
def find_file(path, saltenv='base', **kwargs): ''' Look through the buckets cache file for a match. If the field is found, it is retrieved from S3 only if its cached version is missing, or if the MD5 does not match. ''' if 'env' in kwargs: # "env" is not supported; Use "saltenv". ...
Return an MD5 file hash
def file_hash(load, fnd): ''' Return an MD5 file hash ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') ret = {} if 'saltenv' not in load: return ret if 'path' not in fnd or 'bucket' not in fnd or not fnd['path']: return ret ...
Return a chunk from a file based on the data received
def serve_file(load, fnd): ''' Return a chunk from a file based on the data received ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') ret = {'data': '', 'dest': ''} if 'path' not in load or 'loc' not in load or 'saltenv' not in load: ...
Return a list of all files on the file server in a specified environment
def file_list(load): ''' Return a list of all files on the file server in a specified environment ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') ret = [] if 'saltenv' not in load: return ret saltenv = load['saltenv'] metadata = _...
Return a list of all directories on the master
def dir_list(load): ''' Return a list of all directories on the master ''' if 'env' in load: # "env" is not supported; Use "saltenv". load.pop('env') ret = [] if 'saltenv' not in load: return ret saltenv = load['saltenv'] metadata = _init() if not metadata...
Get AWS keys from pillar or config
def _get_s3_key(): ''' Get AWS keys from pillar or config ''' key = __opts__['s3.key'] if 's3.key' in __opts__ else None keyid = __opts__['s3.keyid'] if 's3.keyid' in __opts__ else None service_url = __opts__['s3.service_url'] \ if 's3.service_url' in __opts__ \ else None ve...
Connect to S3 and download the metadata for each file in all buckets specified and cache the data to disk.
def _init(): ''' Connect to S3 and download the metadata for each file in all buckets specified and cache the data to disk. ''' cache_file = _get_buckets_cache_filename() exp = time.time() - S3_CACHE_EXPIRE # check mtime of the buckets files cache metadata = None try: if os....
Return the cached file name for a bucket path file
def _get_cached_file_name(bucket_name, saltenv, path): ''' Return the cached file name for a bucket path file ''' file_path = os.path.join(_get_cache_dir(), saltenv, bucket_name, path) # make sure bucket and saltenv directories exist if not os.path.exists(os.path.dirname(file_path)): o...
Return the filename of the cache for bucket contents. Create the path if it does not exist.
def _get_buckets_cache_filename(): ''' Return the filename of the cache for bucket contents. Create the path if it does not exist. ''' cache_dir = _get_cache_dir() if not os.path.exists(cache_dir): os.makedirs(cache_dir) return os.path.join(cache_dir, 'buckets_files.cache')
Retrieve the content of all buckets and cache the metadata to the buckets cache file
def _refresh_buckets_cache_file(cache_file): ''' Retrieve the content of all buckets and cache the metadata to the buckets cache file ''' log.debug('Refreshing buckets cache file') key, keyid, service_url, verify_ssl, kms_keyid, location, path_style, https_enable = _get_s3_key() metadata =...
Return the contents of the buckets cache file
def _read_buckets_cache_file(cache_file): ''' Return the contents of the buckets cache file ''' log.debug('Reading buckets cache file') with salt.utils.files.fopen(cache_file, 'rb') as fp_: try: data = pickle.load(fp_) except (pickle.UnpicklingError, AttributeError, EOF...
Looks for all the files in the S3 bucket cache metadata
def _find_files(metadata): ''' Looks for all the files in the S3 bucket cache metadata ''' ret = [] found = {} for bucket_dict in metadata: for bucket_name, data in six.iteritems(bucket_dict): filepaths = [k['Key'] for k in data] filepaths = [k for k in filepath...
Looks for all the directories in the S3 bucket cache metadata. Supports trailing '/' keys (as created by S3 console) as well as directories discovered in the path of file keys.
def _find_dirs(metadata): ''' Looks for all the directories in the S3 bucket cache metadata. Supports trailing '/' keys (as created by S3 console) as well as directories discovered in the path of file keys. ''' ret = [] found = {} for bucket_dict in metadata: for bucket_name, ...
Looks for a file's metadata in the S3 bucket cache file
def _find_file_meta(metadata, bucket_name, saltenv, path): ''' Looks for a file's metadata in the S3 bucket cache file ''' env_meta = metadata[saltenv] if saltenv in metadata else {} bucket_meta = {} for bucket in env_meta: if bucket_name in bucket: bucket_meta = bucket[bucke...
Checks the local cache for the file, if it's old or missing go grab the file from S3 and update the cache
def _get_file_from_s3(metadata, saltenv, bucket_name, path, cached_file_path): ''' Checks the local cache for the file, if it's old or missing go grab the file from S3 and update the cache ''' key, keyid, service_url, verify_ssl, kms_keyid, location, path_style, https_enable = _get_s3_key() # c...
Return a list of file paths with the saltenv directory removed
def _trim_env_off_path(paths, saltenv, trim_slash=False): ''' Return a list of file paths with the saltenv directory removed ''' env_len = None if _is_env_per_bucket() else len(saltenv) + 1 slash_len = -1 if trim_slash else None return [d[env_len:slash_len] for d in paths]
Return the configuration mode, either buckets per environment or a list of buckets that have environment dirs in their root
def _is_env_per_bucket(): ''' Return the configuration mode, either buckets per environment or a list of buckets that have environment dirs in their root ''' buckets = _get_buckets() if isinstance(buckets, dict): return True elif isinstance(buckets, list): return False e...
Find a hosted zone with the given characteristics. Id The unique Zone Identifier for the Hosted Zone. Exclusive with Name. Name The domain name associated with the Hosted Zone. Exclusive with Id. Note this has the potential to match more then one hosted zone (e.g. a public and a priv...
def find_hosted_zone(Id=None, Name=None, PrivateZone=None, region=None, key=None, keyid=None, profile=None): ''' Find a hosted zone with the given characteristics. Id The unique Zone Identifier for the Hosted Zone. Exclusive with Name. Name The domain name associa...
Return detailed info about the given zone. Id The unique Zone Identifier for the Hosted Zone. region Region to connect to. key Secret key to be used. keyid Access key to be used. profile Dict, or pillar key pointing to a dict, containing AWS region/key/ke...
def get_hosted_zone(Id, region=None, key=None, keyid=None, profile=None): ''' Return detailed info about the given zone. Id The unique Zone Identifier for the Hosted Zone. region Region to connect to. key Secret key to be used. keyid Access key to be used. ...
Find any zones with the given domain name and return detailed info about them. Note that this can return multiple Route53 zones, since a domain name can be used in both public and private zones. Name The domain name associated with the Hosted Zone(s). region Region to connect to. ...
def get_hosted_zones_by_domain(Name, region=None, key=None, keyid=None, profile=None): ''' Find any zones with the given domain name and return detailed info about them. Note that this can return multiple Route53 zones, since a domain name can be used in both public and private zones. Name ...
Return detailed info about all zones in the bound account. DelegationSetId If you're using reusable delegation sets and you want to list all of the hosted zones that are associated with a reusable delegation set, specify the ID of that delegation set. region Region to connect to. ...
def list_hosted_zones(DelegationSetId=None, region=None, key=None, keyid=None, profile=None): ''' Return detailed info about all zones in the bound account. DelegationSetId If you're using reusable delegation sets and you want to list all of the hosted zones that are associated with a reusa...
Update the comment on an existing Route 53 hosted zone. Id The unique Zone Identifier for the Hosted Zone. Name The domain name associated with the Hosted Zone(s). Comment Any comments you want to include about the hosted zone. PrivateZone Boolean - Set to True if cha...
def update_hosted_zone_comment(Id=None, Name=None, Comment=None, PrivateZone=None, region=None, key=None, keyid=None, profile=None): ''' Update the comment on an existing Route 53 hosted zone. Id The unique Zone Identifier for the Hosted Zone. Name The do...
Associates an Amazon VPC with a private hosted zone. To perform the association, the VPC and the private hosted zone must already exist. You can't convert a public hosted zone into a private hosted zone. If you want to associate a VPC from one AWS account with a zone from a another, the AWS account owning...
def associate_vpc_with_hosted_zone(HostedZoneId=None, Name=None, VPCId=None, VPCName=None, VPCRegion=None, Comment=None, region=None, key=None, keyid=None, profile=None): ''' Associates an Amazon VPC with a private hosted zone. To perfor...
Delete a Route53 hosted zone. CLI Example:: salt myminion boto3_route53.delete_hosted_zone Z1234567890
def delete_hosted_zone(Id, region=None, key=None, keyid=None, profile=None): ''' Delete a Route53 hosted zone. CLI Example:: salt myminion boto3_route53.delete_hosted_zone Z1234567890 ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: r = conn.delet...
Delete a Route53 hosted zone by domain name, and PrivateZone status if provided. CLI Example:: salt myminion boto3_route53.delete_hosted_zone_by_domain example.org.
def delete_hosted_zone_by_domain(Name, PrivateZone=None, region=None, key=None, keyid=None, profile=None): ''' Delete a Route53 hosted zone by domain name, and PrivateZone status if provided. CLI Example:: salt myminion boto3_route53.delete_hosted_zone_by_domain ex...
An implementation of the encoding required to suport AWS's domain name rules defined here__: .. __: http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/DomainNameFormat.html While AWS's documentation specifies individual ASCII characters which need to be encoded, we instead just try to force the ...
def aws_encode(x): ''' An implementation of the encoding required to suport AWS's domain name rules defined here__: .. __: http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/DomainNameFormat.html While AWS's documentation specifies individual ASCII characters which need to be encoded, we...
helper method to process a change batch & encode the bits which need encoding.
def _aws_encode_changebatch(o): ''' helper method to process a change batch & encode the bits which need encoding. ''' change_idx = 0 while change_idx < len(o['Changes']): o['Changes'][change_idx]['ResourceRecordSet']['Name'] = aws_encode(o['Changes'][change_idx]['ResourceRecordSet']['Name']...
Get all resource records from a given zone matching the provided StartRecordName (if given) or all records in the zone (if not), optionally filtered by a specific StartRecordType. This will return any and all RRs matching, regardless of their special AWS flavors (weighted, geolocation, alias, etc.) so your...
def get_resource_records(HostedZoneId=None, Name=None, StartRecordName=None, StartRecordType=None, PrivateZone=None, region=None, key=None, keyid=None, profile=None): ''' Get all resource records from a given zone matching the provided StartRecordName (if given)...
Mask a line in the data, which matches "mask". This can be used for cases where values in your roster file may contain sensitive data such as IP addresses, passwords, user names, etc. Note that this works only when ``data`` is a single string (i.e. when the data in the roster is formatted as ``key: va...
def mask_args_value(data, mask): ''' Mask a line in the data, which matches "mask". This can be used for cases where values in your roster file may contain sensitive data such as IP addresses, passwords, user names, etc. Note that this works only when ``data`` is a single string (i.e. when the ...
See the `AWS Route53 API docs`__ as well as the `Boto3 documentation`__ for all the details... .. __: https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html .. __: http://boto3.readthedocs.io/en/latest/reference/services/route53.html#Route53.Client.change_resource_record_sets...
def change_resource_record_sets(HostedZoneId=None, Name=None, PrivateZone=None, ChangeBatch=None, region=None, key=None, keyid=None, profile=None): ''' See the `AWS Route53 API docs`__ as well as the `Boto3 documentation`__ for all the details... ...
Raise an exception if value is empty. Otherwise strip it down. :param value: :return:
def trim(value): ''' Raise an exception if value is empty. Otherwise strip it down. :param value: :return: ''' value = (value or '').strip() if not value: raise CommandExecutionError("Empty value during sanitation") return six.text_type(value)
Remove everything that would affect paths in the filename :param value: :return:
def filename(value): ''' Remove everything that would affect paths in the filename :param value: :return: ''' return re.sub('[^a-zA-Z0-9.-_ ]', '', os.path.basename(InputSanitizer.trim(value)))
Get all EIP's associated with the current credentials. addresses (list) - Optional list of addresses. If provided, only those those in the list will be returned. allocation_ids (list) - Optional list of allocation IDs. If provided, only the addresses associated with the given ...
def _get_all_eip_addresses(addresses=None, allocation_ids=None, region=None, key=None, keyid=None, profile=None): ''' Get all EIP's associated with the current credentials. addresses (list) - Optional list of addresses. If provided, only those those in the list w...
Get public addresses of some, or all EIPs associated with the current account. addresses (list) - Optional list of addresses. If provided, only the addresses associated with those in the list will be returned. allocation_ids (list) - Optional list of allocation IDs. If provided, only ...
def get_all_eip_addresses(addresses=None, allocation_ids=None, region=None, key=None, keyid=None, profile=None): ''' Get public addresses of some, or all EIPs associated with the current account. addresses (list) - Optional list of addresses. If provided, only the addres...
Return the first unassociated EIP domain Indicates whether the address is an EC2 address or a VPC address (standard|vpc). CLI Example: .. code-block:: bash salt-call boto_ec2.get_unassociated_eip_address .. versionadded:: 2016.3.0
def get_unassociated_eip_address(domain='standard', region=None, key=None, keyid=None, profile=None): ''' Return the first unassociated EIP domain Indicates whether the address is an EC2 address or a VPC address (standard|vpc). CLI Example: .. code...
Get 'interesting' info about some, or all EIPs associated with the current account. addresses (list) - Optional list of addresses. If provided, only the addresses associated with those in the list will be returned. allocation_ids (list) - Optional list of allocation IDs. If provided, ...
def get_eip_address_info(addresses=None, allocation_ids=None, region=None, key=None, keyid=None, profile=None): ''' Get 'interesting' info about some, or all EIPs associated with the current account. addresses (list) - Optional list of addresses. If provided, only the addr...
Allocate a new Elastic IP address and associate it with your account. domain (string) Optional param - if set to exactly 'vpc', the address will be allocated to the VPC. The default simply maps the EIP to your account container. returns (dict) dict of 'interesting' information...
def allocate_eip_address(domain=None, region=None, key=None, keyid=None, profile=None): ''' Allocate a new Elastic IP address and associate it with your account. domain (string) Optional param - if set to exactly 'vpc', the address will be allocated to the VPC. The default simply maps the ...
Free an Elastic IP address. Pass either a public IP address to release an EC2 Classic EIP, or an AllocationId to release a VPC EIP. public_ip (string) - The public IP address - for EC2 elastic IPs. allocation_id (string) - The Allocation ID - for VPC elastic IPs. returns (bool...
def release_eip_address(public_ip=None, allocation_id=None, region=None, key=None, keyid=None, profile=None): ''' Free an Elastic IP address. Pass either a public IP address to release an EC2 Classic EIP, or an AllocationId to release a VPC EIP. public_ip (string) - The...
Associate an Elastic IP address with a currently running instance or a network interface. This requires exactly one of either 'public_ip' or 'allocation_id', depending on whether you’re associating a VPC address or a plain EC2 address. instance_id (string) – ID of the instance to associate with (ex...
def 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, ...
Disassociate an Elastic IP address from a currently running instance. This requires exactly one of either 'association_id' or 'public_ip', depending on whether you’re dealing with a VPC or EC2 Classic address. public_ip (string) – Public IP address, for EC2 Classic allocations. association_id ...
def disassociate_eip_address(public_ip=None, association_id=None, region=None, key=None, keyid=None, profile=None): ''' Disassociate an Elastic IP address from a currently running instance. This requires exactly one of either 'association_id' or 'public_ip', depending on whe...
Assigns one or more secondary private IP addresses to a network interface. network_interface_id (string) - ID of the network interface to associate the IP with (exclusive with 'network_interface_name') network_interface_name (string) - Name of the network interface to associate the IP with (exc...
def 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...
Get a list of AZs for the configured region. CLI Example: .. code-block:: bash salt myminion boto_ec2.get_zones
def get_zones(region=None, key=None, keyid=None, profile=None): ''' Get a list of AZs for the configured region. CLI Example: .. code-block:: bash salt myminion boto_ec2.get_zones ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) return [z.name for z in c...
Given instance properties, find and return matching instance ids CLI Examples: .. code-block:: bash salt myminion boto_ec2.find_instances # Lists all instances salt myminion boto_ec2.find_instances name=myinstance salt myminion boto_ec2.find_instances tags='{"mytag": "value"}' ...
def 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): ''' Given instance properties, find and return matching instance ids CLI Examples: .. code-block:: bash ...
Given instance properties that define exactly one instance, create AMI and return AMI-id. CLI Examples: .. code-block:: bash salt myminion boto_ec2.create_image ami_name instance_name=myinstance salt myminion boto_ec2.create_image another_ami_name tags='{"mytag": "value"}' description='this i...
def 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): ''' Given instance properties that define exactly one instance, create AMI and return AM...
Given image properties, find and return matching AMI ids CLI Examples: .. code-block:: bash salt myminion boto_ec2.find_images tags='{"mytag": "value"}'
def 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): ''' Given image properties, find and return matching AMI ids CLI Examples: .. code-block:: bash salt myminion boto_e...
Terminate the instance described by instance_id or name. CLI Example: .. code-block:: bash salt myminion boto_ec2.terminate name=myinstance salt myminion boto_ec2.terminate instance_id=i-a46b9f
def terminate(instance_id=None, name=None, region=None, key=None, keyid=None, profile=None, filters=None): ''' Terminate the instance described by instance_id or name. CLI Example: .. code-block:: bash salt myminion boto_ec2.terminate name=myinstance salt myminion boto_e...
Given instance properties, return the instance id if it exists. CLI Example: .. code-block:: bash salt myminion boto_ec2.get_id myinstance
def get_id(name=None, tags=None, region=None, key=None, keyid=None, profile=None, in_states=None, filters=None): ''' Given instance properties, return the instance id if it exists. CLI Example: .. code-block:: bash salt myminion boto_ec2.get_id myinstance ''' instance_ids...
Given an instance_id, return a list of tags associated with that instance. returns (list) - list of tags as key/value pairs CLI Example: .. code-block:: bash salt myminion boto_ec2.get_tags instance_id
def get_tags(instance_id=None, keyid=None, key=None, profile=None, region=None): ''' Given an instance_id, return a list of tags associated with that instance. returns (list) - list of tags as key/value pairs CLI Example: .. code-block:: bash salt myminion boto_ec2.g...
Given an instance id, check to see if the given instance id exists. Returns True if the given instance with the given id, name, or tags exists; otherwise, False is returned. CLI Example: .. code-block:: bash salt myminion boto_ec2.exists myinstance
def exists(instance_id=None, name=None, tags=None, region=None, key=None, keyid=None, profile=None, in_states=None, filters=None): ''' Given an instance id, check to see if the given instance id exists. Returns True if the given instance with the given id, name, or tags exists; otherwise, Fa...
Convert a string, or a json payload, or a dict in the right format, into a boto.ec2.blockdevicemapping.BlockDeviceMapping as needed by instance_present(). The following YAML is a direct representation of what is expected by the underlying boto EC2 code. YAML example: .. code-block:: yaml ...
def _to_blockdev_map(thing): ''' Convert a string, or a json payload, or a dict in the right format, into a boto.ec2.blockdevicemapping.BlockDeviceMapping as needed by instance_present(). The following YAML is a direct representation of what is expected by the underlying boto EC2 code. YAML ex...
Create and start an EC2 instance. Returns True if the instance was created; otherwise False. CLI Example: .. code-block:: bash salt myminion boto_ec2.run ami-b80c2b87 name=myinstance image_id (string) – The ID of the image to run. name (string) - The name of the instance...
def 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_de...
Check to see if a key exists. Returns fingerprint and name if it does and False if it doesn't CLI Example: .. code-block:: bash salt myminion boto_ec2.get_key mykey
def get_key(key_name, region=None, key=None, keyid=None, profile=None): ''' Check to see if a key exists. Returns fingerprint and name if it does and False if it doesn't CLI Example: .. code-block:: bash salt myminion boto_ec2.get_key mykey ''' conn = _get_conn(region=region, key=k...
Creates a key and saves it to a given path. Returns the private key. CLI Example: .. code-block:: bash salt myminion boto_ec2.create_key mykey /root/
def create_key(key_name, save_path, region=None, key=None, keyid=None, profile=None): ''' Creates a key and saves it to a given path. Returns the private key. CLI Example: .. code-block:: bash salt myminion boto_ec2.create_key mykey /root/ ''' conn = _get_conn(regio...
Imports the public key from an RSA key pair that you created with a third-party tool. Supported formats: - OpenSSH public key format (e.g., the format in ~/.ssh/authorized_keys) - Base64 encoded DER format - SSH public key file format as specified in RFC4716 - DSA keys are not supported. Make sure y...
def import_key(key_name, public_key_material, region=None, key=None, keyid=None, profile=None): ''' Imports the public key from an RSA key pair that you created with a third-party tool. Supported formats: - OpenSSH public key format (e.g., the format in ~/.ssh/authorized_keys) - Base6...
Deletes a key. Always returns True CLI Example: .. code-block:: bash salt myminion boto_ec2.delete_key mykey
def delete_key(key_name, region=None, key=None, keyid=None, profile=None): ''' Deletes a key. Always returns True CLI Example: .. code-block:: bash salt myminion boto_ec2.delete_key mykey ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: key ...
Gets all keys or filters them by name and returns a list. keynames (list):: A list of the names of keypairs to retrieve. If not provided, all key pairs will be returned. filters (dict) :: Optional filters that can be used to limit the results returned. Filters are provided in the form of a dictionary ...
def get_keys(keynames=None, filters=None, region=None, key=None, keyid=None, profile=None): ''' Gets all keys or filters them by name and returns a list. keynames (list):: A list of the names of keypairs to retrieve. If not provided, all key pairs will be returned. filters (dict) :: Opt...
Get an EC2 instance attribute. CLI Example: .. code-block:: bash salt myminion boto_ec2.get_attribute sourceDestCheck instance_name=my_instance Available attributes: * instanceType * kernel * ramdisk * userData * disableApiTermination * instanceIni...
def get_attribute(attribute, instance_name=None, instance_id=None, region=None, key=None, keyid=None, profile=None, filters=None): ''' Get an EC2 instance attribute. CLI Example: .. code-block:: bash salt myminion boto_ec2.get_attribute sourceDestCheck instance_name=my_insta...
Set an EC2 instance attribute. Returns whether the operation succeeded or not. CLI Example: .. code-block:: bash salt myminion boto_ec2.set_attribute sourceDestCheck False instance_name=my_instance Available attributes: * instanceType * kernel * ramdisk * user...
def set_attribute(attribute, attribute_value, instance_name=None, instance_id=None, region=None, key=None, keyid=None, profile=None, filters=None): ''' Set an EC2 instance attribute. Returns whether the operation succeeded or not. CLI Example: .. code-block:: bash salt m...
Get an Elastic Network Interface id from its name tag. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt myminion boto_ec2.get_network_interface_id name=my_eni
def get_network_interface_id(name, region=None, key=None, keyid=None, profile=None): ''' Get an Elastic Network Interface id from its name tag. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt myminion boto_ec2.get_network_interface_id name=m...
Get an Elastic Network Interface. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt myminion boto_ec2.get_network_interface name=my_eni
def get_network_interface(name=None, network_interface_id=None, region=None, key=None, keyid=None, profile=None): ''' Get an Elastic Network Interface. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt myminion boto_ec2.get_network_interface name...
Create an Elastic Network Interface. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt myminion boto_ec2.create_network_interface my_eni subnet-12345 description=my_eni groups=['my_group']
def 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): ''' Create an Elastic Network Interface. .. v...
Create an Elastic Network Interface. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt myminion boto_ec2.create_network_interface my_eni subnet-12345 description=my_eni groups=['my_group']
def delete_network_interface( name=None, network_interface_id=None, region=None, key=None, keyid=None, profile=None): ''' Create an Elastic Network Interface. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt myminion boto_ec2.create_network_interface my_e...
Attach an Elastic Network Interface. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt myminion boto_ec2.attach_network_interface my_eni instance_name=salt-master device_index=0
def 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): ''' Attach an Elastic Network Interface. .. versionadded:: 2016.3.0 CLI Exa...
Modify an attribute of an Elastic Network Interface. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash salt myminion boto_ec2.modify_network_interface_attribute my_eni attr=description value='example description'
def modify_network_interface_attribute( name=None, network_interface_id=None, attr=None, value=None, region=None, key=None, keyid=None, profile=None): ''' Modify an attribute of an Elastic Network Interface. .. versionadded:: 2016.3.0 CLI Example: .. code-block:: bash sal...
Get a list of all EBS volumes, optionally filtered by provided 'filters' param .. versionadded:: 2016.11.0 volume_ids (list) - Optional list of volume_ids. If provided, only the volumes associated with those in the list will be returned. filters (dict) - Additional constraints on ...
def get_all_volumes(volume_ids=None, filters=None, return_objs=False, region=None, key=None, keyid=None, profile=None): ''' Get a list of all EBS volumes, optionally filtered by provided 'filters' param .. versionadded:: 2016.11.0 volume_ids (list) - Optional list of volume...
.. versionadded:: 2016.11.0 tag_maps (list) List of dicts of filters and tags, where 'filters' is a dict suitable for passing to the 'filters' argument of get_all_volumes() above, and 'tags' is a dict of tags to be set on volumes (via create_tags/delete_tags) as matched by the given filters...
def set_volumes_tags(tag_maps, authoritative=False, dry_run=False, region=None, key=None, keyid=None, profile=None): ''' .. versionadded:: 2016.11.0 tag_maps (list) List of dicts of filters and tags, where 'filters' is a dict suitable for passing to the 'filters' argumen...
Describe all tags matching the filter criteria, or all tags in the account otherwise. .. versionadded:: 2018.3.0 filters (dict) - Additional constraints on which volumes to return. Note that valid filters vary extensively depending on the resource type. When in doubt, search first without a ...
def get_all_tags(filters=None, region=None, key=None, keyid=None, profile=None): ''' Describe all tags matching the filter criteria, or all tags in the account otherwise. .. versionadded:: 2018.3.0 filters (dict) - Additional constraints on which volumes to return. Note that valid filters var...
Create new metadata tags for the specified resource ids. .. versionadded:: 2016.11.0 resource_ids (string) or (list) – List of resource IDs. A plain string will be converted to a list of one element. tags (dict) – Dictionary of name/value pairs. To create only a tag name, pass '' as the v...
def create_tags(resource_ids, tags, region=None, key=None, keyid=None, profile=None): ''' Create new metadata tags for the specified resource ids. .. versionadded:: 2016.11.0 resource_ids (string) or (list) – List of resource IDs. A plain string will be converted to a list of one element. ...