@@ -343,6 +343,9 @@ export class BackendStack extends cdk.Stack {
343343 // Create the 'api' resource
344344 const apiResource = api . root . addResource ( 'api' ) ;
345345
346+ // Create the 'docs' resource under 'api'
347+ const docsResource = apiResource . addResource ( 'docs' ) ;
348+
346349 // Create the 'reports' resource under 'api'
347350 const reportsResource = apiResource . addResource ( 'reports' ) ;
348351
@@ -361,6 +364,13 @@ export class BackendStack extends cdk.Stack {
361364 vpcLink : vpcLink ,
362365 } ;
363366
367+ const getDocsIntegration = new apigateway . Integration ( {
368+ type : apigateway . IntegrationType . HTTP_PROXY ,
369+ integrationHttpMethod : 'GET' ,
370+ uri : `${ serviceUrl } /api/docs` ,
371+ options : integrationOptions ,
372+ } ) ;
373+
364374 // Create integrations for each endpoint
365375 const getReportsIntegration = new apigateway . Integration ( {
366376 type : apigateway . IntegrationType . HTTP_PROXY ,
@@ -409,7 +419,7 @@ export class BackendStack extends cdk.Stack {
409419 // Add methods to the resources
410420 reportsResource . addMethod ( 'GET' , getReportsIntegration , methodOptions ) ;
411421 latestResource . addMethod ( 'GET' , getLatestReportIntegration , methodOptions ) ;
412-
422+ docsResource . addMethod ( 'GET' , getDocsIntegration , methodOptions ) ;
413423 // For path parameter methods, add the request parameter configuration
414424 reportIdResource . addMethod ( 'GET' , getReportByIdIntegration , {
415425 ...methodOptions ,
@@ -440,31 +450,7 @@ export class BackendStack extends cdk.Stack {
440450 latestResource . addCorsPreflight ( corsOptions ) ;
441451 reportIdResource . addCorsPreflight ( corsOptions ) ;
442452 reportStatusResource . addCorsPreflight ( corsOptions ) ;
443-
444- // Apply resource policy separately after resources and methods are created
445- // const apiResourcePolicy = new iam.PolicyDocument({
446- // statements: [
447- // // Allow authenticated Cognito users
448- // new iam.PolicyStatement({
449- // effect: iam.Effect.ALLOW,
450- // principals: [new iam.AnyPrincipal()],
451- // actions: ['execute-api:Invoke'],
452- // resources: [`arn:aws:execute-api:${this.region}:${this.account}:${api.restApiId}/*/*`],
453- // }),
454- // // Deny non-HTTPS requests
455- // new iam.PolicyStatement({
456- // effect: iam.Effect.DENY,
457- // principals: [new iam.AnyPrincipal()],
458- // actions: ['execute-api:Invoke'],
459- // resources: [`arn:aws:execute-api:${this.region}:${this.account}:${api.restApiId}/*/*`],
460- // conditions: {
461- // Bool: {
462- // 'aws:SecureTransport': 'false',
463- // },
464- // },
465- // }),
466- // ],
467- // });
453+ docsResource . addCorsPreflight ( corsOptions ) ;
468454
469455 // Create API Gateway execution role with required permissions
470456 new iam . Role ( this , `${ appName } APIGatewayRole-${ props . environment } ` , {
0 commit comments