Skip to content

Commit

Permalink
feat(construct): Updated field types and removed unused code (#29)
Browse files Browse the repository at this point in the history
* Added summary construct and lambda functions for summary stepfunction

* updated summary construct lambda functions

* fixed summary lambda issues

* summary construct fixes

* summary construct fixes

* removed unused nltk with bedrock client

* chore: self mutation

Signed-off-by: github-actions <[email protected]>

* added review comments

* removed unused merge api code and made fields stringly typedd

* updated bedrock icon in draw.io and architecture diagram

---------

Signed-off-by: github-actions <[email protected]>
Co-authored-by: Dinesh Sajwan <[email protected]>
Co-authored-by: github-actions <[email protected]>
  • Loading branch information
3 people authored Oct 13, 2023
1 parent 82af9ee commit f9c089d
Show file tree
Hide file tree
Showing 4 changed files with 552 additions and 39 deletions.
546 changes: 545 additions & 1 deletion docs/emerging_tech_cdk_constructs.drawio

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion lambda/input_validation/src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
aws-lambda-powertools
aws-xray-sdk
fastjsonschema
typing-extensions
boto3
requests
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 7 additions & 37 deletions src/patterns/gen-ai/aws-summarization-appsync-stepfn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import * as sqs from 'aws-cdk-lib/aws-sqs';
import * as sfn from 'aws-cdk-lib/aws-stepfunctions';
import * as sfnTask from 'aws-cdk-lib/aws-stepfunctions-tasks';
import { Construct } from 'constructs';
import * as appsyncMergedApi from '../../../common/helpers/appsyncmergedapi-helper';
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';
Expand Down Expand Up @@ -190,21 +189,21 @@ export class SummarizationAppsyncStepfn extends Construct {
/**
* Returns an instance of events.IEventBus created by the construct
*/
public readonly eventBridgeBus: events.IEventBus | undefined;
public readonly eventBridgeBus: events.IEventBus;
/**
* Returns an instance of appsync.CfnGraphQLApi for merge api created by the construct
*/
public readonly mergeApi: appsync.CfnGraphQLApi | undefined;
public readonly mergeApi: appsync.CfnGraphQLApi;

/**
* Returns an instance of appsync.CfnGraphQLApi for summary created by the construct
*/
public readonly summaryGraphqlApi: appsync.IGraphqlApi | undefined;
public readonly summaryGraphqlApi: appsync.IGraphqlApi ;

/**
* Returns an instance of redis cluster created by the construct
*/
public readonly redisCluster: elasticache.CfnCacheCluster | undefined;
public readonly redisCluster: elasticache.CfnCacheCluster;

/**
* Returns the instance of ec2.IVpc used by the construct
Expand All @@ -218,12 +217,12 @@ export class SummarizationAppsyncStepfn extends Construct {
/**
* Returns the instance of s3.IBucket used by the construct
*/
public readonly inputAssetBucket: s3.IBucket | undefined;
public readonly inputAssetBucket: s3.IBucket;

/**
* Returns the instance of s3.IBucket used by the construct
*/
public readonly processedAssetBucket: s3.IBucket | undefined;
public readonly processedAssetBucket: s3.IBucket;

/**
* Logging configuration for AppSync
Expand Down Expand Up @@ -330,7 +329,7 @@ export class SummarizationAppsyncStepfn extends Construct {
});
redisHelper.setInboundRules(redisSecurityGroup, this.securityGroup);
} else {
this.redisCluster= props?.existingRedisCulster;
this.redisCluster= props?.existingRedisCulster!;
}

const redisHost = this.redisCluster?.attrRedisEndpointAddress!;
Expand All @@ -344,16 +343,6 @@ export class SummarizationAppsyncStepfn extends Construct {
eventBusProps: props.eventBusProps,
});


appsyncMergedApi.checkAppsyncMergedApiProps(props);

const appsyncServicePrincipleRoleName = 'appsync.amazonaws.com';

const mergeApiRole = new iam.Role(this, 'mergedapirole'+stage, {
assumedBy: new iam.ServicePrincipal(appsyncServicePrincipleRoleName),
});


this.mergeApi = props.existingMergeApi;

const mergeApiId = this.mergeApi.attrApiId;
Expand Down Expand Up @@ -406,25 +395,6 @@ export class SummarizationAppsyncStepfn extends Construct {
const updateGraphQlApiId = !mergeApiId ? summarizationGraphqlApi.apiId : mergeApiId;


// associate source api with merge api
const sourceApiAssociationConfigProperty:
appsync.CfnSourceApiAssociation.SourceApiAssociationConfigProperty = {
mergeType: 'AUTO_MERGE',
};

const sourceApiAssociation = new appsync.CfnSourceApiAssociation(this,
'sourceApiAssociations'+stage,
{
mergedApiIdentifier: mergeApiId,
sourceApiAssociationConfig: sourceApiAssociationConfigProperty,
sourceApiIdentifier: summarizationGraphqlApi.apiId,
});

sourceApiAssociation.node.addDependency(summarizationGraphqlApi);

// update merge api role with access
appsyncMergedApi.setMergedApiRole(mergeApiId, summarizationGraphqlApi.apiId, mergeApiRole);

// Lambda function to validate Input
const inputValidatorLambda =
new lambdaFunction.DockerImageFunction(this, 'inputValidatorLambda'+stage,
Expand Down

0 comments on commit f9c089d

Please sign in to comment.