How to use the pycfmodel.model.types.ResolvableStr 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 / pycfmodel / model / resources / resource.py View on Github external
from typing import ClassVar, Dict, Optional

from pydantic import validator

from pycfmodel.model.base import CustomModel
from pycfmodel.model.parameter import Parameter
from pycfmodel.model.types import ResolvableCondition, ResolvableStr, ResolvableStrOrList


class Resource(CustomModel):
    TYPE_VALUE: ClassVar[str]
    Type: str
    Condition: Optional[ResolvableCondition] = None
    CreatePolicy: Optional[Dict] = None
    DeletionPolicy: Optional[ResolvableStr] = None
    DependsOn: Optional[ResolvableStrOrList] = None
    Metadata: Optional[Dict] = None
    UpdatePolicy: Optional[Dict] = None
    UpdateReplacePolicy: Optional[ResolvableStr] = None

    @validator("Type")
    def check_type(cls, value):
        if value != cls.TYPE_VALUE:
            raise ValueError(f"Value needs to be {cls.TYPE_VALUE}")
        return value

    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():
github Skyscanner / pycfmodel / pycfmodel / model / resources / properties / security_group_ingress_prop.py View on Github external
- IpProtocol: The IP protocol name (tcp, udp, icmp, icmpv6) or number ([see Protocol Numbers](http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml)).
    - SourcePrefixListId: The prefix list IDs for an AWS service.
    - SourceSecurityGroupId: The ID of the security group.
    - SourceSecurityGroupName: The name of the source security group.
    - SourceSecurityGroupOwnerId: The AWS account ID for the source security group.
    - ToPort: The end of port range for the TCP and UDP protocols.

    More info at [AWS Docs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group-ingress.html)
    """

    CidrIp: Optional[ResolvableIPv4Network] = None
    CidrIpv6: Optional[ResolvableIPv6Network] = None
    Description: Optional[ResolvableStr] = None
    FromPort: Optional[ResolvableInt] = None
    IpProtocol: ResolvableIntOrStr
    SourcePrefixListId: Optional[ResolvableStr] = None
    SourceSecurityGroupId: Optional[ResolvableStr] = None
    SourceSecurityGroupName: Optional[ResolvableStr] = None
    SourceSecurityGroupOwnerId: Optional[ResolvableStr] = None
    ToPort: Optional[ResolvableInt] = None

    @validator("CidrIp", pre=True)
    def set_CidrIp(cls, v):
        return IPv4Network(v, strict=False)

    @validator("CidrIpv6", pre=True)
    def set_CidrIpv6(cls, v):
        return IPv6Network(v, strict=False)

    def ipv4_slash_zero(self) -> bool:
        """ Returns True if `CidrIp` matches `0.0.0.0/0`, otherwise False. """
        # Remove after this is fixed https://bugs.python.org/issue38655
github Skyscanner / pycfmodel / pycfmodel / model / resources / security_group_ingress.py View on Github external
- Description: Description for the security group rule.
    - FromPort: Start of port range for the TCP and UDP protocols, or an ICMP/ICMPv6 type number. A value of -1 indicates all ICMP/ICMPv6 types.
    - GroupId: ID of the security group.
    - GroupName: Name of the security group.
    - IpProtocol: IP protocol name.
    - SourcePrefixListId: The prefix list IDs for an AWS service.
    - SourceSecurityGroupId: ID of the security group.
    - SourceSecurityGroupName: Name of the source security group.
    - SourceSecurityGroupOwnerId: AWS account ID for the source security group.
    - ToPort: End of port range for the TCP and UDP protocols, or an ICMP/ICMPv6 code. A value of -1 indicates all ICMP/ICMPv6 codes.

    More info at [AWS Docs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group-ingress.html)
    """

    GroupId: Optional[ResolvableStr] = None
    GroupName: Optional[ResolvableStr] = None


class SecurityGroupIngress(Resource):
    """
    Properties:

    - Properties: A [Security Group Ingress Properties][pycfmodel.model.resources.kms_key.KMSKeyProperties] object.

    More info at [AWS Docs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group-ingress.html)
    """

    TYPE_VALUE: ClassVar = "AWS::EC2::SecurityGroupIngress"
    Type: str = TYPE_VALUE
    Properties: SecurityGroupIngressProperties

    def ipv4_slash_zero(self) -> bool:
