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


Python troposphere.Ref方法代码示例

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


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

示例1: parse_imports

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Ref [as 别名]
def parse_imports(c, context, element_list):
    return_list = []
    for element in element_list:
        # See if we match an import
        if re.match("^import:", element):
            m = re.match("^import:(.*)", element)
            return_list.append(ImportValue(m.group(1)))
        # See if we match a group in the template.  If so we need to Ref()
        # the group name for named: false to work.
        elif c.is_local_group(element) and context == "user":
            return_list.append(Ref(scrub_name("{}Group".format(element))))
        # Otherwise we're verbatim as there's no real way to know if this
        # is within the template or existing.
        else:
            return_list.append(element)

    return(return_list) 
开发者ID:awslabs,项目名称:aws-iam-generator,代码行数:19,代码来源:iam_template_build.py

示例2: _codebuild_builder

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Ref [as 别名]
def _codebuild_builder(role: iam.Role, application_bucket: s3.Bucket) -> codebuild.Project:
    """Build and return the CodeBuild Project resource to be used to build the decrypt oracle."""
    artifacts = codebuild.Artifacts(Type="CODEPIPELINE")
    environment = codebuild.Environment(
        ComputeType="BUILD_GENERAL1_SMALL",
        Image=CODEBUILD_IMAGE,
        Type="LINUX_CONTAINER",
        EnvironmentVariables=[codebuild.EnvironmentVariable(Name="APP_S3_BUCKET", Value=Ref(application_bucket))],
    )
    source = codebuild.Source(Type="CODEPIPELINE", BuildSpec=BUILDSPEC)
    return codebuild.Project(
        "{}Build".format(APPLICATION_NAME),
        Artifacts=artifacts,
        Environment=environment,
        Name=APPLICATION_NAME,
        ServiceRole=Ref(role),
        Source=source,
    ) 
开发者ID:aws,项目名称:aws-encryption-sdk-python,代码行数:20,代码来源:pipeline.py

示例3: _prepare_subnets

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Ref [as 别名]
def _prepare_subnets(self, subnet_configs):
        for index, subnet_config in enumerate(subnet_configs):
            subnet_type = subnet_config.get('type', 'private')
            subnet_layer = subnet_config.get('name', 'subnet')
            subnet_az = subnet_config.get('AZ', '-1')

            subnet_name = subnet_layer + 'AZ' + str(subnet_az)

            # Save the subnet references to the template object
            if subnet_type not in self._subnets:
                self._subnets[subnet_type] = {}

            if subnet_layer not in self._subnets[subnet_type]:
                self._subnets[subnet_type][subnet_layer] = []

            self._subnets[subnet_type][subnet_layer].append(Ref(subnet_name)) 
开发者ID:DualSpark,项目名称:cloudformation-environmentbase,代码行数:18,代码来源:base_network.py

示例4: add_cname

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

示例5: add_nat_sg_rules

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Ref [as 别名]
def add_nat_sg_rules(self):
        '''
        Add the security group rules necessary for the NAT to operate
        For now, this is opening all ingress from the VPC and all egress to the internet
        '''
        self.add_resource(SecurityGroupIngress(
            "Nat%sIngress" % str(self.subnet_index),
            ToPort="-1",
            FromPort="-1",
            IpProtocol="-1",
            GroupId=Ref(self.sg),
            CidrIp=self.vpc_cidr
        ))
        self.add_resource(SecurityGroupEgress(
            "Nat%sEgress" % str(self.subnet_index),
            ToPort="-1",
            FromPort="-1",
            IpProtocol="-1",
            GroupId=Ref(self.sg),
            CidrIp='0.0.0.0/0'
        )) 
开发者ID:DualSpark,项目名称:cloudformation-environmentbase,代码行数:23,代码来源:ha_nat.py

示例6: add_instance_profile

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Ref [as 别名]
def add_instance_profile(self, layer_name, iam_policies, path_prefix):
        """
        Helper function to add role and instance profile resources to this template
        using the provided iam_policies. The instance_profile will be created at:
        '/<path_prefix>/<layer_name>/'
        """
        iam_role_obj = iam.Role(layer_name + 'IAMRole',
                AssumeRolePolicyDocument={
                    'Statement': [{
                        'Effect': 'Allow',
                        'Principal': {'Service': ['ec2.amazonaws.com']},
                        'Action': ['sts:AssumeRole']
                    }]},
                    Path=Join('', ['/' + path_prefix + '/', layer_name , '/']))

        if iam_policies != None:
            iam_role_obj.Policies = iam_policies

        iam_role = self.add_resource(iam_role_obj)

        return self.add_resource(iam.InstanceProfile(layer_name + 'InstancePolicy',
                Path='/' + path_prefix + '/',
                Roles=[Ref(iam_role)])) 
