本文整理汇总了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')]))
示例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)]))
示例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"))
)
])
示例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"))
)
])
示例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'])))
示例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")])),
])
示例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'])
))
示例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?
示例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
示例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')
示例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
)
示例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
)
)
示例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)
示例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"))
)
])
示例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]
)