Error: There is already a Construct with name 'Regsep' in AppRegistry [AppRegistry]

0

Hello folks, basically I am working on a project and facing some issue :

while executing the code of bulkupload.ts I am getting this error 

throw new Error(There is already a Construct with name '${childName}' in ${typeName}${name.length > 0 ? ' [' + name + ']' : ''});

       ^

Error: There is already a Construct with name 'Regsep' in AppRegistry [AppRegistry]

here is the whole error :: npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead. /home/famith/git/source/infrastructure/node_modules/constructs/src/construct.ts:447 throw new Error(There is already a Construct with name '${childName}' in ${typeName}${name.length > 0 ? ' [' + name + ']' : ''}); ^ Error: There is already a Construct with name 'Regsep' in AppRegistry [AppRegistry] at Node.addChild (/home/famith/git/source/infrastructure/node_modules/constructs/src/construct.ts:447:13) at new Node (/home/famith/git/source/infrastructure/node_modules/constructs/src/construct.ts:71:17) at new Construct (/home/famith/git/source/infrastructure/node_modules/constructs/src/construct.ts:499:17) at new Resource (/home/famith/git/source/infrastructure/node_modules/aws-cdk-lib/core/lib/resource.js:1:1309) at new ApplicationBase (/home/famith/git/source/infrastructure/node_modules/@aws-cdk/aws-servicecatalogappregistry-alpha/lib/application.js:19:9) at new Application (/home/famith/git/source/infrastructure/node_modules/@aws-cdk/aws-servicecatalogappregistry-alpha/lib/application.ts:316:5) at AppRegistry.createAppForAppRegistry (/home/famith/git/source/infrastructure/lib/utils/app-registry-aspects.ts:122:28) at AppRegistry.visit (/home/famith/git/source/infrastructure/lib/utils/app-registry-aspects.ts:98:22) at recurse (/home/famith/git/source/infrastructure/node_modules/aws-cdk-lib/core/lib/private/synthesis.js:2:2282) at recurse (/home/famith/git/source/infrastructure/node_modules/aws-cdk-lib/core/lib/private/synthesis.js:2:2646)

here is below code for bulk upload 

import * as cdk from 'aws-cdk-lib';

import * as s3 from 'aws-cdk-lib/aws-s3';

import * as iam from 'aws-cdk-lib/aws-iam';

import * as lambda from 'aws-cdk-lib/aws-lambda';

import { LAMBDA_TIMEOUT_MINS } from '../utils/constants';

import { Construct } from 'constructs';

import { NagSuppressions } from 'cdk-nag';

export class BulkUploadLambda extends cdk.Stack {

constructor(scope: Construct, id: string, props?: cdk.StackProps) {

   super(scope, id, props);

   // Define the S3 bucket for document uploads

   const uploadBucket = new s3.Bucket(this, 'DocumentRepo', {

       // Define bucket properties here

   });

   // Create an IAM role for the Bulk Upload Lambda function

   const bulkUploadLambdaRole = new iam.Role(this, 'BulkUploadLambdaRole', {

       assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com'),

       inlinePolicies: {

           'CustomLambdaPolicy': new iam.PolicyDocument({

               statements: [

                   new iam.PolicyStatement({

                       actions: ['s3:GetObject', 's3:PutObject'],

                       resources: [uploadBucket.bucketArn + '/*'],

                   }),

                   // Add any other necessary permissions here

               ],

           }),

       },

   });

   // Suppress CDK Nag rules for the Bulk Upload Lambda Role

   NagSuppressions.addResourceSuppressions(bulkUploadLambdaRole, [

       {

           id: 'AwsSolutions-IAM5',

           reason: 'Provide a reason for allowing wildcard permissions',

           appliesTo: [

               `Resource::<BulkUploadLambdaDocumentRepo.Arn>/*`,

           ],

       },

   ]);

   // Define the Bulk Upload Lambda function

   const bulkUploadLambda = new lambda.Function(this, 'BulkUploadLambda', {

       runtime: lambda.Runtime.PYTHON_3_11,

       handler: 'lambda_function.lambda_handler',

       code: lambda.Code.fromAsset('../lambda/bulk-upload'),

       timeout: cdk.Duration.minutes(LAMBDA_TIMEOUT_MINS), // Define your timeout value

       role: bulkUploadLambdaRole,

   });

}

}

finally i am calling this bulk.ts in dusstack.ts

Keine Antworten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen