Skip to content

Commit e32fa20

Browse files
aws-rafamskrokoko
andauthored
fix(bedrock): inference profiles permissions (#994)
* fix(bedrock): modify iam policies and add sonnet 3 7 --------- Co-authored-by: krokoko <[email protected]>
1 parent c813d89 commit e32fa20

20 files changed

+942
-14
lines changed

.gitignore

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.npmignore

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projen/tasks.json

+69
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apidocs/namespaces/bedrock/classes/BedrockFoundationModel.md

+6
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ The ARN of the Bedrock invokable abstraction.
145145

146146
> `readonly` `static` **ANTHROPIC\_CLAUDE\_3\_5\_SONNET\_V2\_0**: [`BedrockFoundationModel`](BedrockFoundationModel.md)
147147
148+
***
149+
150+
### ANTHROPIC\_CLAUDE\_3\_7\_SONNET\_V1\_0
151+
152+
> `readonly` `static` **ANTHROPIC\_CLAUDE\_3\_7\_SONNET\_V1\_0**: [`BedrockFoundationModel`](BedrockFoundationModel.md)
153+
148154
*************************************************************************
149155
ANTHROPIC
150156
*************************************************************************

package.json

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cdk-lib/bedrock/inference-profiles/cross-region-inference-profile.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export class CrossRegionInferenceProfile implements IInvokable, IInferenceProfil
151151
grantProfileUsage(grantee: IGrantable): Grant {
152152
const grant = Grant.addToPrincipal({
153153
grantee: grantee,
154-
actions: ['bedrock:GetInferenceProfile', 'bedrock:InvokeModel'],
154+
actions: ['bedrock:GetInferenceProfile', 'bedrock:InvokeModel*'],
155155
resourceArns: [this.inferenceProfileArn],
156156
});
157157
return grant;

src/cdk-lib/bedrock/models.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ export class BedrockFoundationModel implements IInvokable {
138138
/****************************************************************************
139139
* ANTHROPIC
140140
***************************************************************************/
141+
public static readonly ANTHROPIC_CLAUDE_3_7_SONNET_V1_0 = new BedrockFoundationModel(
142+
'anthropic.claude-3-7-sonnet-20250219-v1:0',
143+
{ supportsAgents: true, supportsCrossRegion: true },
144+
);
145+
141146
public static readonly ANTHROPIC_CLAUDE_3_5_SONNET_V2_0 = new BedrockFoundationModel(
142147
'anthropic.claude-3-5-sonnet-20241022-v2:0',
143148
{ supportsAgents: true, supportsCrossRegion: true },
@@ -293,7 +298,7 @@ export class BedrockFoundationModel implements IInvokable {
293298
public grantInvoke(grantee: IGrantable): Grant {
294299
const grant = Grant.addToPrincipal({
295300
grantee: grantee,
296-
actions: ['bedrock:InvokeModel'],
301+
actions: ['bedrock:InvokeModel*', 'bedrock:GetFoundationModel'],
297302
resourceArns: [this.invokableArn],
298303
});
299304
return grant;
@@ -315,7 +320,7 @@ export class BedrockFoundationModel implements IInvokable {
315320

316321
return Grant.addToPrincipal({
317322
grantee: grantee,
318-
actions: ['bedrock:InvokeModel'],
323+
actions: ['bedrock:InvokeModel*', 'bedrock:GetFoundationModel'],
319324
resourceArns: [invokableArn],
320325
});
321326
}

test/integ/inference-profiles.integ.snapshot/aws-cdk-bedrock-guardrails-integ-test.assets.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"version": "39.0.0",
33
"files": {
4-
"fc1142f404eb5443446b22592dc6d75ae8c80055bfb9474da78f4254ae394a4f": {
4+
"ea52821b2f897f4747652193704dc57b09f387d548e94159a698de2d27cca5ca": {
55
"source": {
66
"path": "aws-cdk-bedrock-guardrails-integ-test.template.json",
77
"packaging": "file"
88
},
99
"destinations": {
1010
"current_account-eu-central-1": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-eu-central-1",
12-
"objectKey": "fc1142f404eb5443446b22592dc6d75ae8c80055bfb9474da78f4254ae394a4f.json",
12+
"objectKey": "ea52821b2f897f4747652193704dc57b09f387d548e94159a698de2d27cca5ca.json",
1313
"region": "eu-central-1",
1414
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-eu-central-1"
1515
}

test/integ/inference-profiles.integ.snapshot/aws-cdk-bedrock-guardrails-integ-test.template.json

+14-5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@
4949
"PolicyDocument": {
5050
"Statement": [
5151
{
52-
"Action": "bedrock:InvokeModel",
52+
"Action": [
53+
"bedrock:InvokeModel*",
54+
"bedrock:GetFoundationModel"
55+
],
5356
"Effect": "Allow",
5457
"Resource": {
5558
"Fn::Join": [
@@ -178,7 +181,10 @@
178181
"PolicyDocument": {
179182
"Statement": [
180183
{
181-
"Action": "bedrock:InvokeModel",
184+
"Action": [
185+
"bedrock:InvokeModel*",
186+
"bedrock:GetFoundationModel"
187+
],
182188
"Effect": "Allow",
183189
"Resource": {
184190
"Fn::Join": [
@@ -196,7 +202,7 @@
196202
{
197203
"Action": [
198204
"bedrock:GetInferenceProfile",
199-
"bedrock:InvokeModel"
205+
"bedrock:InvokeModel*"
200206
],
201207
"Effect": "Allow",
202208
"Resource": {
@@ -368,7 +374,10 @@
368374
"PolicyDocument": {
369375
"Statement": [
370376
{
371-
"Action": "bedrock:InvokeModel",
377+
"Action": [
378+
"bedrock:InvokeModel*",
379+
"bedrock:GetFoundationModel"
380+
],
372381
"Effect": "Allow",
373382
"Resource": {
374383
"Fn::Join": [
@@ -386,7 +395,7 @@
386395
{
387396
"Action": [
388397
"bedrock:GetInferenceProfile",
389-
"bedrock:InvokeModel"
398+
"bedrock:InvokeModel*"
390399
],
391400
"Effect": "Allow",
392401
"Resource": {

test/integ/issue747.integ.snapshot/aws-cdk-bedrock-agents-integ-test.assets.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"version": "39.0.0",
33
"files": {
4-
"edce2cdca448655b4baa3a3f25397547640d54472ced24d6b7c09954e1b4a72c": {
4+
"7e760cbfec7bfb0f842abf3934b793e311a38bd24c9810f722b3e1b8ac300b23": {
55
"source": {
66
"path": "aws-cdk-bedrock-agents-integ-test.template.json",
77
"packaging": "file"
88
},
99
"destinations": {
1010
"current_account-eu-central-1": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-eu-central-1",
12-
"objectKey": "edce2cdca448655b4baa3a3f25397547640d54472ced24d6b7c09954e1b4a72c.json",
12+
"objectKey": "7e760cbfec7bfb0f842abf3934b793e311a38bd24c9810f722b3e1b8ac300b23.json",
1313
"region": "eu-central-1",
1414
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-eu-central-1"
1515
}

test/integ/issue747.integ.snapshot/aws-cdk-bedrock-agents-integ-test.template.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@
4949
"PolicyDocument": {
5050
"Statement": [
5151
{
52-
"Action": "bedrock:InvokeModel",
52+
"Action": [
53+
"bedrock:InvokeModel*",
54+
"bedrock:GetFoundationModel"
55+
],
5356
"Effect": "Allow",
5457
"Resource": {
5558
"Fn::Join": [
@@ -220,7 +223,10 @@
220223
"PolicyDocument": {
221224
"Statement": [
222225
{
223-
"Action": "bedrock:InvokeModel",
226+
"Action": [
227+
"bedrock:InvokeModel*",
228+
"bedrock:GetFoundationModel"
229+
],
224230
"Effect": "Allow",
225231
"Resource": {
226232
"Fn::Join": [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"version": "39.0.0",
3+
"files": {
4+
"1f9354e3c8c90e6a6e4f3adf164e2746481f44ff6494e937f784a37964b01274": {
5+
"source": {
6+
"path": "Claude37Test.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-us-east-1": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-us-east-1",
12+
"objectKey": "1f9354e3c8c90e6a6e4f3adf164e2746481f44ff6494e937f784a37964b01274.json",
13+
"region": "us-east-1",
14+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-us-east-1"
15+
}
16+
}
17+
}
18+
},
19+
"dockerImages": {}
20+
}

0 commit comments

Comments
 (0)