Best Python code snippet using localstack_python
template_deployer.py
Source:template_deployer.py  
...1358                resource_id = res_change["LogicalResourceId"]1359                try:1360                    if is_add_or_modify:1361                        resource = new_resources[resource_id]1362                        should_deploy = self.prepare_should_deploy_change(1363                            resource_id, change, stack, new_resources1364                        )1365                        LOG.debug(1366                            'Handling "%s" for resource "%s" (%s/%s) type "%s" in loop iteration %s (should_deploy=%s)',1367                            action,1368                            resource_id,1369                            j + 1,1370                            len(changes),1371                            res_change["ResourceType"],1372                            i + 1,1373                            should_deploy,1374                        )1375                        if not should_deploy:1376                            del changes[j]1377                            stack_action = get_action_name_for_resource_change(action)1378                            stack.set_resource_status(resource_id, "%s_COMPLETE" % stack_action)1379                            continue1380                        if not self.all_resource_dependencies_satisfied(resource):1381                            j += 11382                            continue1383                    elif action == "Remove":1384                        should_remove = self.prepare_should_deploy_change(1385                            resource_id, change, stack, new_resources1386                        )1387                        if not should_remove:1388                            del changes[j]1389                            continue1390                    self.apply_change(change, stack=stack)1391                    changes_done.append(change)1392                    del changes[j]1393                    updated = True1394                except DependencyNotYetSatisfied as e:1395                    LOG.debug(1396                        'Dependencies for "%s" not yet satisfied, retrying in next loop: %s',1397                        resource_id,1398                        e,1399                    )1400                    j += 11401            if not changes:1402                break1403            if not updated:1404                raise Exception(1405                    "Resource deployment loop completed, pending resource changes: %s" % changes1406                )1407        # clean up references to deleted resources in stack1408        deletes = [c for c in changes_done if c["ResourceChange"]["Action"] == "Remove"]1409        for delete in deletes:1410            stack.template["Resources"].pop(delete["ResourceChange"]["LogicalResourceId"], None)1411        return changes_done1412    def prepare_should_deploy_change(self, resource_id, change, stack, new_resources):1413        resource = new_resources[resource_id]1414        res_change = change["ResourceChange"]1415        action = res_change["Action"]1416        # check resource condition, if present1417        if not evaluate_resource_condition(stack, resource):1418            LOG.debug(1419                'Skipping deployment of "%s", as resource condition evaluates to false', resource_id1420            )1421            return1422        # resolve refs in resource details1423        resolve_refs_recursively(stack, resource)1424        if action in ["Add", "Modify"]:1425            is_deployed = self.is_deployed(resource)1426            if action == "Modify" and not is_deployed:...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!!
