Skip to content

Commit 58d5a2b

Browse files
committed
Create dynamic bucketName
1 parent 8aa25f6 commit 58d5a2b

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

packages/cdk/resources/Storage.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,26 @@ import {Construct} from "constructs"
22
import {Key} from "aws-cdk-lib/aws-kms"
33
import {S3Bucket} from "../constructs/S3Bucket"
44

5+
export interface StorageProps {
6+
readonly stackName: string
7+
}
8+
59
export class Storage extends Construct {
610
public readonly kbDocsBucket: S3Bucket
711
public readonly kbDocsKey: Key
812

9-
constructor(scope: Construct, id: string) {
13+
constructor(scope: Construct, id: string, props: StorageProps) {
1014
super(scope, id)
1115

1216
// Create customer-managed KMS key for knowledge base document encryption
13-
this.kbDocsKey = new Key(this, "KbDocsKeyPr", {
17+
this.kbDocsKey = new Key(this, "KbDocsKey", {
1418
enableKeyRotation: true,
1519
description: "KMS key for encrypting knowledge base documents"
1620
})
1721

1822
// Create S3 bucket for knowledge base documents with encryption
1923
this.kbDocsBucket = new S3Bucket(this, "DocsBucket", {
20-
bucketName: "DocsPr",
24+
bucketName: `${props.stackName}-Docs`,
2125
kmsKey: this.kbDocsKey,
2226
versioned: true
2327
})

packages/cdk/stacks/EpsAssistMeStack.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ export class EpsAssistMeStack extends Stack {
5050
// - Storage needs to exist first so IamResources can reference the S3 bucket for policies
5151
// - IamResources creates the Bedrock role that needs S3 access permissions
5252
// - KMS permissions are added manually after both constructs exist
53-
const storage = new Storage(this, "Storage")
53+
const storage = new Storage(this, "Storage", {
54+
stackName: props.stackName
55+
})
5456

5557
// Create IAM Resources
5658
const iamResources = new IamResources(this, "IamResources", {

0 commit comments

Comments
 (0)