當前位置: 首頁>>代碼示例>>Python>>正文


Python ec2.SecurityGroup方法代碼示例

本文整理匯總了Python中troposphere.ec2.SecurityGroup方法的典型用法代碼示例。如果您正苦於以下問題:Python ec2.SecurityGroup方法的具體用法?Python ec2.SecurityGroup怎麽用?Python ec2.SecurityGroup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在troposphere.ec2的用法示例。


在下文中一共展示了ec2.SecurityGroup方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: update_sg_with_cidr

# 需要導入模塊: from troposphere import ec2 [as 別名]
# 或者: from troposphere.ec2 import SecurityGroup [as 別名]
def update_sg_with_cidr(
        self,
        security_group,
        cidr_ip,
        ports,
        ip_protocol='tcp'
    ):
        """
        Helper method for adding rules to an sg from an sg
        @param security_group [SecurityGroup] security group to update
        @param cidr_ip [string] cidr ip
        @param ports [Dict] dictionary of from:to port objects
        @param ip_protocol [string] name of the IP protocol to set this rule
        for
        """
        security_group_rules = security_group.SecurityGroupIngress
        for from_port, to_port in ports.items():
            security_group_rules.append(ec2.SecurityGroupRule(
                IpProtocol=ip_protocol,
                FromPort=to_port,
                ToPort=to_port,
                CidrIp=cidr_ip
            )) 
開發者ID:AWSFrederick,項目名稱:Spires-Infra,代碼行數:25,代碼來源:aws_frederick_common.py

示例2: update_sg_with_sg

# 需要導入模塊: from troposphere import ec2 [as 別名]
# 或者: from troposphere.ec2 import SecurityGroup [as 別名]
def update_sg_with_sg(
        self,
        security_group,
        source_security_group_id,
        ports,
        ip_protocol='tcp'
    ):
        """
        Helper method for adding rules to an sg from an sg
        @param security_group [SecurityGroup] security group to update
        @param source_security_group_id [string] Id of the security group to
        allow ingress from
        @param ports [Dict] dictionary of from:to port objects
        @param ip_protocol [string] name of the IP protocol to set this rule
        for
        """
        security_group_rules = security_group.SecurityGroupIngress
        for from_port, to_port in ports.items():
            security_group_rules.append(ec2.SecurityGroupRule(
                IpProtocol=ip_protocol,
                FromPort=to_port,
                ToPort=to_port,
                SourceSecurityGroupId=source_security_group_id
            )) 
開發者ID:AWSFrederick,項目名稱:Spires-Infra,代碼行數:26,代碼來源:aws_frederick_common.py

示例3: sceptre_handler

# 需要導入模塊: from troposphere import ec2 [as 別名]
# 或者: from troposphere.ec2 import SecurityGroup [as 別名]
def sceptre_handler(sceptre_user_data):
    return SecurityGroup(sceptre_user_data).template.to_json() 
開發者ID:cloudreach,項目名稱:sceptre-wordpress-example,代碼行數:4,代碼來源:security_groups.py

示例4: add_sg_with_sg

# 需要導入模塊: from troposphere import ec2 [as 別名]
# 或者: from troposphere.ec2 import SecurityGroup [as 別名]
def add_sg_with_sg(
        self,
        name,
        description,
        vpc_id,
        source_security_group_id,
        ports,
        ip_protocol='tcp'
    ):
        """
        Helper method creates ingress given a source cidr range and a set of
        ports
        @param name [string] Unique name for the security group
        @param description [string] Simple description of the security group
        @param vpc_id [string] id of the vpc this sg will target
        @param source_security_group_id [string] Id of the security group to
        allow ingress from
        @param ports [Dict] dictionary of from:to port objects
        @param ip_protocol [string] name of the IP protocol to set this rule
        for
        """
        security_group_rules = []
        for from_port, to_port in ports.items():
            security_group_rules.append(ec2.SecurityGroupRule(
                IpProtocol=ip_protocol,
                FromPort=to_port,
                ToPort=to_port,
                SourceSecurityGroupId=source_security_group_id
            ))

        return self.add_resource(
            ec2.SecurityGroup(
                name,
                GroupDescription=description,
                VpcId=Ref(vpc_id),
                SecurityGroupIngress=security_group_rules,
            )
        ) 
開發者ID:AWSFrederick,項目名稱:Spires-Infra,代碼行數:40,代碼來源:aws_frederick_common.py

示例5: add_sg_with_cidr

