class CfnOutput (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.CfnOutput |
Go | github.com/aws/aws-cdk-go/awscdk/v2#CfnOutput |
Java | software.amazon.awscdk.CfnOutput |
Python | aws_cdk.CfnOutput |
TypeScript (source) | aws-cdk-lib » CfnOutput |
Implements
IConstruct
, IDependable
Example
declare const cluster: eks.Cluster;
// add service account
const serviceAccount = cluster.addServiceAccount('MyServiceAccount');
const bucket = new s3.Bucket(this, 'Bucket');
bucket.grantReadWrite(serviceAccount);
const mypod = cluster.addManifest('mypod', {
apiVersion: 'v1',
kind: 'Pod',
metadata: { name: 'mypod' },
spec: {
serviceAccountName: serviceAccount.serviceAccountName,
containers: [
{
name: 'hello',
image: 'paulbouwer/hello-kubernetes:1.5',
ports: [ { containerPort: 8080 } ],
},
],
},
});
// create the resource after the service account.
mypod.node.addDependency(serviceAccount);
// print the IAM role arn for this service account
new CfnOutput(this, 'ServiceAccountIamRole', { value: serviceAccount.role.roleArn });
Initializer
new CfnOutput(scope: Construct, id: string, props: CfnOutputProps)
Parameters
- scope
Construct
— The parent construct. - id
string
- props
Cfn
— CfnOutput properties.Output Props
Creates an CfnOutput value for this stack.
Construct Props
Name | Type | Description |
---|---|---|
value | string | The value of the property returned by the aws cloudformation describe-stacks command. |
condition? | Cfn | A condition to associate with this output value. |
description? | string | A String type that describes the output value. |
export | string | The name used to export the value of this output across stacks. |
key? | string | The key of the property returned by aws cloudformation describe-stacks command. |
value
Type:
string
The value of the property returned by the aws cloudformation describe-stacks command.
The value of an output can include literals, parameter references, pseudo-parameters, a mapping value, or intrinsic functions.
condition?
Type:
Cfn
(optional, default: No condition is associated with the output.)
A condition to associate with this output value.
If the condition evaluates
to false
, this output value will not be included in the stack.
description?
Type:
string
(optional, default: No description.)
A String type that describes the output value.
The description can be a maximum of 4 K in length.
exportName?
Type:
string
(optional, default: the output is not exported)
The name used to export the value of this output across stacks.
To import the value from another stack, use Fn.importValue(exportName)
.
key?
Type:
string
(optional)
The key of the property returned by aws cloudformation describe-stacks command.
Properties
Name | Type | Description |
---|---|---|
creation | string[] | |
import | string | Return the Fn.importValue expression to import this value into another stack. |
logical | string | The logical ID for this CloudFormation stack element. |
node | Node | The tree node. |
stack | Stack | The stack in which this element is defined. |
value | any | The value of the property returned by the aws cloudformation describe-stacks command. |
condition? | Cfn | A condition to associate with this output value. |
description? | string | A String type that describes the output value. |
export | string | The name used to export the value of this output across stacks. |
creationStack
Type:
string[]
importValue
Type:
string
Return the Fn.importValue
expression to import this value into another stack.
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.
logicalId
Type:
string
The logical ID for this CloudFormation stack element.
The logical ID of the element is calculated from the path of the resource node in the construct tree.
To override this value, use overrideLogicalId(newLogicalId)
.
node
Type:
Node
The tree node.
stack
Type:
Stack
The stack in which this element is defined.
CfnElements must be defined within a stack scope (directly or indirectly).
value
Type:
any
The value of the property returned by the aws cloudformation describe-stacks command.
The value of an output can include literals, parameter references, pseudo-parameters, a mapping value, or intrinsic functions.
condition?
Type:
Cfn
(optional, default: No condition is associated with the output.)
A condition to associate with this output value.
If the condition evaluates
to false
, this output value will not be included in the stack.
description?
Type:
string
(optional, default: No description.)
A String type that describes the output value.
The description can be a maximum of 4 K in length.
exportName?
Type:
string
(optional, default: the output is not exported)
The name used to export the value of this output across stacks.
To use the value in another stack, pass the value of
output.importValue
to it.
Methods
Name | Description |
---|---|
override | Overrides the auto-generated logical ID with a specific ID. |
to | Returns a string representation of this construct. |
LogicalId(newLogicalId)
overridepublic overrideLogicalId(newLogicalId: string): void
Parameters
- newLogicalId
string
— The new logical ID to use for this stack element.
Overrides the auto-generated logical ID with a specific ID.
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.