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

Aucune réponse

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions