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


Python troposphere.Parameter方法代码示例

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


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

示例1: add_cname

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Parameter [as 别名]
def add_cname(self):
        """
        Wrapper method to encapsulate process of creating a CNAME DNS record for the ELB
        Requires InternalHostedZone parameter
        Sets self.cname_record with the record resource
        """

        if not self.cname:
            return

        hosted_zone = self.add_parameter(Parameter(
            'InternalHostedZone',
            Description='Internal Hosted Zone Name',
            Type='String'))

        self.cname_record = self.add_resource(route53.RecordSetType(
            self.name.lower() + 'DnsRecord',
            HostedZoneId=Ref(hosted_zone),
            Comment='CNAME record for %s' % self.name,
            Name=self.cname,
            Type='CNAME',
            TTL='300',
            ResourceRecords=[GetAtt(self.cluster_elb, 'DNSName')])) 
开发者ID:DualSpark,项目名称:cloudformation-environmentbase,代码行数:25,代码来源:ha_cluster.py

示例2: add_parameter_binding

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Parameter [as 别名]
def add_parameter_binding(self, key, value):
        """
        Deployment parameters are used to provide values for parameterized templates

        The deploy_parameter_bindings is populated with hashes of the form:
         {
             'ParameterKey': <key>,
             'ParameterValue': <value>
         }

        :param key: String representing an input Parameter name in the root template
        :param value: Troposphere value for the Parameter
        """
        self.deploy_parameter_bindings.append({
            'ParameterKey': key,
            'ParameterValue': value
        }) 
开发者ID:DualSpark,项目名称:cloudformation-environmentbase,代码行数:19,代码来源:environmentbase.py

示例3: build_parameter

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Parameter [as 别名]
def build_parameter(name, properties):
    """Build a troposphere Parameter with the given properties.

    Args:
        name (str): The name of the parameter.
        properties (Dict[str, Any]): Contains the properties that will be applied to the
            parameter. See:
            http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html

    Returns:
        :class:`troposphere.Parameter`: The created parameter object.

    """
    param = Parameter(name, Type=properties.get("type"))
    for name_, attr in PARAMETER_PROPERTIES.items():
        if name_ in properties:
            setattr(param, attr, properties[name_])
    return param 
开发者ID:onicagroup,项目名称:runway,代码行数:20,代码来源:base.py

示例4: get_parameter_definitions

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Parameter [as 别名]
def get_parameter_definitions(self):
        """Get the parameter definitions to submit to CloudFormation.

        Any variable definition whose `type` is an instance of `CFNType` will
        be returned as a CloudFormation Parameter.

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

        """
        output = {}
        for var_name, attrs in self.defined_variables().items():
            var_type = attrs.get("type")
            if isinstance(var_type, CFNType):
                cfn_attrs = copy.deepcopy(attrs)
                cfn_attrs["type"] = var_type.parameter_type
                output[var_name] = cfn_attrs
        return output 
开发者ID:onicagroup,项目名称:runway,代码行数:22,代码来源:base.py

示例5: cache_param

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Parameter [as 别名]
def cache_param(self, value):
        '''Returns a troposphere Ref to a value cached as a parameter.'''

        if value not in self.cf_parameters:
            keyname = chr(ord('A') + len(self.cf_parameters))
            param = self.cf_template.add_parameter(troposphere.Parameter(
                keyname, Type="String", Default=value, tags=self.tags
            ))

            self.cf_parameters[value] = param

        return troposphere.Ref(self.cf_parameters[value])

    ##
    # Packaging
    ## 
开发者ID:Miserlou,项目名称:Zappa,代码行数:18,代码来源:core.py

