faster_sam.cloudformation module¶
- exception faster_sam.cloudformation.CFBadNode¶
Bases:
ValueError
Raised when an invalid CloudFormation node is encountered.
- exception faster_sam.cloudformation.CFBadTag¶
Bases:
TypeError
Raised when an invalid CloudFormation tag is encountered.
- class faster_sam.cloudformation.CFLoader(
- stream,
Bases:
SafeLoader
Custom YAML loader for CloudFormation templates.
- yaml_multi_constructors = {'!': <function multi_constructor>}¶
- exception faster_sam.cloudformation.CFTemplateNotFound¶
Bases:
FileNotFoundError
Raised when the CloudFormation template file cannot be found.
- class faster_sam.cloudformation.CloudformationTemplate(
- template_path=None,
Bases:
object
Represents an AWS CloudFormation template and provides methods for extracting information from the template.
- Parameters:
template_path (Optional[str]) – Path to the CloudFormation template file.
- template¶
Dictionary representing the loaded CloudFormation template.
- Type:
Dict[str, Any]
- find_nodes(
- tree,
- node_type,
Finds nodes of a specific type in the CloudFormation template.
- Parameters:
tree (Dict[str, Any]) – Dictionary representing a subset of the CloudFormation template.
node_type (NodeType) – The type of node to search for.
- Returns:
Dictionary containing nodes of the specified type.
- Return type:
Dict[str, Any]
- property functions¶
Dict[str, Any]: Dictionary containing Lambda function resources in the CloudFormation template.
- property gateways¶
Dict[str, Any]: Dictionary containing API Gateway resources in the CloudFormation template.
- include_files()¶
Load external files specified in the CloudFormation template like OpenAPI schema.
- lambda_handler(
- resource_id,
Returns a string representing the full module path for a Lambda Function handler.
The path is built by joining the code URI and the handler attributes on the CloudFormation for the given Lambda Function identified by resource_id.
- Parameters:
resource_id (str) – The id of the Lambda function resource.
- Returns:
The constructed Lambda handler path.
- Return type:
str
- load(
- template=None,
Reads CloudFormation template file from the disk and convert it to a dictionary.
If the template argument is not set it is assumed an YAML file named template exists in the current directory.
- Parameters:
template (Optional[str]) – Path to the CloudFormation template file.
- Returns:
Dictionary representing the loaded CloudFormation template.
- Return type:
Dict[str, Any]
- Raises:
CFTemplateNotFound – Exception raised when CloudFormation template file is not found.
- class faster_sam.cloudformation.NodeType(
- value,
- names=None,
- *values,
- module=None,
- qualname=None,
- type=None,
- start=1,
- boundary=None,
Bases:
Enum
Enum representing different types of CloudFormation nodes.
- API_GATEWAY¶
Represents the “AWS::Serverless::Api” node type.
- Type:
str
- LAMBDA¶
Represents the “AWS::Serverless::Function” node type.
- Type:
str
- API_EVENT¶
Represents the “Api” node type.
- Type:
str
- API_EVENT = 'Api'¶
- API_GATEWAY = 'AWS::Serverless::Api'¶
- LAMBDA = 'AWS::Serverless::Function'¶
- faster_sam.cloudformation.construct_getatt(
- node,
Custom YAML node constructor for AWS CloudFormation GetAtt intrinsic function.
- Parameters:
node (yaml.nodes.Node) – The node representing a CloudFormation GetAtt element.
- Returns:
List representing the constructed CloudFormation GetAtt element.
- Return type:
List[Any]
- Raises:
CFBadNode – If an invalid CloudFormation node is encountered.
- faster_sam.cloudformation.multi_constructor(
- loader,
- tag_suffix,
- node,
Custom YAML node constructor.
Handles AWS CloudFormation extensions for its short version of intrinsic functions.