""" Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: MIT-0 """ import os from pathlib import Path from cfnlint.helpers import LIMITS from cfnlint.rules import CloudFormationLintRule, RuleMatch class LimitSize(CloudFormationLintRule): """Check Template Size""" id = "E1002" shortdesc = "Template size limit" description = "Check the size of the template is less than the upper limit" source_url = "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html" tags = ["limits"] def match(self, cfn): matches = [] # Only check if the file exists. The template could be passed in using stdIn if cfn.filename: if Path(cfn.filename).is_file(): statinfo = os.stat(cfn.filename) if statinfo.st_size > LIMITS["template"]["body"]: message = "The template file size ({0} bytes) exceeds the limit ({1} bytes)" matches.append( RuleMatch( ["Template"], message.format( statinfo.st_size, LIMITS["template"]["body"] ), ) ) return matches
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
__pycache__ | Folder | 0755 |
|
|
ApproachingLimitDescription.py | File | 1.2 KB | 0644 |
|
ApproachingLimitSize.py | File | 1.43 KB | 0644 |
|
Base.py | File | 2.9 KB | 0644 |
|
Description.py | File | 916 B | 0644 |
|
LimitDescription.py | File | 1.25 KB | 0644 |
|
LimitSize.py | File | 1.3 KB | 0644 |
|
__init__.py | File | 106 B | 0644 |
|