Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(construct): fixed bugs in image generation construct #338

Merged
merged 11 commits into from
Mar 22, 2024
6 changes: 3 additions & 3 deletions apidocs/classes/ContentGenerationAppSyncLambda.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public

`Readonly` **cgLambdaFunction**: `DockerImageFunction`

Returns an instance of appsync.IGraphqlApi created by the construct
Returns an instance of appsync.GraphqlApi created by the construct

___

Expand Down Expand Up @@ -140,9 +140,9 @@ ___

### graphqlApi

`Readonly` **graphqlApi**: `IGraphqlApi`
`Readonly` **graphqlApi**: `GraphqlApi`

Returns an instance of appsync.IGraphqlApi created by the construct
Returns an instance of appsync.GraphqlApi created by the construct

___

Expand Down
4 changes: 2 additions & 2 deletions src/common/base-class/base-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ export class BaseClass extends Construct {
throw Error('construct name is not present in usageMetricMap ');
}

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

// 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}) ",
// where C1,C2, etc are mapped with construct-name-enum and the values shows the number of time stack created/deleted.
Stack.of(scope).templateOptions.description =
`(usage id :${this.constructUsageMetric})(version:${version}) (constructs :::${ usageMetricMapSerialized}) `;
`Description: (${this.constructUsageMetric}) (version:${version}) (tag:${ usageMetricMapSerialized}) `;

};
}
Expand Down
20 changes: 7 additions & 13 deletions src/patterns/gen-ai/aws-contentgen-appsync-lambda/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ export class ContentGenerationAppSyncLambda extends BaseClass {
*/
public readonly s3GenerateAssetsBucket?: s3.Bucket;
/**
* Returns an instance of appsync.IGraphqlApi created by the construct
* Returns an instance of appsync.GraphqlApi created by the construct
*/
public readonly graphqlApi: appsync.IGraphqlApi;
public readonly graphqlApi: appsync.GraphqlApi;
scottschreckengaust marked this conversation as resolved.
Show resolved Hide resolved
/**
* Returns an instance of appsync.IGraphqlApi created by the construct
* Returns an instance of appsync.GraphqlApi created by the construct
*/
public readonly cgLambdaFunction: lambda.DockerImageFunction;

Expand Down Expand Up @@ -412,12 +412,10 @@ export class ContentGenerationAppSyncLambda extends BaseClass {
generate_image_function_role.addToPolicy(
new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: ['s3:GetObject', 's3:GetObject*', 's3:GetBucket*', 's3:List*'],
actions: ['s3:GetObject', 's3:GetBucket', 's3:ListBucket', 's3:PutObject'],
resources: [
'arn:' + Aws.PARTITION + ':s3:::' + this.s3GenerateAssetsBucketInterface?.bucketName,
'arn:' + Aws.PARTITION + ':s3:::' +
this.s3GenerateAssetsBucketInterface?.bucketName +
'/*',
'arn:' + Aws.PARTITION + ':s3:::' + this.s3GenerateAssetsBucketInterface.bucketName + '/*',

],
}),
);
Expand All @@ -441,11 +439,7 @@ export class ContentGenerationAppSyncLambda extends BaseClass {
new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: [
'comprehend:DetectEntities',
'comprehend:DetectKeyPhrases',
'comprehend:DetectPiiEntities',
'comprehend:DetectSentiment',
'comprehend:DetectSyntax',
'comprehend:DetectToxicContent',
],
resources: ['*'],
}),
Expand Down