Skip to content

Commit 24d63a3

Browse files
dineshSajwanDinesh Sajwangithub-actions
authored
feat(construct): fixed bugs in image generation construct (#338)
* feat(bugfix): fixed version error * feat(construct): updated image generation resource policy and graphql api type * chore: self mutation Signed-off-by: github-actions <[email protected]> --------- Signed-off-by: github-actions <[email protected]> Co-authored-by: Dinesh Sajwan <[email protected]> Co-authored-by: github-actions <[email protected]>
1 parent 4d16b8a commit 24d63a3

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed

apidocs/classes/ContentGenerationAppSyncLambda.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public
8484

8585
`Readonly` **cgLambdaFunction**: `DockerImageFunction`
8686

87-
Returns an instance of appsync.IGraphqlApi created by the construct
87+
Returns an instance of appsync.GraphqlApi created by the construct
8888

8989
___
9090

@@ -140,9 +140,9 @@ ___
140140

141141
### graphqlApi
142142

143-
`Readonly` **graphqlApi**: `IGraphqlApi`
143+
`Readonly` **graphqlApi**: `GraphqlApi`
144144

145-
Returns an instance of appsync.IGraphqlApi created by the construct
145+
Returns an instance of appsync.GraphqlApi created by the construct
146146

147147
___
148148

src/common/base-class/base-class.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ export class BaseClass extends Construct {
158158
throw Error('construct name is not present in usageMetricMap ');
159159
}
160160

161-
const usageMetricMapSerialized = JSON.stringify(BaseClass.usageMetricMap);
161+
const usageMetricMapSerialized = JSON.stringify(BaseClass.usageMetricMap).replace(/[{}]/g, '').replace(/"/g, '');
162162

163163
// Description format :(usage id :uksb-1tupboc45)(version:0.0.0) (constructs :::{\"C1\":1,\"C2\":5,\"C3\":3,\"C4\":0,\"C5\":0,\"C6\":0,\"C7\":0,\"C8\":0}) ",
164164
// where C1,C2, etc are mapped with construct-name-enum and the values shows the number of time stack created/deleted.
165165
Stack.of(scope).templateOptions.description =
166-
`(usage id :${this.constructUsageMetric})(version:${version}) (constructs :::${ usageMetricMapSerialized}) `;
166+
`Description: (${this.constructUsageMetric}) (version:${version}) (tag:${ usageMetricMapSerialized}) `;
167167

168168
};
169169
}

src/patterns/gen-ai/aws-contentgen-appsync-lambda/index.ts

+7-13
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ export class ContentGenerationAppSyncLambda extends BaseClass {
152152
*/
153153
public readonly s3GenerateAssetsBucket?: s3.Bucket;
154154
/**
155-
* Returns an instance of appsync.IGraphqlApi created by the construct
155+
* Returns an instance of appsync.GraphqlApi created by the construct
156156
*/
157-
public readonly graphqlApi: appsync.IGraphqlApi;
157+
public readonly graphqlApi: appsync.GraphqlApi;
158158
/**
159-
* Returns an instance of appsync.IGraphqlApi created by the construct
159+
* Returns an instance of appsync.GraphqlApi created by the construct
160160
*/
161161
public readonly cgLambdaFunction: lambda.DockerImageFunction;
162162

@@ -412,12 +412,10 @@ export class ContentGenerationAppSyncLambda extends BaseClass {
412412
generate_image_function_role.addToPolicy(
413413
new iam.PolicyStatement({
414414
effect: iam.Effect.ALLOW,
415-
actions: ['s3:GetObject', 's3:GetObject*', 's3:GetBucket*', 's3:List*'],
415+
actions: ['s3:GetObject', 's3:GetBucket', 's3:ListBucket', 's3:PutObject'],
416416
resources: [
417-
'arn:' + Aws.PARTITION + ':s3:::' + this.s3GenerateAssetsBucketInterface?.bucketName,
418-
'arn:' + Aws.PARTITION + ':s3:::' +
419-
this.s3GenerateAssetsBucketInterface?.bucketName +
420-
'/*',
417+
'arn:' + Aws.PARTITION + ':s3:::' + this.s3GenerateAssetsBucketInterface.bucketName + '/*',
418+
421419
],
422420
}),
423421
);
@@ -441,11 +439,7 @@ export class ContentGenerationAppSyncLambda extends BaseClass {
441439
new iam.PolicyStatement({
442440
effect: iam.Effect.ALLOW,
443441
actions: [
444-
'comprehend:DetectEntities',
445-
'comprehend:DetectKeyPhrases',
446-
'comprehend:DetectPiiEntities',
447-
'comprehend:DetectSentiment',
448-
'comprehend:DetectSyntax',
442+
'comprehend:DetectToxicContent',
449443
],
450444
resources: ['*'],
451445
}),

0 commit comments

Comments
 (0)