How to use the troposphere.Output function in troposphere

To help you get started, we’ve selected a few troposphere examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cloudtools / troposphere / tests / test_template.py View on Github external
def test_eq(self):
        metadata = 'foo'
        description = 'bar'
        resource = Bucket('Baz')
        output = Output('qux', Value='qux')

        t1 = Template(Description=description, Metadata=metadata)
        t1.add_resource(resource)
        t1.add_output(output)

        t2 = Template(Description=description, Metadata=metadata)
        t2.add_resource(resource)
        t2.add_output(output)

        self.assertEqual(t1, t2)
github cloudtools / troposphere / examples / IAM_Users_Groups_and_Policies.py View on Github external
"cloudformation:Describe*",
                "cloudformation:List*",
                "cloudformation:Get*"
            ],
            "Resource": "*"
        }],
    }
))

t.add_output(Output(
    "AccessKey",
    Value=Ref(cfnkeys),
    Description="AWSAccessKeyId of new user",
))

t.add_output(Output(
    "SecretKey",
    Value=GetAtt(cfnkeys, "SecretAccessKey"),
    Description="AWSSecretKey of new user",
))

print(t.to_json())
github waterbear-cloud / paco / src / paco / cftemplates / lambda_function.py View on Github external
if self.awslambda.expire_events_after_days != 'Never' and self.awslambda.expire_events_after_days != '':
            cfn_export_dict['RetentionInDays'] = int(self.awslambda.expire_events_after_days)
        loggroup_logical_id = self.create_cfn_logical_id('LogGroup' + logical_name)
        loggroup_resource = troposphere.logs.LogGroup.from_dict(
            loggroup_logical_id,
            cfn_export_dict
        )
        loggroup_resource.DependsOn = self.awslambda_resource
        self.template.add_resource(loggroup_resource)

        # LogGroup Output
        self.register_stack_output_config(
            '{}.log_groups.{}.arn'.format(self.awslambda.paco_ref_parts, logical_name), loggroup_logical_id + 'Arn'
        )
        loggroup_output = troposphere.Output(
            loggroup_logical_id + 'Arn',
            Value=troposphere.GetAtt(loggroup_resource, "Arn")
        )
        self.template.add_output(loggroup_output)
        return loggroup_resource
github DualSpark / cloudformation-environmentbase / src / environmentbase / patterns / ha_cluster.py View on Github external
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'])))
github waterbear-cloud / paco / src / paco / cftemplates / nat_gateway.py View on Github external
ec2_resource[az_idx] = troposphere.ec2.Instance(
                    title = self.create_cfn_logical_id_join(
                        str_list = ['EC2NATInstance', str(az_idx)],
                        camel_case=True),
                    template = self.template,
                    SubnetId = troposphere.Ref(subnet_id_param),
                    ImageId = self.paco_ctx.get_ref('paco.ref function.aws.ec2.ami.latest.amazon-linux-nat', self.account_ctx),
                    InstanceType = nat_config.ec2_instance_type,
                    KeyName = self.paco_ctx.get_ref(nat_config.ec2_key_pair+'.keypair_name'),
                    SecurityGroupIds = troposphere.Ref(security_group_list_param),
                    SourceDestCheck=False,
                    Tags=troposphere.ec2.Tags(Name=instance_name)
                )

                ec2_instance_id_output = troposphere.Output(
                    title=ec2_resource[az_idx].title+'Id',

                    Description="EC2 NAT Instance Id",
                    Value=troposphere.Ref(ec2_resource[az_idx])
                )
                self.template.add_output( ec2_instance_id_output )

                troposphere.ec2.EIP(
                    title=self.create_cfn_logical_id_join(
                        str_list = ['ElasticIP', str(az_idx)],
                        camel_case=True),
                    template=self.template,
                    Domain='vpc',
                    InstanceId=troposphere.Ref(ec2_resource[az_idx])
                )
