-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat(stepfunctions-tasks): bedrock createModelCustomizationJob integration #31913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(stepfunctions-tasks): bedrock createModelCustomizationJob integration #31913
Conversation
…e-model-customization-job.ts Co-authored-by: Luca Pizzini <lpizzini7@gmail.com>
…e-model-customization-job.ts Co-authored-by: Luca Pizzini <lpizzini7@gmail.com>
…e-model-customization-job.ts Co-authored-by: Luca Pizzini <lpizzini7@gmail.com>
@gracelu0 I'm really sorry for my late response. I've addressed all of your comments. Could you please reconfirm again? |
/** | ||
* The key/value pair for a tag. | ||
*/ | ||
export interface ITag { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using the I
prefix for interface names unless the interface is specifically intended to represent behavior. Reference: jsii Specification – Interfaces vs Structs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, the interface name is too generic. It would be better to either place it within a relevant namespace or give it a more descriptive name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated to CustomModelTag
.
this._role = this.renderBedrockCreateModelCustomizationJobRole(); | ||
this.taskPolicies = this.renderPolicyStatements(); | ||
|
||
if (this.props.customModelKmsKey) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's important to note that addToResourcePolicy has no effect when used on a KMS key imported via fromKeyArn.
Reference: aws-cdk-lib/aws-kms/key.ts#L163.
It's recommended to check the return value of the method to ensure the policy was actually applied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which is better to throw error or show warnings when customModelKmsKey
is imported key? For now, I have implemented it to display warnings.
if (this.props.customModelKmsKey) {
const poliyStatement = new iam.PolicyStatement({
actions: ['kms:Decrypt', 'kms:GenerateDataKey', 'kms:DescribeKey', 'kms:CreateGrant'],
resources: ['*'],
principals: [new iam.ArnPrincipal(this._role.roleArn)],
conditions: {
StringEquals: {
'kms:ViaService': [
`bedrock.${Stack.of(this).region}.amazonaws.com`,
],
},
},
});
const result = this.props.customModelKmsKey.addToResourcePolicy(poliyStatement, true);
// For the imported key, user must add the policy statement to the key policy
if (result.statementAdded === false) {
Annotations.of(this).addWarning(`You must update 'customModelKmsKey' resource policy to add the following statement:
${poliyStatement.toString()}`);
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the PR. I haven’t worked with this Bedrock job much before, but here’s my take: if missing permissions on the KMS key ultimately cause the job to fail, we should throw an exception to follow the fail-fast principle. On the other hand, if the lack of permission doesn’t block the job from running, then a warning message should suffice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I've updated the implementation to throw an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, could you help me resolve the build errors of unused imports?
@5d Thank you for your review!! I've addressed your comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for your effort on this!
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Comments on closed issues and PRs are hard for our team to see. |
This PR was previously created and passed the community review, but the maintainer review stopped midway, and it was eventually closed. There shouldn’t be any issues with the content, so I am submitting the PR again.
Issue # (if applicable)
Closes #29042
Reason for this change
AWS stepfunctions support optimized integration with AWS bedrock.
Currently, only invokeModel is supported by CDK, but I would like createModelCustomizationJob to be supported in the same manner.
Description of changes
I've added CreatemodelCustomizationJob class.
Description of how you validated changes
I've added both unit and integ tests.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license