What is the problem?
When attempting to use Stack.exportValue to fix an inter-stack dependency, I found that it fails on the endpoint port of an RDS serverless cluster:
self.export_value(serverless_cluster.cluster_endpoint.port)
It works well on the other attributes I needed, only this one fails to synthesise.
Reproduction Steps
#!/usr/bin/env python3
from aws_cdk import (
core as cdk,
aws_rds as rds,
aws_ec2 as ec2,
)
class Stack1(cdk.Stack):
def __init__(self, scope: cdk.Construct, construct_id: str):
super().__init__(scope, construct_id)
old_cluster = rds.ServerlessCluster(
self,
"AuroraCluster",
engine=rds.DatabaseClusterEngine.aurora_postgres(
version=rds.AuroraPostgresEngineVersion.VER_13_4
),
vpc=ec2.Vpc(self, "VPC"),
)
self.export_value(old_cluster.cluster_identifier)
self.export_value(old_cluster.secret.secret_arn)
self.export_value(old_cluster.cluster_endpoint.port)
app = cdk.App()
Stack1(app, "stack1")
app.synth()
What did you expect to happen?
The application should synthesise, and the cloudassembly should include exports for the cluster identifier, the secret ARN, and the cluster endpoint port.
What actually happened?
The application fails to synthesise with this error:
Error: exportValue: either supply 'name' or make sure to export a resource attribute (like 'bucket.bucketName')
occurring on the line that exports the endpoint port.
CDK CLI Version
1.142.0 (build 5dd8e50)
Framework Version
No response
Node.js Version
v14.17.5
OS
OS X (Monterey)
Language
Python
Language Version
Python 3.8.12
Other information
From some experiments in the debugger, I've identified the source of the problem:
const resolvable = Tokenization.reverse(exportedValue);
if (!resolvable || !Reference.isReference(resolvable)) {
throw new Error('exportValue: either supply \'name\' or make sure to export a resource attribute (like \'bucket.bucketName\')');
}
The isReference() response is false, because the port is not a Reference, it's an Intrinsic. Skipping this check and carrying on with the rest of the logic worked just fine, so I'm not sure if the check simply needs to be changed to also accept Intrinsics or whether there is something special about this port attribute compared to other Intrinsics.
What is the problem?
When attempting to use
Stack.exportValueto fix an inter-stack dependency, I found that it fails on the endpoint port of an RDS serverless cluster:It works well on the other attributes I needed, only this one fails to synthesise.
Reproduction Steps
What did you expect to happen?
The application should synthesise, and the cloudassembly should include exports for the cluster identifier, the secret ARN, and the cluster endpoint port.
What actually happened?
The application fails to synthesise with this error:
occurring on the line that exports the endpoint port.
CDK CLI Version
1.142.0 (build 5dd8e50)
Framework Version
No response
Node.js Version
v14.17.5
OS
OS X (Monterey)
Language
Python
Language Version
Python 3.8.12
Other information
From some experiments in the debugger, I've identified the source of the problem:
The
isReference()response is false, because the port is not aReference, it's anIntrinsic. Skipping this check and carrying on with the rest of the logic worked just fine, so I'm not sure if the check simply needs to be changed to also acceptIntrinsics or whether there is something special about thisportattribute compared to otherIntrinsics.