Skip to content

Commit a5d00a6

Browse files
committed
fix(agent): also pin the 2 AgentCore Delivery links (aws-samples#247 #58 deploy-block, round 2)
Round-1 pinning fixed the DeliverySource/DeliveryDestination collision — all 4 updated in place — but the rollback just moved one resource downstream to AWS::Logs::Delivery ('identifier null already exists'). A Delivery has no Name, but it IS unique per (source, destination) pair; with the source+dest now pinned, the churned Delivery logical id tried to create-before-delete a SECOND link over the same pair → AlreadyExists. Pin the 2 Delivery links' logical IDs too (logical-id only — no Name). pinLogResource's liveName is now optional. cdk diff: all 6 log resources [~] in place (Delivery no longer [-]/[+]); the inner [-]/[+] is just DependsOn reordering. agent.test.ts (44) green.
1 parent 37a9ad3 commit a5d00a6

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

cdk/src/stacks/agent.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,15 +408,20 @@ export class AgentStack extends Stack {
408408
// not new ones. Log delivery is stateless routing config — no data risk.
409409
// Best-effort lookup by child id; if a future alpha renames the children
410410
// this silently no-ops (and a fresh stack just deploys clean).
411-
// Pin BOTH the DeliverySources and the DeliveryDestinations (the two
412-
// account-name-unique resource kinds) to their deployed logical IDs +
413-
// Names, so the whole sub-tree updates in place. (The CfnDelivery links
414-
// are not name-unique and Ref the pinned ids, so they follow for free.)
415-
const pinLogResource = (childId: string, liveLogicalId: string, liveName: string): void => {
411+
// Pin ALL THREE auto-created resource kinds to their deployed logical IDs:
412+
// - DeliverySource + DeliveryDestination: also pin ``Name`` (both are
413+
// account-unique, so a churned logical id collides on create).
414+
// - Delivery: logical-id pin ONLY. A Delivery has no Name, but it IS
415+
// unique per (source, destination) pair — and since the source+dest
416+
// are now pinned, a churned Delivery logical id would create-before-
417+
// delete a SECOND link over the same pair and hit ``AlreadyExists``
418+
// ('identifier null already exists'). Pinning the logical id makes CFN
419+
// update it in place. (Pass liveName undefined for these.)
420+
const pinLogResource = (childId: string, liveLogicalId: string, liveName?: string): void => {
416421
const res = runtime.node.tryFindChild(childId) as CfnResource | undefined;
417422
if (!res) return;
418423
res.overrideLogicalId(liveLogicalId);
419-
res.addPropertyOverride('Name', liveName);
424+
if (liveName !== undefined) res.addPropertyOverride('Name', liveName);
420425
};
421426
pinLogResource(
422427
'ApplicationLogsDeliverySource',
@@ -438,6 +443,16 @@ export class AgentStack extends Stack {
438443
'RuntimeCdkLogGroupUsageLogsDeliverybackgroundagentdevRuntimeBC0AE9EDbackgroundagentdevRuntimeUsageLogGroup7FA1FA67Destusagelogs9AB608D0',
439444
'cdk-cwl-Destusage-logs-dest-backgroundagroup7FA1FA67A8A16CEE',
440445
);
446+
// The two Delivery links: logical-id pin only (no Name — unique per
447+
// source/destination pair, which are now pinned).
448+
pinLogResource(
449+
'ApplicationLogsDelivery',
450+
'RuntimeCdkLogGroupApplicationLogsDeliverybackgroundagentdevRuntimeBC0AE9EDbackgroundagentdevRuntimeApplicationLogGroup454A95E8Delivery92FE492C',
451+
);
452+
pinLogResource(
453+
'UsageLogsDelivery',
454+
'RuntimeCdkLogGroupUsageLogsDeliverybackgroundagentdevRuntimeBC0AE9EDbackgroundagentdevRuntimeUsageLogGroup7FA1FA67Delivery40F023D7',
455+
);
441456

442457
// --- Session storage (preview) ---
443458
// The L2 construct does not yet expose filesystemConfigurations; use the

0 commit comments

Comments
 (0)