CodePipeline unable to locate SAM template yaml file

Question:

I’m attempting to setup AWS Codepipeline with a Cloudformation SAM stack that deploys to a Lambda and am doing this via the Pipeline console. The pipeline passes the clone from Codecommit process and the build process with Codebuild, however fails on the deploy with Cloudformation.

I get the following error message:

Action execution failed
Invalid TemplatePath: MyAppBuild::samTemplate.yml

I’ve been following the documentation (http://docs.aws.amazon.com/lambda/latest/dg/automating-deployment.html) pretty closely and in field 16 of the codepipeline setup form (Template File) I have been putting samTemplate.yml.

I also have samTemplate.yml in the root of my repo (which is also the root of the project).

I’ve matched the Codebuild output artifact name with the Cloudformation input artifact name and they match exactly.

Am I missing something here? How do I get the Cloudformation deploy process to recognize the sam template?

EDIT 1 I’ve switched to using Codestar instead of directly using CodePipeline. Nothing special in my buildspec.yml, but it’s below if anyone’s interested.

One thing to keep in mind for anyone new to CodeBuild, the zip file that gets created as a result is of the root level directory of your build operations and IS the zip file that gets transferred to final deployment (in my case, Lambda).

Answer:

I believe the output of the build stage is what needs to be passed into the CloudFormation action.

In the tutorial the build output is called NewSamTemplate.yaml

So try updating your TemplatePath to MyAppBuild::NewSamTemplate.yml

Leave a Reply