Migration to cdk: How to include existing Serverless::Function yaml files in cdk codepipeline

1

We have several yaml files that contain Type: AWS::Serverless::Function and CodeUri: ../some-module/dist/. We deploy these using CLI and the following commands:

aws cloudformation package --template input.yaml --output-template-file /build/output.yaml --s3-bucket <some-bucket> --s3-prefix <some path>
aws cloudformation deploy --template-file /build/output.yaml --stack-name <some stack>  --capabilities CAPABILITY_NAMED_IAM  --parameter-overrides <parameters>

We are in the process of migrating to CDK2 and CodePipeline, and as a first step we just want to reuse the existing yaml files in CDK2.

When we include the original yaml file using:

new CfnInclude(this, 'stack', {
  templateFile: 'input.yaml',
  parameters
});

We get the following error message:

Transform AWS::Serverless failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [X] is invalid. 'CodeUri' is not a valid S3 Uri of the form 's3://bucket/key' with optional versionId query parameter.

The way we interpret this is that the package step that we do when we're using CLI is not happening automatically when we just include the original yaml with CfnInclude, and we are doing it wrong.

What is the proper way to include such yaml file in CDK2?

Thanks in advance :) -wab

답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