Best Python code snippet using localstack_python
aws_config_aggregation_authorization.py
Source:aws_config_aggregation_authorization.py
...51from ansible.module_utils.ec2 import boto3_conn, get_aws_connection_info, AWSRetry52from ansible.module_utils.ec2 import camel_dict_to_snake_dict, boto3_tag_list_to_ansible_dict53def resource_exists(client, module, params):54 try:55 current_authorizations = client.describe_aggregation_authorizations()['AggregationAuthorizations']56 authorization_exists = next(57 (item for item in current_authorizations if item["AuthorizedAccountId"] == params['AuthorizedAccountId']),58 None59 )60 if authorization_exists:61 return True62 except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError):63 return False64def create_resource(client, module, params, result):65 try:66 response = client.put_aggregation_authorization(67 AuthorizedAccountId=params['AuthorizedAccountId'],68 AuthorizedAwsRegion=params['AuthorizedAwsRegion']69 )70 result['changed'] = True71 return result72 except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:73 module.fail_json_aws(e, msg="Couldn't create AWS Aggregation authorization")74def update_resource(client, module, params, result):75 current_authorizations = client.describe_aggregation_authorizations()['AggregationAuthorizations']76 current_params = next(77 (item for item in current_authorizations if item["AuthorizedAccountId"] == params['AuthorizedAccountId']),78 None79 )80 del current_params['AggregationAuthorizationArn']81 del current_params['CreationTime']82 if params != current_params:83 try:84 response = client.put_aggregation_authorization(85 AuthorizedAccountId=params['AuthorizedAccountId'],86 AuthorizedAwsRegion=params['AuthorizedAwsRegion']87 )88 result['changed'] = True89 return result...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!