Table of Contents

Class CfnOutput

Namespace
Amazon.CDK
Assembly
Amazon.CDK.dll
public class CfnOutput : CfnElement, IConstruct, IConstruct, IDependable
Inheritance
CfnOutput
Implements
IConstruct
Inherited Members

Examples

Cluster cluster;

            // add service account
            var serviceAccount = cluster.AddServiceAccount("MyServiceAccount");

            var bucket = new Bucket(this, "Bucket");
            bucket.GrantReadWrite(serviceAccount);

            var mypod = cluster.AddManifest("mypod", new Dictionary<string, object> {
                { "apiVersion", "v1" },
                { "kind", "Pod" },
                { "metadata", new Dictionary<string, string> { { "name", "mypod" } } },
                { "spec", new Dictionary<string, object> {
                    { "serviceAccountName", serviceAccount.ServiceAccountName },
                    { "containers", new [] { new Struct {
                        Name = "hello",
                        Image = "paulbouwer/hello-kubernetes:1.5",
                        Ports = new [] { new Struct { ContainerPort = 8080 } }
                    } } }
                } }
            });

            // create the resource after the service account.
            mypod.Node.AddDependency(serviceAccount);

            // print the IAM role arn for this service account
            // print the IAM role arn for this service account
            new CfnOutput(this, "ServiceAccountIamRole", new CfnOutputProps { Value = serviceAccount.Role.RoleArn });

Remarks

ExampleMetadata: infused

Constructors

CfnOutput(Construct, string, ICfnOutputProps)

Creates an CfnOutput value for this stack.

public CfnOutput(Construct scope, string id, ICfnOutputProps props)

Parameters

scope Construct

The parent construct.

id string
props ICfnOutputProps

CfnOutput properties.

Properties

Condition

A condition to associate with this output value.

public virtual CfnCondition? Condition { get; set; }

Property Value

CfnCondition

Remarks

If the condition evaluates to false, this output value will not be included in the stack.

Default: - No condition is associated with the output.

Description

A String type that describes the output value.

public virtual string? Description { get; set; }

Property Value

string

Remarks

The description can be a maximum of 4 K in length.

Default: - No description.

ExportName

The name used to export the value of this output across stacks.

public virtual string? ExportName { get; set; }

Property Value

string

Remarks

To use the value in another stack, pass the value of output.importValue to it.

Default: - the output is not exported

ImportValue

Return the Fn.importValue expression to import this value into another stack.

public virtual string ImportValue { get; }

Property Value

string

Remarks

The returned value should not be used in the same stack, but in a different one. It must be deployed to the same environment, as CloudFormation exports can only be imported in the same Region and account.

The is no automatic registration of dependencies between stacks when using this mechanism, so you should make sure to deploy them in the right order yourself.

You can use this mechanism to share values across Stacks in different Stages. If you intend to share the value to another Stack inside the same Stage, the automatic cross-stack referencing mechanism is more convenient.

Value

The value of the property returned by the aws cloudformation describe-stacks command.

public virtual object Value { get; set; }

Property Value

object

Remarks

The value of an output can include literals, parameter references, pseudo-parameters, a mapping value, or intrinsic functions.

Methods

Validate()

Validate the current construct.

protected override string[] Validate()

Returns

string[]

Remarks

This method can be implemented by derived constructs in order to perform validation logic. It is called on all constructs before synthesis.