Matt Cremeens
Matt Cremeens

Reputation: 5151

Error: Template file not found at /builds/.../.../template.yml

I am running into this error when running my pipeline upon a merge into gitlab. My .gitlab-ci.yml file looks like this

image: python:3.12

stages:
  - deploy

production:
  stage: deploy
  before_script:
    - pip3 install awscli --upgrade
    - pip3 install aws-sam-cli --upgrade
  script:
    - sam build
    - sam package --output-template-file output.yaml --s3-bucket my-bucket-name
    - sam deploy --template-file output.yaml --stack-name sam-test-1 --capabilities CAPABILITY_IAM
  environment: production

My project is in the main repository directory under /lambda_functions/app/ which is also where the above file is along with my template.yaml file.

I've tried moving files around to see if they could be found but no luck. I've also tried renaming the extension of the template file to .yml instead of .yaml, but that did not make a difference. I have gitlab pointing to the correct .gitlab-ci.yml. All works fine when I deploy locally.

Again, the error is

Error: Template file not found at /builds/.../.../template.yml

Upvotes: 2

Views: 633

Answers (1)

Allan Chua
Allan Chua

Reputation: 10185

You need to change the working directory to the location of your template file.


image: python:3.12

stages:
  - deploy

production:
  stage: deploy
  before_script:
    - pip3 install awscli --upgrade
    - pip3 install aws-sam-cli --upgrade
  script:
    - cd lambda_functions/app
    - sam build
    - sam package --output-template-file output.yaml --s3-bucket my-bucket-name
    - sam deploy --template-file output.yaml --stack-name sam-test-1 --capabilities CAPABILITY_IAM
  environment: production

Upvotes: 2

Related Questions