当前位置: 首页>>代码示例>>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;未经允许,请勿转载。