def __exit__()

in _compile_cloudformation_template.py [0:0]


    def __exit__(self, exc_type, exc_val, exc_tb):
        if not exc_type:
            global_resources = {}

            for template_filename, config in zip(self.filenames, self.configs):
                stack_prefix = snake_case_to_capitalized_words(template_filename.split('.')[0])
                stack_name = f'{stack_prefix}Stack'

                for ref in find_refs(config):
                    if ref not in config['Resources'] and not ref.startswith('AWS::'):
                        config.setdefault('Parameters', {})
                        config['Parameters'][ref] = {'Type': 'String'}

                for resource in list(config['Resources'].keys()):
                    if config['Resources'][resource]['Type'] == 'AWS::ApiGateway::Deployment':
                        # Unique-ify the logical ID to force a new deployment for each stack update
                        unique_resource_name = f"{resource}{str(int(time.time()))}"
                        config['Resources'][unique_resource_name] = config['Resources'].pop(resource)
                        config['Outputs'][resource] = {'Value': Ref(unique_resource_name)}
                    else:
                        config['Outputs'][resource] = {'Value': Ref(resource)}

                for output in config['Outputs']:
                    global_resources[output] = stack_name

                with open(os.path.join(self.out_dir, template_filename), 'w') as f:
                    f.write(yaml.dump(config, default_flow_style=False))

            # Compile the overall configuration
            overall_config = yaml.safe_load(open(os.path.join(self.in_dir, 'aws-ops-wheel.yml')))
            overall_config.setdefault('Resources', {})
            overall_config.setdefault('Outputs', {})
            for template_filename, config in zip(self.filenames, self.configs):
                stack_prefix = snake_case_to_capitalized_words(template_filename.split('.')[0])
                stack_name = f'{stack_prefix}Stack'
                params = {}
                for p in config.get('Parameters', dict()):
                    if p in global_resources:
                        params[p] = GetAtt(f"{global_resources[p]}.Outputs.{p}")
                    else:
                        overall_config.setdefault('Parameters', dict())
                        overall_config['Parameters'][p] = config['Parameters'][p]
                        params[p] = Ref(p)
                overall_config['Resources'][stack_name] = {
                    'Type': "AWS::CloudFormation::Stack",
                    'Properties': {
                        'TemplateURL': f'./compiled_templates/{template_filename}',
                        'TimeoutInMinutes': 20,
                        'Parameters': params,
                    }
                }
                for p in global_resources:
                    overall_config['Outputs'][p] = {'Value': GetAtt(f"{global_resources[p]}.Outputs.{p}")}


            with open(os.path.join(self.out_dir, 'aws-ops-wheel.yml'), 'w') as f:
                f.write(yaml.dump(overall_config))