Skip to content

Commit

Permalink
feat(construct): fixed bugs in image generation construct (#338)
Browse files Browse the repository at this point in the history
* feat(bugfix): fixed version error

* feat(construct): updated image generation resource policy and graphql api type

* chore: self mutation

Signed-off-by: github-actions <github-actions@github.com>

---------

Signed-off-by: github-actions <github-actions@github.com>
Co-authored-by: Dinesh Sajwan <dinsajwa@amazon.com>
Co-authored-by: github-actions <github-actions@github.com>
  • Loading branch information
3 people committed Mar 22, 2024
1 parent 4d16b8a commit 24d63a3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
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;
/**
* 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

0 comments on commit 24d63a3

Please sign in to comment.