# 需要導入模塊: from troposphere import ec2 [as 別名]
# 或者: from troposphere.ec2 import SecurityGroup [as 別名]
def add_sg_with_cidr(
        self,
        name,
        description,
        vpc_id,
        cidr,
        ports,
        ip_protocol='tcp'
    ):
        """
        Helper method creates ingress given a source cidr range and a set of
        ports
        @param name [string] Unique name for the security group
        @param description [string] Simple description of the security group
        @param vpc_id [string] id of the vpc this sg will target
        @param cidr [string] cidr ip range for ingress
        @param ports [Dict] dictionary of from:to port objects
        @param ip_protocol [string] name of the IP protocol to set this rule
        for
        """
        securityGroupRules = []
        for from_port, to_port in ports.items():
            securityGroupRules.append(ec2.SecurityGroupRule(
                IpProtocol=ip_protocol,
                FromPort=to_port,
                ToPort=to_port,
                CidrIp=cidr
            ))

        return self.add_resource(
            ec2.SecurityGroup(
                name,
                GroupDescription=description,
                VpcId=Ref(vpc_id),
                SecurityGroupIngress=securityGroupRules,
            )
        ) 
開發者ID:AWSFrederick,項目名稱:Spires-Infra,代碼行數:39,代碼來源:aws_frederick_common.py

示例6: add_simple_sg_with_sg

# 需要導入模塊: from troposphere import ec2 [as 別名]
# 或者: from troposphere.ec2 import SecurityGroup [as 別名]
def add_simple_sg_with_sg(
        self,
        name,
        description,
        vpc_id,
        source_security_group_id,
        from_port,
        to_port=None,
        ip_protocol='tcp'
    ):
        """
        Helper method creates ingress given a source cidr range and a set of
        ports
        @param name [string] Unique name for the security group
        @param description [string] Simple description of the security group
        @param vpc_id [string] id of the vpc this sg will target
        @param source_security_group_id [string] Id of the security group to
        allow ingress from
        @param from_port [string] lower boundary of the port range to set for
        the secuirty group rules
        @param to_port [string] upper boundary of the port range to set for the
        security group rules
        @param ip_protocol [string] name of the IP protocol to set this rule
        for
        """

        return self.add_resource(
            ec2.SecurityGroup(
                name,
                GroupDescription=description,
                VpcId=Ref(vpc_id),
                SecurityGroupIngress=[
                    ec2.SecurityGroupRule(
                        IpProtocol=ip_protocol,
                        FromPort=from_port,
                        ToPort=to_port,
                        SourceSecurityGroupId=source_security_group_id
                    )
                ],
            )
        ) 
開發者ID:AWSFrederick,項目名稱:Spires-Infra,代碼行數:43,代碼來源:aws_frederick_common.py

示例7: add_rds_security_group

# 需要導入模塊: from troposphere import ec2 [as 別名]
# 或者: from troposphere.ec2 import SecurityGroup [as 別名]
def add_rds_security_group(self, name, vpc_id):
        return self.add_resource(
            ec2.SecurityGroup(
                name + "RDSSecurityGroup",
                GroupDescription="Security group for RDS DB Instance.",
                VpcId=Ref(vpc_id)
            )
        ) 
開發者ID:AWSFrederick,項目名稱:Spires-Infra,代碼行數:10,代碼來源:aws_frederick_common.py

示例8: add_elasticache_sg

# 需要導入模塊: from troposphere import ec2 [as 別名]
# 或者: from troposphere.ec2 import SecurityGroup [as 別名]
def add_elasticache_sg(self, name, engine):
        return self.add_resource(
            elasticache.SecurityGroup(
                name + engine + 'ClusterSecurityGroup',
                Description='ElastiCache security group for ' + name + engine
            )
        ) 
開發者ID:AWSFrederick,項目名稱:Spires-Infra,代碼行數:9,代碼來源:aws_frederick_common.py

示例9: security_group

# 需要導入模塊: from troposphere import ec2 [as 別名]
# 或者: from troposphere.ec2 import SecurityGroup [as 別名]
def security_group(group_id, vpc_id, ingress_structs, description=""):
    return ec2.SecurityGroup(group_id, **{
        'GroupDescription': description or 'security group',
        'VpcId': vpc_id,
        'SecurityGroupIngress': map(complex_ingress, ingress_structs)
    }) 
開發者ID:elifesciences,項目名稱:builder,代碼行數:8,代碼來源:trop.py


注:本文中的troposphere.ec2.SecurityGroup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。