示例6: _build_template

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Parameter [as 别名]
def _build_template(github_owner: str, github_branch: str) -> Template:
    """Build and return the pipeline template."""
    template = Template(Description="CI/CD pipeline for Decrypt Oracle powered by the AWS Encryption SDK for Python")
    github_access_token = template.add_parameter(
        troposphere.Parameter(
            "GithubPersonalToken", Type="String", Description="Personal access token for the github repo.", NoEcho=True
        )
    )
    application_bucket = template.add_resource(s3.Bucket("ApplicationBucket"))
    artifact_bucket = template.add_resource(s3.Bucket("ArtifactBucketStore"))
    builder_role = template.add_resource(_codebuild_role())
    builder = template.add_resource(_codebuild_builder(builder_role, application_bucket))
    # add codepipeline role
    pipeline_role = template.add_resource(_pipeline_role(buckets=[application_bucket, artifact_bucket]))
    # add cloudformation deploy role
    cfn_role = template.add_resource(_cloudformation_role())
    # add codepipeline
    template.add_resource(
        _pipeline(
            pipeline_role=pipeline_role,
            cfn_role=cfn_role,
            codebuild_builder=builder,
            artifact_bucket=artifact_bucket,
            github_owner=github_owner,
            github_branch=github_branch,
            github_access_token=github_access_token,
        )
    )
    return template 
开发者ID:aws,项目名称:aws-encryption-sdk-python,代码行数:31,代码来源:pipeline.py

示例7: add_parameter_idempotent

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Parameter [as 别名]
def add_parameter_idempotent(self, troposphere_parameter):
        """
        Idempotent add (add only if not exists) for parameters within the template
        @param [Troposphere.Parameter] Troposphere Parameter to add to this template
        """
        if troposphere_parameter.title not in self.parameters:
            return self.add_parameter(troposphere_parameter)
        else:
            return None 
开发者ID:DualSpark,项目名称:cloudformation-environmentbase,代码行数:11,代码来源:template.py

示例8: add_utility_bucket

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

示例9: get_template_s3_url

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Parameter [as 别名]
def get_template_s3_url(self, child_template):
        """
        Overridable method for getting the s3 url for child templates.

        By default it uses the `TemplateBucket` Parameter and
            `child_template.resource_path` to build the URL.
        Use `utility.get_template_s3_url(Template.template_bucket_default, child_template.resource_path)`
            if you want a non-parametrized version of this URL.
        """
        return Join('', ['https://', Ref(self.template_bucket_param), '.s3.amazonaws.com/', child_template.resource_path]) 
开发者ID:DualSpark,项目名称:cloudformation-environmentbase,代码行数:12,代码来源:template.py

示例10: test_tropo_to_string

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

示例11: __init__

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Parameter [as 别名]
def __init__(self, name, value):
        """Instantiate class.

        Args:
            name (str): The name of the CloudFormation Parameter.
            value (Any): The value we're going to submit as a CloudFormation
                Parameter.

        """
        acceptable_types = [string_types, bool, list, int]
        acceptable = False
        for acceptable_type in acceptable_types:
            if isinstance(value, acceptable_type):
                acceptable = True
                if acceptable_type == bool:
                    LOGGER.debug("Converting parameter %s boolean '%s' "
                                 "to string.", name, value)
                    value = str(value).lower()
                    break

                if acceptable_type == int:
                    LOGGER.debug("Converting parameter %s integer '%s' "
                                 "to string.", name, value)
                    value = str(value)
                    break

        if not acceptable:
            raise ValueError(
                "CFNParameter (%s) value must be one of %s got: %s" % (
                    name, "str, int, bool, or list", value))

        self.name = name
        self.value = value 
开发者ID:onicagroup,项目名称:runway,代码行数:35,代码来源:base.py

