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


Python troposphere.Output方法代码示例

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


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

示例1: prepare_efs_security_groups

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Output [as 别名]
def prepare_efs_security_groups(self):
        t = self.template
        v = self.get_variables()

        created_groups = []
        for sg in v['SecurityGroups']:
            sg.VpcId = v['VpcId']
            sg.Tags = merge_tags(v['Tags'], getattr(sg, 'Tags', {}))

            sg = t.add_resource(sg)
            created_groups.append(sg)

        created_group_ids = list(map(Ref, created_groups))
        t.add_output(Output(
            'EfsNewSecurityGroupIds',
            Value=Join(',', created_group_ids)))

        groups_ids = created_group_ids + v['ExtraSecurityGroups']
        return groups_ids 
开发者ID:remind101,项目名称:stacker_blueprints,代码行数:21,代码来源:efs.py

示例2: create_efs_mount_targets

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Output [as 别名]
def create_efs_mount_targets(self, fs):
        t = self.template
        v = self.get_variables()

        groups = self.prepare_efs_security_groups()
        subnets = v['Subnets']
        ips = v['IpAddresses']

        mount_targets = []
        for i, subnet in enumerate(subnets):
            mount_target = efs.MountTarget(
                'EfsMountTarget{}'.format(i + 1),
                FileSystemId=Ref(fs),
                SubnetId=subnet,
                SecurityGroups=groups)

            if ips:
                mount_target.IpAddress = ips[i]

            mount_target = t.add_resource(mount_target)
            mount_targets.append(mount_target)

        t.add_output(Output(
            'EfsMountTargetIds',
            Value=Join(',', list(map(Ref, mount_targets))))) 
开发者ID:remind101,项目名称:stacker_blueprints,代码行数:27,代码来源:efs.py