开发者ID:DualSpark,项目名称:cloudformation-environmentbase,代码行数:25,代码来源:template.py

示例7: add_scaling_policy

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Ref [as 别名]
def add_scaling_policy(self,
        metric_name,
        asg_name,
        adjustment_type="ChangeInCapacity",
        cooldown=1,
        scaling_adjustment=1):
        """
        Helper method to encapsulate process of adding a scaling policy to an autoscaling group in this template
        """
        policy = autoscaling.ScalingPolicy(
            metric_name + 'ScalingPolicy',
            AdjustmentType=adjustment_type,
            AutoScalingGroupName=Ref(asg_name),
            Cooldown=cooldown,
            ScalingAdjustment=str(scaling_adjustment))

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

示例8: test_resolve_variables_cfn_type_list

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Ref [as 别名]
def test_resolve_variables_cfn_type_list(self):
        """Test resolve variables cfn type list."""
        class TestBlueprint(Blueprint):
            """Test blueprint."""

            VARIABLES = {
                "Param1": {"type": EC2AvailabilityZoneNameList},
            }

        blueprint = TestBlueprint(name="test", context=MagicMock())
        variables = [Variable("Param1", ["us-east-1", "us-west-2"], 'cfngin')]
        blueprint.resolve_variables(variables)
        variables = blueprint.get_variables()
        self.assertTrue(isinstance(variables["Param1"], CFNParameter))
        self.assertEqual(variables["Param1"].value, ["us-east-1", "us-west-2"])
        self.assertEqual(variables["Param1"].ref.data, Ref("Param1").data)
        parameters = blueprint.get_parameter_values()
        self.assertEqual(parameters["Param1"], ["us-east-1", "us-west-2"]) 
开发者ID:onicagroup,项目名称:runway,代码行数:20,代码来源:test_base.py

示例9: create_iam_profile

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Ref [as 别名]
def create_iam_profile(self):
        t = self.template
        ec2_role_policy = get_default_assumerole_policy()
        t.add_resource(
            Role(
                "EmpireMinionRole",
                AssumeRolePolicyDocument=ec2_role_policy,
                Path="/",
                Policies=self.generate_iam_policies()))
        t.add_resource(
            InstanceProfile(
                "EmpireMinionProfile",
                Path="/",
                Roles=[Ref("EmpireMinionRole")]))
        t.add_output(
            Output("IAMRole", Value=Ref("EmpireMinionRole"))) 
开发者ID:remind101,项目名称:stacker_blueprints,代码行数:18,代码来源:minion.py

示例10: create_log_stream

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Ref [as 别名]
def create_log_stream(self):
        t = self.template
        super(DeliveryStream, self).create_log_stream()

        self.redshift_log_stream = t.add_resource(
            logs.LogStream(
                REDSHIFT_LOG_STREAM,
                LogGroupName=Ref(self.log_group),
                DependsOn=self.log_group.title
            )
        )

        t.add_output(
            Output(
                "RedshiftLogStreamName",
                Value=Ref(self.redshift_log_stream)
            )
        ) 
开发者ID:remind101,项目名称:stacker_blueprints,代码行数:20,代码来源:redshift.py

示例11: create_autoscaling_group

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

示例12: prepare_efs_security_groups

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

示例13: create_efs_mount_targets

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

示例14: cache_param

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

示例15: build_sts_statement

# 需要导入模块: import troposphere [as 别名]
# 或者: from troposphere import Ref [as 别名]
def build_sts_statement(account, role):
    statement = {
        "Effect": "Allow",
        "Action": "sts:AssumeRole",
        "Resource": "arn:aws:iam::" + account + ":role/" + role,
    }
    return(statement)


# Managed policies are unique in that they must be an ARN.
# So either we have an ARN, or a Ref() within our current environment
# or an import: statement from another cloudformation template. 
开发者ID:awslabs,项目名称:aws-iam-generator,代码行数:14,代码来源:iam_template_build.py


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