Example #1
0
 def find_lambda_zipfile(self) -> str:
     log.debug(f'Looking for zipfile in {self.path}')
     for xf in os.listdir(self.path):
         if xf.endswith('.zip'):
             log.debug(f'Finally {xf} looks like a zip file')
             return xf
         log.debug(f'{xf} is not a zip file')
     raise util.InvalidStackConfiguration(f'Lambda function source at {self.path} must produce a zipfile')
Example #2
0
 def list_deployable(self) -> List[CloudformationTemplate]:
     u = list()
     for xs in self.environment_parameters.get('stacks', list()):
         try:
             if xs.get('deployable', True) is False:
                 log.info(f'Stack {Fore.GREEN}{xs.get("name")}{Style.RESET_ALL} is not deployable, skipping')
                 continue
             stack_template = [xt for xt in self.templates if xt.name == xs.get('name')].pop()
             u.append(stack_template)
         except IndexError:
             raise util.InvalidStackConfiguration(f'Template not found for {xs.get("name")}') from None
     return u
Example #3
0
 def find_template(self, template_name):
     try:
         return [f'{xt.s3_key_prefix}/{xt.s3_key}' for xt in self.templates if xt.s3_key == template_name].pop()
     except IndexError:
         raise util.InvalidStackConfiguration(f'Template {template_name} is not part of the deployment')\
             from None
Example #4
0
 def find_stack_output(self, stack_name, output_name):
     try:
         return [xs.get_stack_output(output_name) for xs in self.stacks if xs.template.name == stack_name].pop()
     except IndexError:
         raise util.InvalidStackConfiguration(f'Can\'t find output {output_name} on stack {stack_name}, '
                     f'template {stack_name} is not part of the deployment') from None
Example #5
0
 def find_lambda_key(self, zip_name) -> str:
     try:
         return [x.s3_key for x in self.lambdas if x.zip_file == zip_name].pop()
     except IndexError:
         raise util.InvalidStackConfiguration(f'Lambda function bundle {zip_name} not found') from None
Example #6
0
 def find_template_file(self, template_key: str) -> str:
     for xk, xp in self.template_files:
         if xk == template_key:
             return xp
     raise util.InvalidStackConfiguration(f'Template file not found for {template_key}')
Example #7
0
 def find_template(self, template_name: str) -> CloudformationTemplate:
     try:
         return [x for x in self.templates if x.template == template_name].pop()
     except IndexError:
         raise util.InvalidStackConfiguration(f'Template {template_name} not found in this deployment')\
             from None
 def get_stack_output(self, output_name: str) -> NoReturn:
     raise util.InvalidStackConfiguration(
         f'Can\'t retrieve output {output_name} '
         f'of stackset {self.stack_name}'
         f', stacksets don\'t have outputs. Please review your configuration'
     )