CfnOutput
- class aws_cdk.CfnOutput(scope, id, *, value, condition=None, description=None, export_name=None, key=None)
Bases:
CfnElement
- ExampleMetadata:
infused
Example:
# cluster: eks.Cluster # add service account service_account = cluster.add_service_account("MyServiceAccount") bucket = s3.Bucket(self, "Bucket") bucket.grant_read_write(service_account) mypod = cluster.add_manifest("mypod", { "api_version": "v1", "kind": "Pod", "metadata": {"name": "mypod"}, "spec": { "service_account_name": service_account.service_account_name, "containers": [{ "name": "hello", "image": "paulbouwer/hello-kubernetes:1.5", "ports": [{"container_port": 8080}] } ] } }) # create the resource after the service account. mypod.node.add_dependency(service_account) # print the IAM role arn for this service account CfnOutput(self, "ServiceAccountIamRole", value=service_account.role.role_arn)
Creates an CfnOutput value for this stack.
- Parameters:
scope (
Construct
) – The parent construct.id (
str
) –value (
str
) – 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 (
Optional
[CfnCondition
]) – A condition to associate with this output value. If the condition evaluates tofalse
, this output value will not be included in the stack. Default: - No condition is associated with the output.description (
Optional
[str
]) – A String type that describes the output value. The description can be a maximum of 4 K in length. Default: - No description.export_name (
Optional
[str
]) – The name used to export the value of this output across stacks. To import the value from another stack, useFn.importValue(exportName)
. Default: - the output is not exportedkey (
Optional
[str
]) – The key of the property returned by aws cloudformation describe-stacks command.
Methods
- override_logical_id(new_logical_id)
Overrides the auto-generated logical ID with a specific ID.
- Parameters:
new_logical_id (
str
) – The new logical ID to use for this stack element.- Return type:
None
- to_string()
Returns a string representation of this construct.
- Return type:
str
Attributes
- condition
A condition to associate with this output value.
If the condition evaluates to
false
, this output value will not be included in the stack.- Default:
No condition is associated with the output.
- creation_stack
return:
the stack trace of the point where this Resource was created from, sourced from the +metadata+ entry typed +aws:cdk:logicalId+, and with the bottom-most node +internal+ entries filtered.
- description
A String type that describes the output value.
The description can be a maximum of 4 K in length.
- Default:
No description.
- export_name
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.- Default:
the output is not exported
- import_value
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.
- logical_id
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)
.- Returns:
the logical ID as a stringified token. This value will only get resolved during synthesis.
- node
The tree node.
- stack
The stack in which this element is defined.
CfnElements must be defined within a stack scope (directly or indirectly).
- value
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.
Static Methods
- classmethod is_cfn_element(x)
Returns
true
if a construct is a stack element (i.e. part of the synthesized cloudformation template).Uses duck-typing instead of
instanceof
to allow stack elements from different versions of this library to be included in the same stack.- Parameters:
x (
Any
) –- Return type:
bool
- Returns:
The construct as a stack element or undefined if it is not a stack element.
- classmethod is_construct(x)
Checks if
x
is a construct.Use this method instead of
instanceof
to properly detectConstruct
instances, even when the construct library is symlinked.Explanation: in JavaScript, multiple copies of the
constructs
library on disk are seen as independent, completely different libraries. As a consequence, the classConstruct
in each copy of theconstructs
library is seen as a different class, and an instance of one class will not test asinstanceof
the other class.npm install
will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of theconstructs
library can be accidentally installed, andinstanceof
will behave unpredictably. It is safest to avoid usinginstanceof
, and using this type-testing method instead.- Parameters:
x (
Any
) – Any object.- Return type:
bool
- Returns:
true if
x
is an object created from a class which extendsConstruct
.