當前位置: 首頁>>代碼示例>>Python>>正文


Python troposphere.GetAtt方法代碼示例

本文整理匯總了Python中troposphere.GetAtt方法的典型用法代碼示例。如果您正苦於以下問題:Python troposphere.GetAtt方法的具體用法?Python troposphere.GetAtt怎麽用?Python troposphere.GetAtt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在troposphere的用法示例。


在下文中一共展示了troposphere.GetAtt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: add_cname

# 需要導入模塊: import troposphere [as 別名]
# 或者: from troposphere import GetAtt [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: create_autoscaling_group

# 需要導入模塊: import troposphere [as 別名]
# 或者: from troposphere import GetAtt [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

示例3: add_role

# 需要導入模塊: import troposphere [as 別名]
# 或者: from troposphere import GetAtt [as 別名]
def add_role(c, RoleName, model, named=False):
    cfn_name = scrub_name(RoleName + "Role")
    kw_args = {
        "Path": "/",
        "AssumeRolePolicyDocument": build_role_trust(c, model['trusts']),
        "ManagedPolicyArns": [],
        "Policies": []
    }

    if named:
        kw_args["RoleName"] = RoleName

    if "managed_policies" in model:
        kw_args["ManagedPolicyArns"] = parse_managed_policies(
                                        c, model["managed_policies"], RoleName)

    if "max_role_duration" in model:
        kw_args['MaxSessionDuration'] = int(model["max_role_duration"])

    if "retain_on_delete" in model:
        if model["retain_on_delete"] is True:
            kw_args["DeletionPolicy"] = "Retain"

    c.template[c.current_account].add_resource(Role(
        cfn_name,
        **kw_args
    ))
    if c.config['global']['template_outputs'] == "enabled":
        c.template[c.current_account].add_output([
            Output(
                cfn_name + "Arn",
                Description="Role " + RoleName + " ARN",
                Value=GetAtt(cfn_name, "Arn"),
                Export=Export(Sub("${AWS::StackName}-" + cfn_name + "Arn"))
            )
        ]) 
開發者ID:awslabs,項目名稱:aws-iam-generator,代碼行數:38,代碼來源:iam_template_build.py

示例4: add_group

# 需要導入模塊: import troposphere [as 別名]
# 或者: from troposphere import GetAtt [as 別名]
def add_group(c, GroupName, model, named=False):
    cfn_name = scrub_name(GroupName + "Group")
    kw_args = {
        "Path": "/",
        "ManagedPolicyArns": [],
        "Policies": []
    }

    if named:
        kw_args["GroupName"] = GroupName

    if "managed_policies" in model:
        kw_args["ManagedPolicyArns"] = parse_managed_policies(
            c,
            model["managed_policies"], GroupName
        )

    if "retain_on_delete" in model:
        if model["retain_on_delete"] is True:
            kw_args["DeletionPolicy"] = "Retain"

    c.template[c.current_account].add_resource(Group(
        scrub_name(cfn_name),
        **kw_args
    ))
    if c.config['global']['template_outputs'] == "enabled":
        c.template[c.current_account].add_output([
            Output(
                cfn_name + "Arn",
                Description="Group " + GroupName + " ARN",
                Value=GetAtt(cfn_name, "Arn"),
                Export=Export(Sub("${AWS::StackName}-" + cfn_name + "Arn"))
            )
        ]) 
開發者ID:awslabs,項目名稱:aws-iam-generator,代碼行數:36,代碼來源:iam_template_build.py

示例5: add_outputs

# 需要導入模塊: import troposphere [as 別名]
# 或者: from troposphere import GetAtt [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

示例6: build_hook

# 需要導入模塊: import troposphere [as 別名]
# 或者: from troposphere import GetAtt [as 別名]
def build_hook(self):
        """
        Hook to add tier-specific assets within the build stage of initializing this class.
        """

        if not self.dist_config:
            self.dist_config = DistributionConfig(
                Origins=[Origin(
                    Id="Origin",
                    DomainName=self.domain_name,
                    OriginPath=self.origin_path,
                    S3OriginConfig=S3Origin(),
                )],
                DefaultCacheBehavior=DefaultCacheBehavior(
                    TargetOriginId="Origin",
                    ForwardedValues=ForwardedValues(
                        QueryString=False
                    ),
                    ViewerProtocolPolicy="allow-all"),
                Enabled=True
            )

        if self.utility_bucket:
            self.dist_config.Logging = Logging(
                Bucket=Join('.', [self.utility_bucket, 's3.amazonaws.com']),
                IncludeCookies=True,
                Prefix=Join('/', ['AWSLogs', Ref(AWS_ACCOUNT_ID), 'CloudFront'])
            )

        cf_distribution = self.add_resource(Distribution(
            self.resource_name,
            DistributionConfig=self.dist_config
        ))

        self.add_output([
            Output("DistributionId", Value=Ref(cf_distribution)),
            Output("DistributionName", Value=Join("", ["http://", GetAtt(cf_distribution, "DomainName")])),
        ]) 