github jorgebastida / gordon / gordon / resources / apigateway.py View on Github external
deployment_dependencies.append(m.name)
                deployment_resources.append(m)

        deploy_hash = hashlib.sha1(six.text_type(uuid.uuid4()).encode('utf-8')).hexdigest()
        deploy = Deployment(
            utils.valid_cloudformation_name(self.name, "Deployment", deploy_hash[:8]),
            DependsOn=sorted(deployment_dependencies),
            StageName=troposphere.Ref('Stage'),
            RestApiId=troposphere.Ref(api)
        )

        template.add_resource(deploy)

        if self._get_true_false('cli-output', 't'):
            template.add_output([
                troposphere.Output(
                    utils.valid_cloudformation_name("Clioutput", self.in_project_name),
                    Value=troposphere.Join(
                        "",
                        [
                            "https://",
                            troposphere.Ref(api),
                            ".execute-api.",
                            troposphere.Ref(troposphere.AWS_REGION),
                            ".amazonaws.com/",
                            troposphere.Ref('Stage')
                        ]
github onicagroup / runway / runway / blueprints / staticsite / cleanup.py View on Github external
ZipFile=read_value_from_path(
                        'file://' + os.path.join(
                            os.path.dirname(__file__),
                            'templates/replicated_lambda_remover.template.py'
                        )
                    )
                ),
                Description="Checks for Replicated Lambdas created during the main stack and "
                            "deletes them when they are ready.",
                Handler='index.handler',
                Role=res['role'].get_att('Arn'),
                Runtime='python3.7'
            )
        )

        self.template.add_output(Output(
            'ReplicatedLambdaRemoverArn',
            Description='The ARN of the Replicated Function',
            Value=res['function'].get_att('Arn')
        ))

        return res
github aws / aws-parallelcluster / util / cfn-stacks-generators / generate-ebs-substack.py View on Github external
KmsKeyId=If(use_ebs_kms_key, Select(str(i), Ref(ebs_kms_id)), NoValue),
                Condition=create_vol,
            )
        )

    outputs = [None] * number_of_vol
    vol_to_return = [None] * number_of_vol
    for i in range(number_of_vol):
        vol_to_return[i] = If(use_existing_ebs_volume[i], Select(str(i), Ref(ebs_volume_id)), Ref(v[i]))
        if i == 0:
            outputs[i] = vol_to_return[i]
        else:
            outputs[i] = If(use_vol[i], Join(",", vol_to_return[: (i + 1)]), outputs[i - 1])

    t.add_output(
        Output("Volumeids", Description="Volume IDs of the resulted EBS volumes", Value=outputs[number_of_vol - 1])
    )

    json_file_path = args.target_path
    output_file = open(json_file_path, "w")
    output_file.write(t.to_json())
    output_file.close()
github cloudtools / troposphere / examples / EC2InstanceSample.py View on Github external
ec2_instance = template.add_resource(ec2.Instance(
    "Ec2Instance",
    ImageId=FindInMap("RegionMap", Ref("AWS::Region"), "AMI"),
    InstanceType="t1.micro",
    KeyName=Ref(keyname_param),
    SecurityGroups=["default"],
    UserData=Base64("80")
))

template.add_output([
    Output(
        "InstanceId",
        Description="InstanceId of the newly created EC2 instance",
        Value=Ref(ec2_instance),
    ),
    Output(
        "AZ",
        Description="Availability Zone of the newly created EC2 instance",
        Value=GetAtt(ec2_instance, "AvailabilityZone"),
    ),
    Output(
        "PublicIP",
        Description="Public IP address of the newly created EC2 instance",
        Value=GetAtt(ec2_instance, "PublicIp"),
    ),
    Output(
        "PrivateIP",
        Description="Private IP address of the newly created EC2 instance",
        Value=GetAtt(ec2_instance, "PrivateIp"),
    ),
    Output(
        "PublicDNS",
github awslabs / aws-cfn-control / troposhpere / NFS_Server.py View on Github external
t.add_condition(
        "Has_Static_Private_IP",
        Not(Equals(Ref(StaticPrivateIpAddress), "NO_VALUE"))
    )

    nfswaithandle = t.add_resource(WaitConditionHandle('NFSInstanceWaitHandle'))

    nfswaitcondition = t.add_resource(WaitCondition(
        "NFSInstanceWaitCondition",
        Handle=Ref(nfswaithandle),
        Timeout="1500",
        DependsOn="NFSInstance"
    ))

    t.add_output([
        Output(
            "ElasticIP",
            Description="Elastic IP address for the instance",
            Value=Ref(EIPAddress),
            Condition="create_elastic_ip"
        ),
        Output(
            "InstanceID",
            Description="Instance ID",
            Value=Ref(NFSInstance)
        ),
        Output(
            "InstancePrivateIP",
            Value=GetAtt('NFSInstance', 'PrivateIp')
        ),
        Output(
            "InstancePublicIP",