Best Python code snippet using localstack_python
responses.py
Source:responses.py  
...100            self._get_param("limit"),101            self._get_param("nextToken"),102        )103        return json.dumps(schema)104    def list_aggregate_discovered_resources(self):105        schema = self.config_backend.list_aggregate_discovered_resources(106            self._get_param("ConfigurationAggregatorName"),107            self._get_param("ResourceType"),108            self._get_param("Filters"),109            self._get_param("Limit"),110            self._get_param("NextToken"),111        )112        return json.dumps(schema)113    def get_resource_config_history(self):114        schema = self.config_backend.get_resource_config_history(115            self._get_param("resourceType"), self._get_param("resourceId"), self.region116        )117        return json.dumps(schema)118    def batch_get_resource_config(self):119        schema = self.config_backend.batch_get_resource_config(...org-aws-organisation-audit.py
Source:org-aws-organisation-audit.py  
1import boto32import os3import json45#6# Author: Adan Patience7# Date: 24 November 20208# Description:9# Using the aws-controltower-GuardrailsComplianceAggregator, the script lists all EC2 instances in the account in the following format:10# accountId, instanceId, privateIpAddress, subnetId, vpcId11#12# An easy means to audit the EC2 resources in an AWS Organiztion13#14profile = ''15region =  'eu-west-1'1617if __name__ == '__main__':18    os.environ['AWS_SHARED_CREDENTIALS_FILE'] = '~/.aws/credentials'1920    session = boto3.Session(profile_name=profile) #profile of the adminstrator account details21    22    config_service_client = session.client(23      'config',24      region_name=region25    )26    paginator = config_service_client.get_paginator('list_aggregate_discovered_resources') #get paginator resource for the list_aggregate_discovered_resources method27    operation_params = {28      'ConfigurationAggregatorName':'aws-controltower-GuardrailsComplianceAggregator',29      'ResourceType':'AWS::EC2::Instance'30    }31    print('accountId, instanceId, privateIpAddress, subnetId, vpcId')32    page_iterator = paginator.paginate(**operation_params) #create paginator and parse parameters and iterate over results in for loop33  34    for aggregated_resources in page_iterator:35      resource_configs = config_service_client.batch_get_aggregate_resource_config(36        ConfigurationAggregatorName='aws-controltower-GuardrailsComplianceAggregator',37        ResourceIdentifiers=aggregated_resources['ResourceIdentifiers']38      )39      for resource_id in resource_configs['BaseConfigurationItems']:40        parsed_config = json.loads(resource_id['configuration'])41        print('{0}, {1} ,{2} ,{3}, {4}'.format(42          resource_id['accountId'],43          parsed_config['instanceId'],44          parsed_config['privateIpAddress'],45          parsed_config['subnetId'],46          parsed_config['vpcId']
...lambda_to_csv.py
Source:lambda_to_csv.py  
...16def lambda_handler(event, context):17    account_ids = list_organizations()18    lst = []19    for id in account_ids:20        response = client.list_aggregate_discovered_resources(21            ConfigurationAggregatorName='aws-controltower-GuardrailsComplianceAggregator',22            ResourceType= 'AWS::IAM::Role',23            Filters={24                'AccountId': id25            }26        )27        lst.append(response)28    csvio = io.StringIO()29    writer = csv.writer(csvio)30    writer.writerow(["resourceType", "resourceId", "resourceName", "AccountId", "Region"])   31    for res in lst:32        for page in res['ResourceIdentifiers']:33            resourceType = page.get('ResourceType')34            resourceId = page.get('ResourceId')...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!!