github Skyscanner / pycfmodel / pycfmodel / model / resources / properties / statement.py View on Github external
import logging
from typing import Dict, List, Optional, Pattern, Union

from pycfmodel.model.resources.properties.property import Property
from pycfmodel.model.types import ResolvableStr, ResolvableStrOrList
from pycfmodel.utils import is_resolvable_dict

logger = logging.getLogger(__file__)

PrincipalTypes = Union[ResolvableStr, List[ResolvableStr], Dict[str, Union[ResolvableStr, List[ResolvableStr]]]]


class Statement(Property):
    """
    Contains information about an attached policy.

    Properties:

    - Sid: Optional identifier.
    - Effect: Whether the statement results in an allow or an explicit deny.
    - Principal: Specify the IAM user, federated user, IAM role, AWS account, AWS service, or other principal that is allowed to access a resource.
    - NotPrincipal: Specify the IAM user, federated user, IAM role, AWS account, AWS service, or other principal that is not allowed or denied access to a resource.
    - Action: Specific action or actions that will be allowed or denied.
    - NotAction: Explicitly matches everything except the specified action or list of actions.
    - Resource: Specifies the object or objects that the statement covers.
    - NotResource: Specifies the object or objects that the statement does not cover.
github Skyscanner / pycfmodel / pycfmodel / model / resources / iam_user.py View on Github external
class IAMUserProperties(CustomModel):
    """
    Properties:

    - Groups: List of groups to attach.
    - LoginProfile: Name and password for the user.
    - ManagedPolicyArns: List of ARNs of the IAM managed policies to attach.
    - Path: Path to the user.
    - PermissionsBoundary: ARN of the policy used to set the permissions boundary.
    - Policies: A list of [policy][pycfmodel.model.resources.properties.policy.Policy] objects.
    - UserName: Name of the user.

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

    Groups: Optional[Resolvable[List[ResolvableStr]]] = None
    LoginProfile: Optional[Dict] = None
    ManagedPolicyArns: Optional[Resolvable[List[ResolvableStr]]] = None
    Path: Optional[ResolvableStr] = None
    PermissionsBoundary: Optional[ResolvableStr] = None
    Policies: Optional[Resolvable[List[Resolvable[Policy]]]] = None
    UserName: Optional[ResolvableStr] = None


class IAMUser(Resource):
    """
    Properties:

    - Properties: A [IAM User properties][pycfmodel.model.resources.iam_user.IAMUserProperties] object.

    More info at [AWS Docs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-user.html)
    """
github Skyscanner / pycfmodel / pycfmodel / model / resources / sns_topic_policy.py View on Github external
from pycfmodel.model.resources.resource import Resource
from pycfmodel.model.types import Resolvable, ResolvableStr


class SNSTopicPolicyProperties(CustomModel):
    """
    Properties:

    - PolicyDocument: A [policy document][pycfmodel.model.resources.properties.policy_document.PolicyDocument] object.
    - Topics: ARNs of the topics to add the policy.

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

    PolicyDocument: Resolvable[PolicyDocument]
    Topics: List[ResolvableStr]


class SNSTopicPolicy(Resource):
    """
    Properties:

    - Properties: A [SNS Topic Policy][pycfmodel.model.resources.sns_topic_policy.SNSTopicPolicyProperties] object.

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

    TYPE_VALUE: ClassVar = "AWS::SNS::TopicPolicy"
    Type: str = TYPE_VALUE
    Properties: Resolvable[SNSTopicPolicyProperties]
