How to use batch_get_resource_config method in localstack

Best Python code snippet using localstack_python

responses.py

Source:responses.py Github

copy

Full Screen

...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(120 self._get_param("resourceKeys"), self.region121 )122 return json.dumps(schema)123 def batch_get_aggregate_resource_config(self):124 schema = self.config_backend.batch_get_aggregate_resource_config(125 self._get_param("ConfigurationAggregatorName"),126 self._get_param("ResourceIdentifiers"),127 )128 return json.dumps(schema)129 def put_evaluations(self):130 evaluations = self.config_backend.put_evaluations(131 self._get_param("Evaluations"),132 self._get_param("ResultToken"),133 self._get_param("TestMode"),...

Full Screen

Full Screen

test_stack_wait_for_config_resources.py

Source:test_stack_wait_for_config_resources.py Github

copy

Full Screen

1# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.2# SPDX-License-Identifier: Apache-2.03from unittest.mock import patch, MagicMock, call4from critter import Stack5rule = {6 "ConfigRuleName": "my-config-rule",7 "ConfigRuleArn": "arn:aws:config:us-region-1:111111111111:config-rule/config-rule-aaa111",8 "ConfigRuleId": "config-rule-aaa111",9 "Description": "CloudWatch LogGroup retention period rule",10 "Scope": {"ComplianceResourceTypes": ["AWS::Logs::LogGroup"]},11 "Source": {"Owner": "AWS", "SourceIdentifier": "CW_LOGGROUP_RETENTION_PERIOD_CHECK"},12 "MaximumExecutionFrequency": "TwentyFour_Hours",13 "ConfigRuleState": "ACTIVE",14}15resources = {16 "compliant-one": {"evaluation_result": {}, "expected_compliance_type": "COMPLIANT"},17 "compliant-two": {"evaluation_result": {}, "expected_compliance_type": "COMPLIANT"},18 "non-compliant-one": {"evaluation_result": {}, "expected_compliance_type": "NON_COMPLIANT"},19 "non-compliant-two": {"evaluation_result": {}, "expected_compliance_type": "NON_COMPLIANT"},20 "not-applicable-one": {"evaluation_result": {}, "expected_compliance_type": "NOT_APPLICABLE"},21}22@patch("time.sleep")23@patch("boto3.resource")24@patch("boto3.client")25def test_stack_wait_for_config_resources(mock_boto_client, mock_boto_resource, mock_time_sleep, caplog):26 stack = Stack()27 stack.initialize_boto_clients()28 stack.skip_wait_for_resource_recording = False29 stack.resource_types = rule["Scope"]["ComplianceResourceTypes"]30 stack.config_rule_name = rule["ConfigRuleName"]31 stack.resources = resources32 stack.config = MagicMock()33 # TODO: test a loop, return less than all of the resources on the first34 # config.batch_get_resource_config api call, then return all resources on the second call35 stack.config.batch_get_resource_config.return_value = {"baseConfigurationItems": resources.keys()}36 stack.wait_for_config_resources()37 assert mock_boto_client.call_args_list == [call("sts"), call("cloudformation"), call("config")]38 assert mock_boto_resource.call_args_list == []39 assert mock_time_sleep.call_args_list == []40 assert stack.config.batch_get_resource_config.call_args_list == [41 call(42 resourceKeys=[43 {"resourceType": "AWS::Logs::LogGroup", "resourceId": "compliant-one"},44 {"resourceType": "AWS::Logs::LogGroup", "resourceId": "compliant-two"},45 {"resourceType": "AWS::Logs::LogGroup", "resourceId": "non-compliant-one"},46 {"resourceType": "AWS::Logs::LogGroup", "resourceId": "non-compliant-two"},47 {"resourceType": "AWS::Logs::LogGroup", "resourceId": "not-applicable-one"},48 ]49 )50 ]51@patch("boto3.resource")52@patch("boto3.client")53def test_stack_wait_for_config_resources_skip_wait(mock_boto_client, mock_boto_resource):54 stack = Stack()55 stack.initialize_boto_clients()56 stack.skip_wait_for_resource_recording = True57 stack.wait_for_config_resources()58 assert mock_boto_client.call_args_list == [call("sts"), call("cloudformation"), call("config")]59 assert mock_boto_resource.call_args_list == []60@patch("boto3.resource")61@patch("boto3.client")62def test_stack_wait_for_config_resources_not_resource_types(mock_boto_client, mock_boto_resource, caplog):63 stack = Stack()64 stack.initialize_boto_clients()65 stack.skip_wait_for_resource_recording = False66 stack.resource_types = []67 stack.config_rule_name = "test-rule"68 stack.wait_for_config_resources()69 assert mock_boto_client.call_args_list == [call("sts"), call("cloudformation"), call("config")]70 assert mock_boto_resource.call_args_list == []71 assert (72 "Warning - Skipping waiting for resources to be recorded by AWS Config. Config rule "73 "'test-rule' scope does not specify applicable resource types." in caplog.text...

Full Screen

Full Screen

status.py

Source:status.py Github

copy

Full Screen

...31 # NextToken = None32 # if "NextToken" in response:33 # NextToken = response["NextToken"]34 # print(response)35 response = config.batch_get_resource_config(36 resourceKeys=[37 {38 'resourceType': 'AWS::RDS::DBInstance',39 'resourceId': 'db-ODKMWZQ66B46CGZDEOFDBEMZHQ'40 },41 ]42 )43 print(response)44if __name__== "__main__":...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful