Skip to content

Commit

Permalink
fix(lint): run linter
Browse files Browse the repository at this point in the history
  • Loading branch information
krokoko committed Dec 15, 2023
1 parent 895e56e commit f2e170a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 39 deletions.
62 changes: 31 additions & 31 deletions src/common/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,34 @@ import * as cdk from 'aws-cdk-lib';
*
*/
export function generatePhysicalName(
prefix: string,
parts: string[],
maxLength: number,
): string {
// The result will consist of:
// -The prefix - unaltered
// -The parts concatenated, but reduced in size to meet the maxLength limit for the overall name
// -A hyphen delimiter
// -The GUID portion of the stack arn
const stackIdGuidLength = 36;
const prefixLength = prefix.length;
const maxPartsLength = maxLength - prefixLength - 1 - stackIdGuidLength; // 1 is the hyphen
// Extract the Stack ID Guid
const uniqueStackIdPart = cdk.Fn.select(2, cdk.Fn.split('/', `${cdk.Aws.STACK_ID}`));
let allParts: string = '';
parts.forEach((part) => {
allParts += part;
});
if (allParts.length > maxPartsLength) {
const subStringLength = maxPartsLength / 2;
allParts = allParts.substring(0, subStringLength) + allParts.substring(allParts.length - subStringLength);
}
const finalName = prefix.toLowerCase() + allParts + '-' + uniqueStackIdPart;
return finalName;
}
prefix: string,
parts: string[],
maxLength: number,
): string {
// The result will consist of:
// -The prefix - unaltered
// -The parts concatenated, but reduced in size to meet the maxLength limit for the overall name
// -A hyphen delimiter
// -The GUID portion of the stack arn

const stackIdGuidLength = 36;
const prefixLength = prefix.length;
const maxPartsLength = maxLength - prefixLength - 1 - stackIdGuidLength; // 1 is the hyphen

// Extract the Stack ID Guid
const uniqueStackIdPart = cdk.Fn.select(2, cdk.Fn.split('/', `${cdk.Aws.STACK_ID}`));

let allParts: string = '';

parts.forEach((part) => {
allParts += part;
});

if (allParts.length > maxPartsLength) {
const subStringLength = maxPartsLength / 2;
allParts = allParts.substring(0, subStringLength) + allParts.substring(allParts.length - subStringLength);
}

const finalName = prefix.toLowerCase() + allParts + '-' + uniqueStackIdPart;
return finalName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import * as stepfn_task from 'aws-cdk-lib/aws-stepfunctions-tasks';
import { NagSuppressions } from 'cdk-nag';
import { Construct } from 'constructs';
import * as s3_bucket_helper from '../../../common/helpers/s3-bucket-helper';
import * as vpc_helper from '../../../common/helpers/vpc-helper';
import { generatePhysicalName } from '../../../common/helpers/utils';
import * as vpc_helper from '../../../common/helpers/vpc-helper';

/**
* The properties for the RagAppsyncStepfnOpensearchProps class.
Expand Down Expand Up @@ -776,12 +776,12 @@ export class RagAppsyncStepfnOpensearch extends Construct {
const maxGeneratedNameLength = maxLogGroupNameLength - logGroupPrefix.length;
const nameParts: string[] = [
Stack.of(scope).stackName, // Name of the stack
scope.node.id, // Construct ID
'StateMachineLog' // Literal string for log group name portion
scope.node.id, // Construct ID
'StateMachineLog', // Literal string for log group name portion
];
const logGroupName = generatePhysicalName(logGroupPrefix, nameParts, maxGeneratedNameLength);
const ragLogGroup = new logs.LogGroup(this, 'ingestionStepFunctionLogGroup', {
logGroupName: logGroupName
logGroupName: logGroupName,
});

const ingestion_step_function = new stepfn.StateMachine(
Expand Down
8 changes: 4 additions & 4 deletions src/patterns/gen-ai/aws-summarization-appsync-stepfn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import { Construct } from 'constructs';
import * as eventBridge from '../../../common/helpers/eventbridge-helper';
import * as redisHelper from '../../../common/helpers/redis-helper';
import * as s3BucketHelper from '../../../common/helpers/s3-bucket-helper';
import * as vpcHelper from '../../../common/helpers/vpc-helper';
import { generatePhysicalName } from '../../../common/helpers/utils';
import * as vpcHelper from '../../../common/helpers/vpc-helper';

export interface SummarizationAppsyncStepfnProps {
/**
Expand Down Expand Up @@ -810,12 +810,12 @@ export class SummarizationAppsyncStepfn extends Construct {
const maxGeneratedNameLength = maxLogGroupNameLength - logGroupPrefix.length;
const nameParts: string[] = [
Stack.of(scope).stackName, // Name of the stack
scope.node.id, // Construct ID
'StateMachineLog' // Literal string for log group name portion
scope.node.id, // Construct ID
'StateMachineLog', // Literal string for log group name portion
];
const logGroupName = generatePhysicalName(logGroupPrefix, nameParts, maxGeneratedNameLength);
const summarizationLogGroup = new logs.LogGroup(this, 'summarizationLogGroup', {
logGroupName: logGroupName
logGroupName: logGroupName,
});

// step function definition
Expand Down

0 comments on commit f2e170a

Please sign in to comment.