開發者ID:DualSpark,項目名稱:cloudformation-environmentbase,代碼行數:40,代碼來源:cloudfront.py

示例7: build_hook

# 需要導入模塊: import troposphere [as 別名]
# 或者: from troposphere import GetAtt [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

示例8: add_child_outputs_to_parameter_binding

# 需要導入模塊: import troposphere [as 別名]
# 或者: from troposphere import GetAtt [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

示例9: match_stack_parameters

# 需要導入模塊: import troposphere [as 別名]
# 或者: from troposphere import GetAtt [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

示例10: create_hook

# 需要導入模塊: import troposphere [as 別名]
# 或者: from troposphere import GetAtt [as 別名]
def create_hook(self):
        super(NetworkBase, self).create_hook()

        network_config = self.config.get('network', {})
        nat_config = self.config.get('nat')

        base_network_template = BaseNetwork('BaseNetwork', network_config, nat_config)
        self.add_child_template(base_network_template)

        self.template._subnets = base_network_template._subnets.copy()
        self.template._vpc_id = GetAtt(base_network_template.name, 'Outputs.vpcId') 
開發者ID:DualSpark,項目名稱:cloudformation-environmentbase,代碼行數:13,代碼來源:networkbase.py

示例11: __init__

# 需要導入模塊: import troposphere [as 別名]
# 或者: from troposphere import GetAtt [as 別名]
def __init__(self, title, template=None, *args, **kwargs):
        super(Certificate, self).__init__(
            title, template, *args, ServiceToken=GetAtt(CERTIFICATE_LAMBDA, 'Arn'), **kwargs
        ) 
開發者ID:dflook,項目名稱:cloudformation-dns-certificate,代碼行數:6,代碼來源:certificatemanager.py

示例12: create_delivery_stream

# 需要導入模塊: import troposphere [as 別名]
# 或者: from troposphere import GetAtt [as 別名]
def create_delivery_stream(self):
        t = self.template
        variables = self.get_variables()

        s3_dest_config = firehose.S3Configuration(
            **self.s3_destination_config_dict()
        )

        redshift_config = firehose.RedshiftDestinationConfiguration(
            RoleARN=GetAtt(self.role, "Arn"),
            ClusterJDBCURL=variables['JDBCURL'],
            CopyCommand=firehose.CopyCommand(
                CopyOptions=variables["CopyOptions"],
                DataTableName=variables['TableName']
            ),
            Username=variables['Username'],
            Password=variables['Password'].ref,
            S3Configuration=s3_dest_config,
            CloudWatchLoggingOptions=self.cloudwatch_logging_options(
                self.log_group,
                self.redshift_log_stream
            )
        )

        self.delivery_stream = t.add_resource(
            firehose.DeliveryStream(
                DELIVERY_STREAM,
                RedshiftDestinationConfiguration=redshift_config
            )
        ) 
開發者ID:remind101,項目名稱:stacker_blueprints,代碼行數:32,代碼來源:redshift.py

示例13: test_create_template

# 需要導入模塊: import troposphere [as 別名]
# 或者: from troposphere import GetAtt [as 別名]
def test_create_template(self):
        blueprint = SubscriptionFilters(
            'test_cloudwatch_logs_subscription_filters',
            self.ctx
        )

        blueprint.resolve_variables(
            [
                Variable(
                    "SubscriptionFilters",
                    {
                        "Filter1": {
                            "DestinationArn": GetAtt("KinesisStream1", "Arn"),
                            "FilterPattern": "{$.userIdentity.type = Root}",
                            "LogGroupName": Ref("LogGroup1"),
                        },
                        "Filter2": {
                            "DestinationArn": GetAtt("KinesisStream2", "Arn"),
                            "FilterPattern": "{$.userIdentity.type = Root}",
                            "LogGroupName": Ref("LogGroup2"),
                        },
                    }
                )
            ]
        )
        blueprint.create_template()
        self.assertRenderedBlueprint(blueprint) 
