Skip to content

Commit

Permalink
chore: more components to enable
Browse files Browse the repository at this point in the history
  • Loading branch information
Erdem Ayyildiz committed Jun 24, 2024
1 parent af2fc2c commit 2133596
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/common/helpers/vpc-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,13 @@ export function DefaultVpcProps(): VpcProps {
};
}

export function createOpenSearchVpcEndpoint(scope: Construct, vpc: IVpc, props: OpenSearchProps) {
export function createOpenSearchVpcEndpoint(scope: Construct, vpc: IVpc, sg: ec2.ISecurityGroup, props: OpenSearchProps) {
if (props?.existingOpensearchServerlessCollection) {
new CfnVpcEndpoint(scope, 'VpcEndpoint', {
name: 'VpcEndpoint',
vpcId: vpc.vpcId,
subnetIds: vpc.selectSubnets({ subnetType: ec2.SubnetType.PRIVATE_ISOLATED }).subnetIds,
securityGroupIds: [getlambdaSecuritygroup(scope, vpc, 'aoss').securityGroupId],
securityGroupIds: [sg.securityGroupId],
});
}
if (props?.existingOpensearchDomain) {
Expand All @@ -198,7 +198,7 @@ export function createOpenSearchVpcEndpoint(scope: Construct, vpc: IVpc, props:
Endpoint: props?.existingOpensearchDomain.domainEndpoint,
DomainArn: props?.existingOpensearchDomain.domainArn,
SubnetIds: vpc.selectSubnets({ subnetType: ec2.SubnetType.PRIVATE_ISOLATED }).subnetIds,
SecurityGroupIds: [getlambdaSecuritygroup(scope, vpc, 'es').securityGroupId],
SecurityGroupIds: [sg.securityGroupId],
},
});
}
Expand Down
7 changes: 5 additions & 2 deletions src/patterns/gen-ai/aws-qa-appsync-opensearch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,8 @@ export class QaAppsyncOpensearch extends BaseClass {
this.vpc = vpc_helper.buildVpc(scope, {
defaultVpcProps: props?.vpcProps,
});
vpc_helper.createOpenSearchVpcEndpoint(scope, this.vpc, props);
}


//vpc endpoints
vpc_helper.AddAwsServiceEndpoint(scope, this.vpc, [
vpc_helper.ServiceEndpointTypeEnum.S3,
Expand All @@ -252,6 +250,11 @@ export class QaAppsyncOpensearch extends BaseClass {
});
}

//vpc endpoint for opensearch
if (!props?.existingVpc) {
vpc_helper.createOpenSearchVpcEndpoint(scope, this.vpc, this.securityGroup, props);
}

