Skip to content

Commit

Permalink
feat(construct): adding outputbucket permission to bda result status …
Browse files Browse the repository at this point in the history
…lambda
  • Loading branch information
dinsajwa committed Feb 21, 2025
1 parent 907924d commit 2420f27
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,31 @@ import * as path from 'path';
import { aws_iam as iam, aws_lambda as lambda, Duration, Aws } from 'aws-cdk-lib';
import { NagSuppressions } from 'cdk-nag';
import { Construct } from 'constructs';
import * as s3 from 'aws-cdk-lib/aws-s3';


/**
* Properties for creating a BdaBlueprintLambda
*/
export interface BdaResultsambdaProps {
export interface BdaResultsLambdaProps {
/**
* The layers to apply to this lambda function.
*/
readonly lambdaLayers: lambda.ILayerVersion[];
/**
* The S3 bucket
* Output bucket to publish the generated result
* by Bedrock Data Automation process.
*/
readonly outputBucket: s3.IBucket;
}

/**
* Lambda function that manages BDA results
*/
export class BdaResultsambda extends lambda.Function {

constructor(scope: Construct, id: string, props: BdaResultsambdaProps) {
constructor(scope: Construct, id: string, props: BdaResultsLambdaProps) {

const role = new iam.Role(
scope,
Expand Down Expand Up @@ -111,9 +119,10 @@ export class BdaResultsambda extends lambda.Function {
true,
);


role.attachInlinePolicy(bedrockBDAPolicy);


if (this.role) {
props.outputBucket.grantReadWrite(this.role);
}
}
}
3 changes: 2 additions & 1 deletion src/patterns/gen-ai/aws-bedrock-data-automation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,10 @@ export class BedrockDataAutomation extends BaseClass {
lambdaLayers: [this.powertoolsLayer, this.boto3Layer],
});
}
if (props.isStatusRequired) {
if (props.isStatusRequired && this.bdaOutputBucket) {
this.bdaResultStatusFunction = new BdaResultsambda(this, 'bdaresultslambda', {
lambdaLayers: [this.powertoolsLayer, this.boto3Layer],
outputBucket: this.bdaOutputBucket,
});
}
}
Expand Down

0 comments on commit 2420f27

Please sign in to comment.