我正在嘗試將用于模型構建、訓練和部署 CloudFormation 模板的 MLOps 模板 轉換為 CDK 專案,以便我可以輕松更新定義、合成模板并將其上傳到CloudCatalog以便在SageMaker中用作專案模板作業室。
不過,我對 CDK 還是很陌生,嘗試使用存盤在S3中的 sagemaker 管道初始化CodeCommit存盤庫時遇到了一些麻煩,這在原始模板中完成如下:seed-code
'ModelBuildCodeCommitRepository':
'Type': 'AWS::CodeCommit::Repository'
'Properties':
'RepositoryName':
'Fn::Sub': 'sagemaker-${SageMakerProjectName}-${SageMakerProjectId}-modelbuild'
'RepositoryDescription':
'Fn::Sub': 'SageMaker Model building workflow infrastructure as code for the
Project ${SageMakerProjectName}'
'Code':
'S3':
'Bucket': 'sagemaker-servicecatalog-seedcode-sa-east-1'
'Key': 'toolchain/model-building-workflow-v1.0.zip'
'BranchName': 'main'
CDK API 檔案確實將codecommit.Repositorycode中的引數作為初始化選項,但它僅適用于本地檔案被壓縮并上傳到S3等。那是因為它假設部署了 CDK 專案,但我只想要.cdk synth
當然,我總是可以使用codecommit.CfnRepository及其code引數指向S3,但是我不能將它插入到codepipeline階段codepipeline_actions.CodeCommitSourceAction的repository引數中,因為它需要一個IRepository物件。
我也想堅持aws-cdk-lib.aws_codepipeline掌握CloudPipeline的基本邏輯(我也很新),避免使用高級別的aws-cdk-lib.pipelines.
關于如何做到這一點的任何想法?
uj5u.com熱心網友回復:
構造一個Repository沒有Code道具的。獲取對其 L1層的逃生艙口參考。CfnRepository手動將CfnRepository' 屬性設定為現有的 S3 存盤桶:
const repo = new codecommit.Repository(this, 'Repo', { repositoryName: 'my-great-repo' });
const cfnRepo = repo.node.defaultChild as codecommit.CfnRepository;
cfnRepo.addPropertyOverride('Code', {
S3: {
Bucket: 'sagemaker-servicecatalog-seedcode-sa-east-1',
Key: 'toolchain/model-building-workflow-v1.0.zip',
},
BranchName: 'main',
});
上面的代碼將在 OP 中合成 YAML 輸出。repo作為管道的源操作傳遞。
不要忘記在 S3 存盤桶上授予必要的 IAM 權限。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/475824.html
標籤:亚马逊-s3 aws-cdk aws-codepipeline aws-codecommit aws-管道
下一篇:如何創建與文字正確連接的檔案?