// vpc flowloggroup
const logGroup = new logs.LogGroup(this, 'qaConstructLogGroup');
const role = new iam.Role(this, 'qaConstructRole', {
Expand Down
19 changes: 1 addition & 18 deletions src/patterns/gen-ai/aws-rag-appsync-stepfn-kendra/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
} from '../../../common/helpers/kendra-helper';
import { buildDockerLambdaFunction } from '../../../common/helpers/lambda-builder-helper';
import { lambdaMemorySizeLimiter } from '../../../common/helpers/utils';
import { AddAwsServiceEndpoint, buildVpc, createDefaultIsolatedVpcProps } from '../../../common/helpers/vpc-helper';
import { AddAwsServiceEndpoint, buildVpc, createDefaultIsolatedVpcProps, ServiceEndpointTypeEnum } from '../../../common/helpers/vpc-helper';
import { DockerLambdaCustomProps } from '../../../common/props/DockerLambdaCustomProps';

/**
Expand Down Expand Up @@ -140,23 +140,6 @@ export interface RagAppsyncStepfnKendraProps {
readonly updateKendraJobStatusLambdaProps?: DockerLambdaCustomProps | undefined;
}

enum ServiceEndpointTypeEnum {
DYNAMODB= 'DDB',
ECR_API= 'ECR_API',
ECR_DKR= 'ECR_DKR',
EVENTS= 'CLOUDWATCH_EVENTS',
KENDRA= 'KENDRA',
KINESIS_FIREHOSE= 'KINESIS_FIREHOSE',
KINESIS_STREAMS= 'KINESIS_STREAMS',
S3= 'S3',
SAGEMAKER_RUNTIME= 'SAGEMAKER_RUNTIME',
SECRETS_MANAGER= 'SECRETS_MANAGER',
SNS= 'SNS',
SQS= 'SQS',
SSM= 'SSM',
STEP_FUNCTIONS= 'STEP_FUNCTIONS',
}

/**
* @summary The RagAppsyncStepfnKendra class.
*/
Expand Down
16 changes: 15 additions & 1 deletion src/patterns/gen-ai/aws-rag-appsync-stepfn-opensearch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,18 @@ export class RagAppsyncStepfnOpensearch extends BaseClass {
if (props?.existingVpc) {
this.vpc = props.existingVpc;
} else {
this.vpc = new ec2.Vpc(this, 'Vpc', props.vpcProps);
this.vpc = vpc_helper.buildVpc(scope, {
defaultVpcProps: props?.vpcProps,
});
}

//vpc endpoints
vpc_helper.AddAwsServiceEndpoint(scope, this.vpc, [
vpc_helper.ServiceEndpointTypeEnum.S3,
vpc_helper.ServiceEndpointTypeEnum.BEDROCK_RUNTIME,
vpc_helper.ServiceEndpointTypeEnum.APP_SYNC,
]);

// Security group
if (props?.existingSecurityGroup) {
this.securityGroup = props.existingSecurityGroup;
Expand All @@ -275,6 +284,11 @@ export class RagAppsyncStepfnOpensearch extends BaseClass {
);
}

//vpc endpoint for opensearch
if (!props?.existingVpc) {
vpc_helper.createOpenSearchVpcEndpoint(scope, this.vpc, this.securityGroup, props);
}

// vpc flowloggroup
const logGroup = new logs.LogGroup(this, 'ingestionConstructLogGroup');
const role = new iam.Role(this, 'ingestionConstructRole', {
Expand Down
11 changes: 10 additions & 1 deletion src/patterns/gen-ai/aws-summarization-appsync-stepfn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import * as eventBridge from '../../../common/helpers/eventbridge-helper';
import { buildDockerLambdaFunction } from '../../../common/helpers/lambda-builder-helper';
import * as s3BucketHelper from '../../../common/helpers/s3-bucket-helper';
import { lambdaMemorySizeLimiter, generatePhysicalNameV2 } from '../../../common/helpers/utils';
import * as vpc_helper from '../../../common/helpers/vpc-helper';
import { DockerLambdaCustomProps } from '../../../common/props/DockerLambdaCustomProps';

export interface SummarizationAppsyncStepfnProps {
Expand Down Expand Up @@ -257,8 +258,16 @@ export class SummarizationAppsyncStepfn extends BaseClass {
if (props?.existingVpc) {
this.vpc = props.existingVpc;
} else {
this.vpc = new ec2.Vpc(this, 'Vpc', props.vpcProps);
this.vpc = vpc_helper.buildVpc(scope, {
defaultVpcProps: props?.vpcProps,
});
}

// vpc endpoints
vpc_helper.AddAwsServiceEndpoint(scope, this.vpc, [vpc_helper.ServiceEndpointTypeEnum.S3,
vpc_helper.ServiceEndpointTypeEnum.BEDROCK_RUNTIME, vpc_helper.ServiceEndpointTypeEnum.REKOGNITION,
vpc_helper.ServiceEndpointTypeEnum.APP_SYNC]);

// Security group
if (props?.existingSecurityGroup) {
this.securityGroup = props.existingSecurityGroup;
Expand Down

0 comments on commit 2133596

Please sign in to comment.