Init CodeCommit存储库,使用CDK存储在S3中的种子代码

发布于 2025-01-29 10:58:45 字数 2123 浏览 5 评论 0原文

我正在尝试转换用于建立模型,培训和部署的MLOP模板 cloudformation 模板模板 to cdk项目,因此我可以轻松地更新定义,合成模板并将其上传到< em> CloudCatalog 为了用作 sagemaker Studio 的项目模板。

不过,我是CDK的新手,并且尝试使用SageMaker Pipeline seed-code存储在 s3 s3 < s3 < /em>,在原始模板中完成如下:

  '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文档确实是指code参数 codecommit.repository 作为初始化选项,但仅用于压缩和上传的本地文件到 s3 等。那是因为它假设了CDK项目的部署,但是我只希望由cdk Synth生成的模板。

当然,我总是可以使用 codecommit.cfnrepository 及其代码参数要指向 s3 ,但随后我无法将其插入codepipeline's中阶段's 存储库参数,因为它期望irepository对象。

我也想坚持aws-cdk-lib.aws_codepipeline以掌握 cloudpipeline 的基本逻辑(我也很新),避免使用高级<代码> aws-cdk-lib.pipelines 。

关于如何实现这一目标的任何想法?

I'm trying to convert the MLOps template for model building, training, and deployment CloudFormation template into a CDK project so I can easily update the definitions, synth the template and upload it into CloudCatalog in order to be used as a project template in SageMaker Studio.

I'm quite new to CDK though, and I'm having some troubles trying to initialize a CodeCommit repository with the sagemaker pipeline seed-code stored in S3, which was accomplished as follows in the original template :

  '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'

The CDK API docs does refer to the code parameter in codecommit.Repository as an initialization option, but it's only for local files being compressed and uploaded to S3 and such. That's because it assumes a deployment of the CDK project, but I only want the template generated by cdk synth.

Of course I can always use codecommit.CfnRepository and its code parameter to point into S3, but then I cannot insert it in the codepipeline's stage codepipeline_actions.CodeCommitSourceAction's repository parameter because it expects an IRepository object.

I also want to stick to aws-cdk-lib.aws_codepipeline to grasp the fundamental logic of CloudPipeline (which I'm quite new too) and avoid using the high level aws-cdk-lib.pipelines.

Any ideas on how can I accomplish this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑红尘 2025-02-05 10:58:45

构建一个存储库没有代码 prop。获取 secave Hatch 引用其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许可。

Construct a Repository without a Code prop. Get an escape hatch reference to its L1 CfnRepository layer. Set the CfnRepository's property manually to the existing S3 bucket:

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',
});

The above code will synth the YAML output in the OP. Pass repo as the pipeline's source action.

Don't forget to grant the necessary IAM permissions on the S3 bucket.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文