本文整理匯總了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
示例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)))))
示例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))
示例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'])))
示例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()
示例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'])
))
示例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()
示例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
示例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
示例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?
示例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
示例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"))
示例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
示例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()}
示例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))