Skip to content

Commit

Permalink
unique log group name in the case for removing and recreating the sam…
Browse files Browse the repository at this point in the history
…e Provider
  • Loading branch information
go-to-k committed Jan 5, 2024
1 parent bf391e4 commit 277023c
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 11 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -125,6 +126,7 @@ export class WaiterStateMachine extends Construct {
},
});

this.isCompleteHandler = props.isCompleteHandler;
const resource = new CfnStateMachine(this, 'Resource', {
definitionString: definition,
roleArn: role.roleArn,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
],
},
});
});
});

0 comments on commit 277023c

Please sign in to comment.