開發者ID:remind101,項目名稱:stacker_blueprints,代碼行數:29,代碼來源:test_cloudwatch_logs.py

示例14: add_user

# 需要導入模塊: import troposphere [as 別名]
# 或者: from troposphere import GetAtt [as 別名]
def add_user(c, UserName, model, named=False):
    cfn_name = scrub_name(UserName + "User")
    kw_args = {
        "Path": "/",
        "Groups": [],
        "ManagedPolicyArns": [],
        "Policies": [],
    }

    if named:
        kw_args["UserName"] = UserName

    if "groups" in model:
        kw_args["Groups"] = parse_imports(c, "user", model["groups"])

    if "managed_policies" in model:
        kw_args["ManagedPolicyArns"] = parse_managed_policies(
                c,
                model["managed_policies"],
                UserName
            )

    if "password" in model:
        kw_args["LoginProfile"] = LoginProfile(
            Password=model["password"],
            PasswordResetRequired=True
        )

    if "retain_on_delete" in model:
        if model["retain_on_delete"] is True:
            kw_args["DeletionPolicy"] = "Retain"

    c.template[c.current_account].add_resource(User(
        cfn_name,
        **kw_args
    ))
    if c.config['global']['template_outputs'] == "enabled":
        c.template[c.current_account].add_output([
            Output(
                cfn_name + "Arn",
                Description="User " + UserName + " ARN",
                Value=GetAtt(cfn_name, "Arn"),
                Export=Export(Sub("${AWS::StackName}-" + cfn_name + "Arn"))
            )
        ]) 
開發者ID:awslabs,項目名稱:aws-iam-generator,代碼行數:47,代碼來源:iam_template_build.py

示例15: _pipeline_role

# 需要導入模塊: import troposphere [as 別名]
# 或者: from troposphere import GetAtt [as 別名]
def _pipeline_role(buckets: Iterable[s3.Bucket]) -> iam.Role:
    """Build and return the IAM Role resource to be used by CodePipeline to run the pipeline."""
    bucket_statements = [
        AWS.Statement(
            Effect=AWS.Allow,
            Action=[S3.GetBucketVersioning, S3.PutBucketVersioning],
            Resource=[GetAtt(bucket, "Arn") for bucket in buckets],
        ),
        AWS.Statement(
            Effect=AWS.Allow,
            Action=[S3.GetObject, S3.PutObject],
            Resource=[Sub("${{{bucket}.Arn}}/*".format(bucket=bucket.title)) for bucket in buckets],
        ),
    ]
    policy = iam.Policy(
        "PipelinePolicy",
        PolicyName="PipelinePolicy",
        PolicyDocument=AWS.PolicyDocument(
            Statement=bucket_statements
            + [
                AllowEverywhere(Action=[CLOUDWATCH.Action("*"), IAM.PassRole]),
                AllowEverywhere(Action=[LAMBDA.InvokeFunction, LAMBDA.ListFunctions]),
                AllowEverywhere(
                    Action=[
                        CLOUDFORMATION.CreateStack,
                        CLOUDFORMATION.DeleteStack,
                        CLOUDFORMATION.DescribeStacks,
                        CLOUDFORMATION.UpdateStack,
                        CLOUDFORMATION.CreateChangeSet,
                        CLOUDFORMATION.DeleteChangeSet,
                        CLOUDFORMATION.DescribeChangeSet,
                        CLOUDFORMATION.ExecuteChangeSet,
                        CLOUDFORMATION.SetStackPolicy,
                        CLOUDFORMATION.ValidateTemplate,
                    ]
                ),
                AllowEverywhere(Action=[CODEBUILD.BatchGetBuilds, CODEBUILD.StartBuild]),
            ]
        ),
    )
    return iam.Role(
        "CodePipelinesRole", AssumeRolePolicyDocument=_service_assume_role(CODEPIPELINE.prefix), Policies=[policy]
    ) 
開發者ID:aws,項目名稱:aws-encryption-sdk-python,代碼行數:45,代碼來源:pipeline.py


注:本文中的troposphere.GetAtt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。