Skip to content

Commit 213032d

Browse files
dineshSajwandinsajwakrokoko
authored
feat(issue-667): added an optional custom policy for vector collection (#811)
* feat(issue-667): added an optional custom policy for vector collection --------- Co-authored-by: dinsajwa <[email protected]> Co-authored-by: Alain Krok <[email protected]>
1 parent 48daf18 commit 213032d

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

apidocs/namespaces/opensearchserverless/interfaces/VectorCollectionProps.md

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ The name of the collection.
1616

1717
***
1818

19+
### customAossPolicy?
20+
21+
> `readonly` `optional` **customAossPolicy**: `ManagedPolicy`
22+
23+
A user defined IAM policy that allows API access to the collection.
24+
25+
***
26+
1927
### standbyReplicas?
2028

2129
> `readonly` `optional` **standbyReplicas**: [`VectorCollectionStandbyReplicas`](../enumerations/VectorCollectionStandbyReplicas.md)

src/cdk-lib/opensearchserverless/vector-collection.ts

+23-14
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ export interface VectorCollectionProps {
3333
* @default ENABLED
3434
*/
3535
readonly standbyReplicas?: VectorCollectionStandbyReplicas;
36+
37+
/**
38+
* A user defined IAM policy that allows API access to the collection.
39+
*/
40+
readonly customAossPolicy?: iam.ManagedPolicy;
3641
}
3742

3843
/**
@@ -135,20 +140,24 @@ export class VectorCollection extends Construct {
135140
this.collectionArn = collection.attrArn;
136141
this.collectionId = collection.attrId;
137142

138-
this.aossPolicy = new iam.ManagedPolicy(
139-
this,
140-
'AOSSApiAccessAll', {
141-
statements: [
142-
new iam.PolicyStatement({
143-
effect: iam.Effect.ALLOW,
144-
actions: [
145-
'aoss:APIAccessAll',
146-
],
147-
resources: [collection.attrArn],
148-
}),
149-
],
150-
},
151-
);
143+
if (props?.customAossPolicy) {
144+
this.aossPolicy = props.customAossPolicy;
145+
} else {
146+
this.aossPolicy = new iam.ManagedPolicy(
147+
this,
148+
'AOSSApiAccessAll', {
149+
statements: [
150+
new iam.PolicyStatement({
151+
effect: iam.Effect.ALLOW,
152+
actions: [
153+
'aoss:APIAccessAll',
154+
],
155+
resources: [collection.attrArn],
156+
}),
157+
],
158+
},
159+
);
160+
}
152161

153162
collection.addDependency(encryptionPolicy);
154163
collection.addDependency(networkPolicy);

0 commit comments

Comments
 (0)