示例3: construct_network

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Output [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_outputs

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Output [as 别名]
def add_outputs(self):
        """
        Wrapper method to encapsulate creation of stack outputs for this template
        """
        self.add_output(Output('%sELBDNSName' % self.name, Value=GetAtt(self.cluster_elb, 'DNSName')))
        self.add_output(Output('%sSecurityGroupId' % self.name, Value=Ref(self.security_groups['ha_cluster'])))
        self.add_output(Output('%sElbSecurityGroupId' % self.name, Value=Ref(self.security_groups['elb']))) 
开发者ID:DualSpark,项目名称:cloudformation-environmentbase,代码行数:9,代码来源:ha_cluster.py

示例5: add_nat_sg

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Output [as 别名]
def add_nat_sg(self):
        '''
        Create the NAT security group and add the ingress/egress rules
        '''
        self.sg = self.add_resource(SecurityGroup(
            "Nat%sSG" % str(self.subnet_index),
            VpcId=self.vpc_id,
            GroupDescription="Security group for NAT host."
        ))
        self.add_output(Output(self.sg.name, Value=Ref(self.sg)))
        self.add_nat_sg_rules() 
开发者ID:DualSpark,项目名称:cloudformation-environmentbase,代码行数:13,代码来源:ha_nat.py

示例6: build_hook

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Output [as 别名]
def build_hook(self):
        """
        Hook to add tier-specific assets within the build stage of initializing this class.
        """
        security_groups = self.add_security_groups()

        bastion_elb = self.add_elb(
            resource_name=self.name,
            security_groups=[security_groups['elb']],
            listeners=[{
                'elb_port': self.ingress_port,
                'instance_port': SSH_PORT
            }],
            utility_bucket=self.utility_bucket
        )

        bastion_asg = self.add_asg(
            layer_name=self.name,
            security_groups=[security_groups['bastion'], self.common_security_group],
            load_balancer=bastion_elb,
            user_data=self.user_data,
            instance_type=self.instance_type
        )

        self.add_output(Output(
            'BastionELBDNSName',
            Value=GetAtt(bastion_elb, 'DNSName')
        ))

        self.add_output(Output(
            'BastionELBDNSZoneId',
             Value=GetAtt(bastion_elb, 'CanonicalHostedZoneNameID')
         ))

        self.add_output(Output(
            'BastionSecurityGroupId',
            Value=Ref(security_groups['bastion'])
        )) 
开发者ID:DualSpark,项目名称:cloudformation-environmentbase,代码行数:40,代码来源:bastion.py

示例7: to_template_json

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Output [as 别名]
def to_template_json(self):
        """
        Process all child templates recursively and render this template as json with a timestamp identifying
        when it was generated along with a SHA256 hash representing the template for validation purposes
        """
        self.process_child_templates()

        # strip existing values
        for output_key in ['dateGenerated', 'templateValidationHash']:
            if output_key in self.outputs:
                self.outputs.pop(output_key)

        # generate the template validation hash
        if self.include_templateValidationHash_output and 'templateValidationHash' not in self.outputs:
            self.add_output(Output(
                'templateValidationHash',
                Value=self.__get_template_hash(),
                Description='Hash of this template that can be used as a simple means of validating whether a template has been changed since it was generated.'))

        # set the date that this template was generated
        if self.include_dateGenerated_output and 'dateGenerated' not in self.outputs:
            self.add_output(Output(
                'dateGenerated',
                Value=str(datetime.utcnow()),
                Description='UTC datetime representation of when this template was generated'))

        return self.to_json() 
开发者ID:DualSpark,项目名称:cloudformation-environmentbase,代码行数:29,代码来源:template.py

示例8: get_elb_stickiness_policy

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Output [as 别名]
def get_elb_stickiness_policy(self, PolicyName, **kwargs):
        """Output like:
        {
           "PolicyName" : String
           "CookieExpirationPeriod" : String,
        }
        Source: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-elb-connectiondrainingpolicy.html
        """
        stickiness_policy_kwargs = { "PolicyName" : PolicyName, }
        stickiness_policy_kwargs.update(kwargs)

        stickiness_policy = elb.LBCookieStickinessPolicy(**stickiness_policy_kwargs)
        return stickiness_policy 
开发者ID:DualSpark,项目名称:cloudformation-environmentbase,代码行数:15,代码来源:template.py

示例9: add_utility_bucket

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Output [as 别名]
def add_utility_bucket(self, name=None):
        """
        Method adds a bucket to be used for infrastructure utility purposes such as backups
        @param name [str] friendly name to prepend to the CloudFormation asset name
        """

        if name:
            self._utility_bucket = self.add_parameter(Parameter(
                'utilityBucket',
                Description='Name of the S3 bucket used for infrastructure utility',
                Default=name,
                AllowedPattern=res.get_str('ascii_only'),
                MinLength=1,
                MaxLength=255,
                ConstraintDescription=res.get_str('ascii_only_message'),
                Type='String'))
        else:
            self._utility_bucket = self.add_resource(s3.Bucket(
                name.lower() + 'UtilityBucket',
                AccessControl=s3.BucketOwnerFullControl,
                DeletionPolicy=Retain))

            bucket_policy_statements = self.get_logging_bucket_policy_document(
                self.utility_bucket,
                elb_log_prefix=res.get_str('elb_log_prefix', ''),
                cloudtrail_log_prefix=res.get_str('cloudtrail_log_prefix', ''))

            self.add_resource(s3.BucketPolicy(
                name.lower() + 'UtilityBucketLoggingPolicy',
                Bucket=self.utility_bucket,
                PolicyDocument=bucket_policy_statements))

        self.add_output(Output('utilityBucket', Value=self.utility_bucket))

        self.manual_parameter_bindings['utilityBucket'] = self.utility_bucket 
开发者ID:DualSpark,项目名称:cloudformation-environmentbase,代码行数:37,代码来源:template.py

示例10: add_child_outputs_to_parameter_binding

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Output [as 别名]
def add_child_outputs_to_parameter_binding(self, child_template, propagate_up=False):
        """
        This auto-wires the outputs of the child stack to the manual_param of the parent stack
        """
        for output in child_template.outputs:
            self.manual_parameter_bindings[output] = GetAtt(child_template.name, "Outputs." + output)
            if propagate_up:
                self.add_output(Output(output, Value=GetAtt(child_template.name, "Outputs." + output)))
            # TODO: should a custom resource be addeded for each output? 
开发者ID:DualSpark,项目名称:cloudformation-environmentbase,代码行数:11,代码来源:template.py

示例11: match_stack_parameters

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Output [as 别名]
def match_stack_parameters(self, child_template):
        """
        For all matching parameters between this template and the child template, attempt to
        get the value from this template's parameters, resources, and manual parameter bindings.
        Return the dictionary of stack parameters to deploy the child template with
        """
        stack_params = {}

        for parameter in child_template.parameters.keys():

            # Manual parameter bindings single-namespace
            if parameter in self.manual_parameter_bindings:
                manual_match = self.manual_parameter_bindings[parameter]
                stack_params[parameter] = manual_match

            # Match any child stack parameters that have the same name as this stacks **parameters**
            elif parameter in self.parameters.keys():
                param_match = self.parameters.get(parameter)
                stack_params[parameter] = Ref(param_match)

            # Match any child stack parameters that have the same name as this stacks **resources**
            elif parameter in self.resources.keys():
                resource_match = self.resources.get(parameter)
                stack_params[parameter] = Ref(resource_match)

            # # Match any child stack parameters that have the same name as a top-level **stack_output**
            # TODO: Enable Output autowiring
            # elif parameter in self.stack_outputs:
            #     stack_params[parameter] = GetAtt(self.stack_outputs[parameter], 'Outputs.' + parameter)

            # Finally if nothing else matches copy the child templates parameter to this template's parameter list
            # so the value will pass through this stack down to the child.
            else:
                new_param = self.add_parameter(child_template.parameters[parameter])
                stack_params[parameter] = Ref(new_param)

        return stack_params 
开发者ID:DualSpark,项目名称:cloudformation-environmentbase,代码行数:39,代码来源:template.py

示例12: test_tropo_to_string

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Output [as 别名]
def test_tropo_to_string(self):
        utility.tropo_to_string(tropo.Template())
        utility.tropo_to_string(tropo.Base64('efsdfsdf'))
        utility.tropo_to_string(tropo.Output('efsdfsdf', Value='dsfsdfs'))
        utility.tropo_to_string(tropo.Parameter('efsdfsdf', Type='dsfsdfs'))

        # These constructors recursively call themselves for some reason
        # Don't instantiate directly
        # utility.tropo_to_string(tropo.AWSProperty())
        # utility.tropo_to_string(tropo.AWSAttribute())

        utility.tropo_to_string(ec2.Instance(
            "ec2instance",
            InstanceType="m3.medium",
            ImageId="ami-951945d0")) 
开发者ID:DualSpark,项目名称:cloudformation-environmentbase,代码行数:17,代码来源:test_template.py

示例13: create_template

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Output [as 别名]
def create_template():
    template = Template(
        Description='DNS Validated ACM Certificate Example'
    )
    template.set_version()

    certificate = template.add_resource(certificatemanager.Certificate(
        'ExampleCertificate',
        ValidationMethod='DNS',
        DomainName='test.example.com',
        DomainValidationOptions=[
            certificatemanager.DomainValidationOption(
                DomainName='test.example.com',
                HostedZoneId='Z2KZ5YTUFZNC7H'
            )
        ],
        Tags=[{
            'Key': 'Name',
            'Value': 'Example Certificate'
        }]
    ))

    template.add_output(Output(
        'CertificateARN',
        Value=Ref(certificate),
        Description='The ARN of the example certificate'
    ))

    return template 
开发者ID:dflook,项目名称:cloudformation-dns-certificate,代码行数:31,代码来源:cloudformation.py

示例14: get_output_definitions

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Output [as 别名]
def get_output_definitions(self):
        """Get the output definitions.

        Returns:
            Dict[str, Dict[str, str]]: Output definitions. Keys are output
            names, the values are dicts containing key/values for various
            output properties.

        """
        return {k: output.to_dict() for k, output in
                self.template.outputs.items()} 
开发者ID:onicagroup,项目名称:runway,代码行数:13,代码来源:base.py

示例15: add_output

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Output [as 别名]
def add_output(self, name, value):
        """Add an output to the template.

        Wrapper for ``self.template.add_output(Output(name, Value=value))``.

        Args:
            name (str): The name of the output to create.
            value (str): The value to put in the output.

        """
        self.template.add_output(Output(name, Value=value)) 
开发者ID:onicagroup,项目名称:runway,代码行数:13,代码来源:base.py


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