示例12: add_parameters

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Parameter [as 别名]
def add_parameters(self, db_label, db_config):
        instance_type_param = self.add_parameter(Parameter(
            db_label.lower() + self.tier_name.title() + 'RdsInstanceType',
            Default=db_config.get('db_instance_type_default'),
            Type='String',
            Description='DB Instance Type for the RDS instance.',
            AllowedValues=res.COMMON_STRINGS.get('valid_db_instance_types'),
            ConstraintDescription=res.COMMON_STRINGS.get('valid_db_instance_type_message')))

        name_param = self.add_parameter(Parameter(
            db_label.lower() + self.tier_name.title() + 'RdsDbName',
            Type='String',
            Default=db_config.get('master_db_name'),
            Description='Master RDS database name for the RDS instance.',
            MinLength=3,
            MaxLength=32,
            ConstraintDescription='must be 3 or more characters and not longer than 64 characters.'))

        user_name_param = self.add_parameter(Parameter(
            db_label.lower() + self.tier_name.title() + 'RdsUserName',
            Default=db_config.get('rds_user_name'),
            Type='String',
            Description='Master RDS User name for the RDS instance',
            MinLength=3,
            MaxLength=64,
            ConstraintDescription='must be 3 or more characters and not longer than 64 characters.'))

        user_password_param = self.add_parameter(Parameter(
            db_label.lower() + self.tier_name.title() + 'RdsMasterUserPassword',
            NoEcho=True,
            Type='String',
            Description='Master RDS User Password for the RDS instance.',
            MinLength=12,
            MaxLength=64,
            ConstraintDescription='must be 12 or more characters and not longer than 64 characters.'))

        return instance_type_param, name_param, user_name_param, user_password_param

    # Called after add_child_template() has attached common parameters and some instance attributes:
    # - RegionMap: Region to AMI map, allows template to be deployed in different regions without updating AMI ids
    # - ec2Key: keyname to use for ssh authentication
    # - vpcCidr: IP block claimed by whole VPC
    # - vpcId: resource id of VPC
    # - commonSecurityGroup: sg identifier for common allowed ports (22 in from VPC)
    # - utilityBucket: S3 bucket name used to send logs to
    # - [public|private]Subnet[0-9]: indexed and classified subnet identifiers
    #
    # and some instance attributes referencing the attached parameters:
    # - self.vpc_cidr
    # - self.vpc_id
    # - self.common_security_group
    # - self.utility_bucket
    # - self.subnets: keyed by type and index (e.g. self.subnets['public'][1]) 
开发者ID:DualSpark,项目名称:cloudformation-environmentbase,代码行数:55,代码来源:rds.py

示例13: initialize_template

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Parameter [as 别名]
def initialize_template(self):
        """
        Create new Template instance, set description and common parameters and load AMI cache.
        """
        print '\nGenerating templates for {} stack\n'.format(self.globals['environment_name'])

        # Configure Template class with S3 settings from config
        Template.template_bucket_default = self.template_args.get('s3_bucket')
        Template.s3_path_prefix = self.s3_prefix()
        Template.stack_timeout = self.template_args.get("timeout_in_minutes")
        Template.upload_acl = self.template_args.get('s3_upload_acl')
        Template.include_timestamp = self.template_args.get('include_timestamp')

        Template.include_templateValidationHash_output = self.template_args.get('include_templateValidationHash_output')
        Template.include_dateGenerated_output = self.template_args.get('include_dateGenerated_output')

        # Create the root template object
        self.template = Template(self.globals.get('environment_name', 'default_template'))
        self.template.description = self.template_args.get('description', 'No Description Specified')
        self.template.resource_path = self._root_template_path()

        ec2_key = self.config.get('template').get('ec2_key_default', 'default-key')
        self.template._ec2_key = self.template.add_parameter(Parameter(
           'ec2Key',
            Type='String',
            Default=ec2_key,
            Description='Name of an existing EC2 KeyPair to enable SSH access to the instances',
            AllowedPattern=res.get_str('ec2_key'),
            MinLength=1,
            MaxLength=255,
            ConstraintDescription=res.get_str('ec2_key_message')
        ))

        bucket_name = self.config.get('logging').get('s3_bucket')

        self.template.add_utility_bucket(name=bucket_name)

        self.template.add_log_group()
        self.template.add_vpcflowlogs_role()

        ami_filename = self.config['template'].get('ami_map_file')
        if ami_filename:
            ami_cache = res.load_yaml_file(ami_filename)
            self.template.add_ami_mapping(ami_cache) 
开发者ID:DualSpark,项目名称:cloudformation-environmentbase,代码行数:46,代码来源:environmentbase.py


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