github Skyscanner / pycfmodel / pycfmodel / model / resources / kms_key.py View on Github external
class KMSKeyProperties(CustomModel):
    """
    Properties:

    - Description: Description of the CMK.
    - EnableKeyRotation: Enables automatic rotation of the key for the customer master key.
    - Enabled: Specifies whether the customer master key (CMK) is enabled.
    - KeyPolicy: A [policy document][pycfmodel.model.resources.properties.policy_document.PolicyDocument] object.
    - KeyUsage: Determines the cryptographic operations.
    - PendingWindowInDays: Number of days in the waiting period before AWS KMS deletes a CMK that has been removed from a CloudFormation stack.
    - Tags: Array of key-value pairs.

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

    Description: Optional[ResolvableStr] = None
    EnableKeyRotation: Optional[ResolvableBool] = None
    Enabled: Optional[ResolvableBool] = None
    KeyPolicy: Resolvable[PolicyDocument]
    KeyUsage: Optional[ResolvableStr] = None
    PendingWindowInDays: Optional[ResolvableInt] = None
    Tags: Optional[Resolvable[List[Dict]]] = None


class KMSKey(Resource):
    """
    Properties:

    - Properties: A [KMS Key properties][pycfmodel.model.resources.kms_key.KMSKeyProperties] object.

    More info at [AWS Docs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kms-key.html)
    """
github Skyscanner / pycfmodel / pycfmodel / model / resources / security_group.py View on Github external
class SecurityGroupProperties(CustomModel):
    """
    Properties:

    - GroupDescription: Description for the security group.
    - GroupName: Name of the security group.
    - SecurityGroupEgress: Outbound rules associated with the security group.
    - SecurityGroupIngress: Inbound rules associated with the security group.
    - Tags: Array of key-value pairs.
    - VpcId: ID of the VPC for the security group.

    More info at [AWS Docs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group.html)
    """

    GroupDescription: ResolvableStr
    GroupName: Optional[ResolvableStr] = None
    SecurityGroupEgress: Optional[
        Resolvable[Union[SecurityGroupEgressProp, List[Resolvable[SecurityGroupEgressProp]]]]
    ] = None
    SecurityGroupIngress: Optional[
        Resolvable[Union[SecurityGroupIngressProp, List[Resolvable[SecurityGroupIngressProp]]]]
    ] = None
    Tags: Optional[Resolvable[List[Dict]]] = None
    VpcId: Optional[ResolvableStr] = None


class SecurityGroup(Resource):
    """
    Properties:

    - Properties: A [Security Group Properties][pycfmodel.model.resources.security_group.SecurityGroupProperties] object.
github Skyscanner / pycfmodel / pycfmodel / model / resources / iam_group.py View on Github external
class IAMGroupProperties(CustomModel):
    """
    Properties:

    - GroupName: Name of the group.
    - ManagedPolicyArns: ARN of the IAM policies to attach.
    - Path: Path to the group. See [IAM Identifiers](https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html).
    - Policies: Inline policies embedded in the IAM group.

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

    GroupName: Optional[ResolvableStr] = None
    ManagedPolicyArns: Optional[Resolvable[List[ResolvableStr]]] = None
    Path: Optional[ResolvableStr] = None
    Policies: Optional[Resolvable[List[IAMPolicy]]] = None


class IAMGroup(Resource):
    """
    Properties:

    - Properties: A [IAM Group properties][pycfmodel.model.resources.iam_group.IAMGroupProperties] object.

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

    TYPE_VALUE: ClassVar = "AWS::IAM::Group"
    Type: str = TYPE_VALUE
    Properties: Resolvable[IAMGroupProperties]
github Skyscanner / pycfmodel / pycfmodel / model / resources / security_group.py View on Github external
- Tags: Array of key-value pairs.
    - VpcId: ID of the VPC for the security group.

    More info at [AWS Docs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group.html)
    """

    GroupDescription: ResolvableStr
    GroupName: Optional[ResolvableStr] = None
    SecurityGroupEgress: Optional[
        Resolvable[Union[SecurityGroupEgressProp, List[Resolvable[SecurityGroupEgressProp]]]]
    ] = None
    SecurityGroupIngress: Optional[
        Resolvable[Union[SecurityGroupIngressProp, List[Resolvable[SecurityGroupIngressProp]]]]
    ] = None
    Tags: Optional[Resolvable[List[Dict]]] = None
    VpcId: Optional[ResolvableStr] = None


class SecurityGroup(Resource):
    """
    Properties:

    - Properties: A [Security Group Properties][pycfmodel.model.resources.security_group.SecurityGroupProperties] object.

    More info at [AWS Docs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group.html)
    """

    TYPE_VALUE: ClassVar = "AWS::EC2::SecurityGroup"
    Type: str = TYPE_VALUE
    Properties: Resolvable[SecurityGroupProperties]