diff --git a/packages/@aws-cdk-testing/framework-integ/test/custom-resources/test/provider-framework/integ.provider-with-waiter-state-machine.js.snapshot/integ-provider-with-waiter-state-machine.assets.json b/packages/@aws-cdk-testing/framework-integ/test/custom-resources/test/provider-framework/integ.provider-with-waiter-state-machine.js.snapshot/integ-provider-with-waiter-state-machine.assets.json index 4a22c0ee84968..b616fa67738ed 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/custom-resources/test/provider-framework/integ.provider-with-waiter-state-machine.js.snapshot/integ-provider-with-waiter-state-machine.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/custom-resources/test/provider-framework/integ.provider-with-waiter-state-machine.js.snapshot/integ-provider-with-waiter-state-machine.assets.json @@ -27,7 +27,7 @@ } } }, - "c4934037912635137a61ff14a2b2623fa08b180c4b757ad915d6fd9365ffb971": { + "f846c7dce86a836c27a5ff81d868b42f46e94502cd6f0859944c4d9e48751e33": { "source": { "path": "integ-provider-with-waiter-state-machine.template.json", "packaging": "file" @@ -35,7 +35,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "c4934037912635137a61ff14a2b2623fa08b180c4b757ad915d6fd9365ffb971.json", + "objectKey": "f846c7dce86a836c27a5ff81d868b42f46e94502cd6f0859944c4d9e48751e33.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/custom-resources/test/provider-framework/integ.provider-with-waiter-state-machine.js.snapshot/integ-provider-with-waiter-state-machine.template.json b/packages/@aws-cdk-testing/framework-integ/test/custom-resources/test/provider-framework/integ.provider-with-waiter-state-machine.js.snapshot/integ-provider-with-waiter-state-machine.template.json index ef09953f183a4..f8920f09d9ca3 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/custom-resources/test/provider-framework/integ.provider-with-waiter-state-machine.js.snapshot/integ-provider-with-waiter-state-machine.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/custom-resources/test/provider-framework/integ.provider-with-waiter-state-machine.js.snapshot/integ-provider-with-waiter-state-machine.template.json @@ -2077,7 +2077,18 @@ "MyProviderWithDefaultLogwaiterstatemachineLogGroup5907E67B": { "Type": "AWS::Logs::LogGroup", "Properties": { - "LogGroupName": "/aws/vendedlogs/states/waiter-state-machine-c8755c6a4f7af107037ba386c1af047796ca4678a8-Logs", + "LogGroupName": { + "Fn::Join": [ + "", + [ + "/aws/vendedlogs/states/waiter-state-machine-", + { + "Ref": "MyProviderWithDefaultLogframeworkisCompleteC86EC850" + }, + "-c8755c6a4f7af107037ba386c1af047796ca4678a8" + ] + ] + }, "RetentionInDays": 731 }, "UpdateReplacePolicy": "Retain", diff --git a/packages/@aws-cdk-testing/framework-integ/test/custom-resources/test/provider-framework/integ.provider-with-waiter-state-machine.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/custom-resources/test/provider-framework/integ.provider-with-waiter-state-machine.js.snapshot/manifest.json index c1c67f385b368..ccb36ad429810 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/custom-resources/test/provider-framework/integ.provider-with-waiter-state-machine.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/custom-resources/test/provider-framework/integ.provider-with-waiter-state-machine.js.snapshot/manifest.json @@ -18,7 +18,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/c4934037912635137a61ff14a2b2623fa08b180c4b757ad915d6fd9365ffb971.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/f846c7dce86a836c27a5ff81d868b42f46e94502cd6f0859944c4d9e48751e33.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -391,7 +391,10 @@ "/integ-provider-with-waiter-state-machine/MyProviderWithDefaultLog/waiter-state-machine/LogGroup/Resource": [ { "type": "aws:cdk:logicalId", - "data": "MyProviderWithDefaultLogwaiterstatemachineLogGroup5907E67B" + "data": "MyProviderWithDefaultLogwaiterstatemachineLogGroup5907E67B", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_REPLACE" + ] } ], "/integ-provider-with-waiter-state-machine/MyProviderWithDefaultLog/waiter-state-machine/Resource": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/custom-resources/test/provider-framework/integ.provider-with-waiter-state-machine.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/custom-resources/test/provider-framework/integ.provider-with-waiter-state-machine.js.snapshot/tree.json index 6d91d1944abdb..da6e395044085 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/custom-resources/test/provider-framework/integ.provider-with-waiter-state-machine.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/custom-resources/test/provider-framework/integ.provider-with-waiter-state-machine.js.snapshot/tree.json @@ -3006,7 +3006,18 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::Logs::LogGroup", "aws:cdk:cloudformation:props": { - "logGroupName": "/aws/vendedlogs/states/waiter-state-machine-c8755c6a4f7af107037ba386c1af047796ca4678a8-Logs", + "logGroupName": { + "Fn::Join": [ + "", + [ + "/aws/vendedlogs/states/waiter-state-machine-", + { + "Ref": "MyProviderWithDefaultLogframeworkisCompleteC86EC850" + }, + "-c8755c6a4f7af107037ba386c1af047796ca4678a8" + ] + ] + }, "retentionInDays": 731 } }, diff --git a/packages/aws-cdk-lib/custom-resources/lib/provider-framework/waiter-state-machine.ts b/packages/aws-cdk-lib/custom-resources/lib/provider-framework/waiter-state-machine.ts index 16c251809d8e0..02e5853535760 100644 --- a/packages/aws-cdk-lib/custom-resources/lib/provider-framework/waiter-state-machine.ts +++ b/packages/aws-cdk-lib/custom-resources/lib/provider-framework/waiter-state-machine.ts @@ -89,6 +89,7 @@ export class WaiterStateMachine extends Construct { * The ARN of the state machine. */ public readonly stateMachineArn: string; + private readonly isCompleteHandler: IFunction; constructor(scope: Construct, id: string, props: WaiterStateMachineProps) { super(scope, id); @@ -125,6 +126,7 @@ export class WaiterStateMachine extends Construct { }, }); + this.isCompleteHandler = props.isCompleteHandler; const resource = new CfnStateMachine(this, 'Resource', { definitionString: definition, roleArn: role.roleArn, @@ -173,12 +175,9 @@ export class WaiterStateMachine extends Construct { resources: ['*'], })); - // Using `node.addr` because it needs to be a unique log group name in the AWS account, - // not using `node.path` because of the possibility of exceeding the maximum number of characters for the log group name. - // The `addr` value does not change when moving the construct tree using the ID `Default`. const logGroupName = FeatureFlags.of(this).isEnabled(cxapi.WAITER_STATE_MACHINE_LOG_GROUP_NAME) - ? `/aws/vendedlogs/states/waiter-state-machine-${this.node.addr}-Logs` + ? `/aws/vendedlogs/states/waiter-state-machine-${this.isCompleteHandler.functionName}-${this.node.addr}` : undefined; const logGroup = logOptions?.destination ?? new LogGroup(this, 'LogGroup', { logGroupName, diff --git a/packages/aws-cdk-lib/custom-resources/test/provider-framework/waiter-state-machine.test.ts b/packages/aws-cdk-lib/custom-resources/test/provider-framework/waiter-state-machine.test.ts index 8198f6f074362..11f5f18d0e734 100644 --- a/packages/aws-cdk-lib/custom-resources/test/provider-framework/waiter-state-machine.test.ts +++ b/packages/aws-cdk-lib/custom-resources/test/provider-framework/waiter-state-machine.test.ts @@ -292,7 +292,18 @@ describe('state machine', () => { // THEN Template.fromStack(stack).hasResourceProperties('AWS::Logs::LogGroup', { - LogGroupName: '/aws/vendedlogs/states/waiter-state-machine-c892b744a2306a661f17f50ce17de4b606ce3fc700-Logs', + LogGroupName: { + 'Fn::Join': [ + '', + [ + '/aws/vendedlogs/states/waiter-state-machine-', + { + Ref: 'isCompleteBBB74F92', + }, + '-c892b744a2306a661f17f50ce17de4b606ce3fc700', + ], + ], + }, }); }); });