How to use the pycfmodel.model.parameter.Parameter function in pycfmodel

To help you get started, we’ve selected a few pycfmodel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Skyscanner / pycfmodel / tests / test_parameter.py View on Github external
def test_get_ref_value(param, provided_value, expected):
    parameter = Parameter(**param)
    assert parameter.get_ref_value(provided_value) == expected
github Skyscanner / pycfmodel / tests / test_parameter.py View on Github external
        ({"Type": "String", "NoEcho": True, "Default": "A"}, "SuperSecret", Parameter.NO_ECHO_WITH_VALUE),
        ({"Type": "String", "NoEcho": True}, "SuperSecret", Parameter.NO_ECHO_WITH_VALUE),
        ({"Type": "String", "NoEcho": False, "Default": "A"}, "B", "B"),
        ({"Type": "String", "NoEcho": False}, "B", "B"),
        ({"Type": "String", "Default": "abc"}, "B", "B"),
        ({"Type": "String", "Default": None}, None, None),
        ({"Type": "Number", "Default": 1}, None, "1"),
        ({"Type": "List", "Default": "1,2,3"}, "4,5,6", ["4", "5", "6"]),
        ({"Type": "CommaDelimitedList", "Default": "a,b,c"}, "b,c,d", ["b", "c", "d"]),
    ],
)
def test_get_ref_value(param, provided_value, expected):
    parameter = Parameter(**param)
    assert parameter.get_ref_value(provided_value) == expected
github Skyscanner / pycfmodel / pycfmodel / model / cf_model.py View on Github external
- Outputs: Output values of the template.
    - Parameters: Parameters to the template.
    - Resources: Stack resources and their properties.
    - Rules
    - Transform: For serverless applications, specifies the version of the AWS Serverless Application Model (AWS SAM) to use.

    More info at [AWS Docs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html)
    """

    AWSTemplateFormatVersion: Optional[date]
    Conditions: Optional[Dict] = {}
    Description: Optional[str] = None
    Mappings: Optional[Dict[str, Dict[str, Dict[str, Any]]]] = {}
    Metadata: Optional[Dict[str, Dict]] = None
    Outputs: Optional[Dict[str, Dict[str, Union[str, Dict]]]] = {}
    Parameters: Optional[Dict[str, Parameter]] = {}
    Resources: Dict[str, Resolvable[Union[ResourceModels, GenericResource]]] = {}
    Rules: Optional[Dict] = {}
    Transform: Optional[List]

    PSEUDO_PARAMETERS: ClassVar[Dict[str, Union[str, List[str]]]] = {
        # default pseudo parameters
        "AWS::AccountId": "123456789012",
        "AWS::NotificationARNs": [],
        "AWS::NoValue": AWS_NOVALUE,
        "AWS::Partition": "aws",
        "AWS::Region": "eu-west-1",
        "AWS::StackId": "",
        "AWS::StackName": "",
        "AWS::URLSuffix": "amazonaws.com",
    }
github Skyscanner / pycfmodel / pycfmodel / model / resources / resource.py View on Github external
def has_hardcoded_credentials(self) -> bool:
        if not self.Metadata or not self.Metadata.get("AWS::CloudFormation::Authentication"):
            return False

        for auth in self.Metadata["AWS::CloudFormation::Authentication"].values():
            if not all(
                [
                    auth.get("accessKeyId", Parameter.NO_ECHO_NO_DEFAULT) == Parameter.NO_ECHO_NO_DEFAULT,
                    auth.get("password", Parameter.NO_ECHO_NO_DEFAULT) == Parameter.NO_ECHO_NO_DEFAULT,
                    auth.get("secretKey", Parameter.NO_ECHO_NO_DEFAULT) == Parameter.NO_ECHO_NO_DEFAULT,
                ]
            ):
                return True

        return False