当前位置: 首页>>代码示例>>Python>>正文


Python troposphere.FindInMap方法代码示例

本文整理汇总了Python中troposphere.FindInMap方法的典型用法代码示例。如果您正苦于以下问题:Python troposphere.FindInMap方法的具体用法?Python troposphere.FindInMap怎么用?Python troposphere.FindInMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在troposphere的用法示例。


在下文中一共展示了troposphere.FindInMap方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_autoscaling_group

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import FindInMap [as 别名]
def create_autoscaling_group(self):
        t = self.template
        t.add_resource(
            autoscaling.LaunchConfiguration(
                "EmpireMinionLaunchConfig",
                IamInstanceProfile=GetAtt("EmpireMinionProfile", "Arn"),
                ImageId=FindInMap(
                    "AmiMap",
                    Ref("AWS::Region"),
                    Ref("ImageName")),
                BlockDeviceMappings=self.build_block_device(),
                InstanceType=Ref("InstanceType"),
                KeyName=Ref("SshKeyName"),
                UserData=self.generate_user_data(),
                SecurityGroups=[Ref("DefaultSG"), Ref(CLUSTER_SG_NAME)]))
        t.add_resource(
            autoscaling.AutoScalingGroup(
                "EmpireMinionAutoscalingGroup",
                AvailabilityZones=Ref("AvailabilityZones"),
                LaunchConfigurationName=Ref("EmpireMinionLaunchConfig"),
                MinSize=Ref("MinHosts"),
                MaxSize=Ref("MaxHosts"),
                VPCZoneIdentifier=Ref("PrivateSubnets"),
                Tags=[ASTag("Name", "empire_minion", True)])) 
开发者ID:remind101,项目名称:stacker_blueprints,代码行数:26,代码来源:minion.py

示例2: create_autoscaling_group

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import FindInMap [as 别名]
def create_autoscaling_group(self):
        t = self.template
        t.add_resource(
            autoscaling.LaunchConfiguration(
                'BastionLaunchConfig',
                AssociatePublicIpAddress=True,
                ImageId=FindInMap(
                    'AmiMap', Ref("AWS::Region"), Ref("ImageName")),
                InstanceType=Ref("InstanceType"),
                KeyName=Ref("SshKeyName"),
                UserData=self.generate_user_data(),
                SecurityGroups=[Ref("DefaultSG"), Ref(CLUSTER_SG_NAME)]))
        t.add_resource(
            autoscaling.AutoScalingGroup(
                'BastionAutoscalingGroup',
                AvailabilityZones=Ref("AvailabilityZones"),
                LaunchConfigurationName=Ref("BastionLaunchConfig"),
                MinSize=Ref("MinSize"),
                MaxSize=Ref("MaxSize"),
                VPCZoneIdentifier=Ref("PublicSubnets"),
                Tags=[ASTag('Name', 'bastion', True)])) 
开发者ID:remind101,项目名称:stacker_blueprints,代码行数:23,代码来源:bastion.py

示例3: construct_network

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import FindInMap [as 别名]
def construct_network(self):
        """
        Main function to construct VPC, subnets, security groups, NAT instances, etc
        """
        network_config = self.network_config
        nat_config = self.nat_config
        az_count = self.az_count

        self.add_network_cidr_mapping(network_config=network_config)
        self._prepare_subnets(self._subnet_configs)
        self.create_network_components(network_config=network_config, nat_config=nat_config)

        self._common_security_group = self.add_resource(ec2.SecurityGroup('commonSecurityGroup',
            GroupDescription='Security Group allows ingress and egress for common usage patterns throughout this deployed infrastructure.',
            VpcId=self.vpc_id,
            SecurityGroupEgress=[ec2.SecurityGroupRule(
                        FromPort='80',
                        ToPort='80',
                        IpProtocol='tcp',
                        CidrIp='0.0.0.0/0'),
                    ec2.SecurityGroupRule(
                        FromPort='443',
                        ToPort='443',
                        IpProtocol='tcp',
                        CidrIp='0.0.0.0/0'),
                    ec2.SecurityGroupRule(
                        FromPort='123',
                        ToPort='123',
                        IpProtocol='udp',
                        CidrIp='0.0.0.0/0')],
            SecurityGroupIngress=[
                    ec2.SecurityGroupRule(
                        FromPort='22',
                        ToPort='22',
                        IpProtocol='tcp',
                        CidrIp=FindInMap('networkAddresses', 'vpcBase', 'cidr'))]))

        self.add_output(Output('commonSecurityGroup', Value=self.common_security_group)) 
开发者ID:DualSpark,项目名称:cloudformation-environmentbase,代码行数:40,代码来源:base_network.py

示例4: add_nat_asg

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import FindInMap [as 别名]
def add_nat_asg(self):

        user_data = [resources.get_resource('nat_takeover.sh')]

        if self.enable_ntp:
            user_data.append(resources.get_resource('ntp_takeover.sh'))
        if self.extra_user_data:
            user_data.append(open(self.extra_user_data).read())

        nat_asg_name = "Nat%sASG" % str(self.subnet_index)

        user_data.extend([
            "\n",
            "cfn-signal -s true",
            " --resource ", nat_asg_name,
            " --stack ", {"Ref": "AWS::StackName"},
            " --region ", {"Ref": "AWS::Region"}
        ])
 
        nat_launch_config = self.add_resource(LaunchConfiguration(
            "Nat%sLaunchConfig" % str(self.subnet_index),
            UserData=Base64(Join('', user_data)),
            ImageId=FindInMap('RegionMap', Ref('AWS::Region'), 'natAmiId'),
            KeyName=Ref('ec2Key'),
            SecurityGroups=[Ref(self.sg)],
            EbsOptimized=False,
            IamInstanceProfile=Ref(self.instance_profile),
            InstanceType=self.instance_type,
            AssociatePublicIpAddress=True
        ))

        # Create the NAT in a public subnet
        subnet_layer = self._subnets['public'].keys()[0]

        nat_asg = self.add_resource(AutoScalingGroup(
            nat_asg_name,
            DesiredCapacity=1,
            Tags=[
                Tag("Name", Join("-", ["NAT", self.subnet_index,]), True),
                Tag("isNat", "true", True)
            ],
            MinSize=1,
            MaxSize=1,
            Cooldown="30",
            LaunchConfigurationName=Ref(nat_launch_config),
            HealthCheckGracePeriod=30,
            HealthCheckType="EC2",
            VPCZoneIdentifier=[self._subnets['public'][subnet_layer][self.subnet_index]],
            CreationPolicy=CreationPolicy(
                ResourceSignal=ResourceSignal(
                    Count=1,
                    Timeout='PT15M'
                )
            )
        ))

        return nat_asg 
开发者ID:DualSpark,项目名称:cloudformation-environmentbase,代码行数:59,代码来源:ha_nat.py


注:本文中的troposphere.FindInMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。