Open nathanielks opened 1 month ago
Reproducible. This seems a bug to me.
Let me simplify it with this PoC
VpcStack
export interface VpcStackProps extends cdk.StackProps {
readonly cidr?: string;
}
export class VpcStack extends Stack {
public readonly vpcId: string;
public readonly vpcCidrIpV4: string;
public readonly vpcCidrIpV6: string;
public readonly vpcCidrIpV6List: string[];
constructor(scope: Construct, id: string, props: VpcStackProps) {
super(scope, id, props);
const vpc = new ec2.Vpc(this, 'Bug VPC', {
ipAddresses: ec2.IpAddresses.cidr('10.16.0.0/16'),
ipProtocol: ec2.IpProtocol.DUAL_STACK,
createInternetGateway: false,
maxAzs: 3,
subnetConfiguration: [
{
cidrMask: 28,
name: 'private',
subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
}
]
})
this.vpcId = vpc.vpcId
this.vpcCidrIpV4 = vpc.vpcCidrBlock
this.vpcCidrIpV6 = cdk.Fn.select(0, vpc.vpcIpv6CidrBlocks);
new CfnOutput(this, 'vpcCidrIpV6', { value: this.vpcCidrIpV6 })
}
}
It's fine when just deploy the vpc stack
new VpcStack(app, 'vpc-stack', { env });
Outputs:
vpc-stack.vpcCidrIpV6 = 2600:1f18:601f:ec00::/56
Now if we define a consumer stack
export interface ConsumerStackProps extends StackProps {
readonly vpcCidrIpV6: string;
}
export class ConsumerStack extends Stack {
constructor(scope: Construct, id: string, props: ConsumerStackProps) {
super(scope, id, props);
new CfnOutput(this, 'MyListOutput', { value: props.vpcCidrIpV6 })
}
}
And enable crossRegionReferences
:
const stack = new VpcStack(app, 'vpc-stack', { env, crossRegionReferences: true });
new ConsumerStack(app, 'consumer-stack', { env: {
account: process.env.CDK_DEFAULT_ACCOUNT,
region: 'us-west-2',
} , vpcCidrIpV6: stack.vpcCidrIpV6, crossRegionReferences: true })
The writer CR would fail with SerializationException
:
11:03:42 PM | CREATE_FAILED | Custom::CrossRegionExportWriter | ExportsWriteruswes...0/Resource /Default Received response status [FAILED] from custom resource. Message returned: SerializationException: Start of l ist found where not expected at throwDefaultError (/var/runtime/node_modules/@aws-sdk/node_modules/@smithy/smithy-client/dist-cjs/index.j s:840:20) at /var/runtime/node_modules/@aws-sdk/node_modules/@smithy/smithy-client/dist-cjs/index.js:849:5 at de_CommandError (/var/runtime/node_modules/@aws-sdk/client-ssm/dist-cjs/index.js:7021:14) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async /var/runtime/node_modules/@aws-sdk/node_modules/@smithy/middleware-serde/dist-cjs/index.js:35:20 at async /var/runtime/node_modules/@aws-sdk/node_modules/@smithy/core/dist-cjs/index.js:165:18 at async /var/runtime/node_modules/@aws-sdk/node_modules/@smithy/middleware-retry/dist-cjs/index.js:320:38
Making this a p1.
Describe the bug
When creating stacks with
crossRegionReferences
enabled, and the stack exposes a list/array value that is to be read in another region, theCustom::CrossRegionExportWriter
resource will fail during creation with the error "SerializationException: Start of list found where not expected". Reading string values works fine, but if it's an array/list, it will fail.Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
I expect to be able to reference lists/arrays from a stack in another region like I would strings.
Current Behavior
The
Custom::CrossRegionExportWriter
resource fails during creation with the error "SerializationException: Start of list found where not expected":Reproduction Steps
By default, the app will be created in a way that does not trigger the bug. To deploy the app as-is:
This should create the stacks successfully. Then run another deployment with a context variable:
This will instruct the app to reference list values in a cross-region manager and trigger the bug.
The bug occurs whether you create the stack with or without the context variable set; that is to say, if you create the stack with the context variable, the bug will also be triggered in that circumstance.
app.ts:
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.158.0
Framework Version
No response
Node.js Version
20.15.0
OS
macOS 14.6.1
Language
TypeScript
Language Version
5.5.4
Other information
No response