Lala
Lala

Reputation: 1

Why does my AWS CodeBuild project fail to create a CloudFormation stack with the error "Template file not found"?

I am working on automating the deployment of a static website using AWS CodePipeline and CodeBuild, along with CloudFormation. However, I am encountering some issues in my buildspec.yml configuration.

Failed phase message:

Error while executing command: aws cloudformation validate-template --template-body s3_static_web.yml. Reason: exit status 254

version: 0.2

phases:
  install:
    runtime-versions:
      python: 3.8  # Ensure Python is available

  pre_build:
    commands:
      - python --version  # Verify Python version
      - echo "Validating the CloudFormation template..."
      - aws cloudformation validate-template --template-body file:\\s3_static_web.yml

  build:
    commands:
      - echo "Packaging the CloudFormation template..."
      - aws cloudformation package --template-file s3_static_web.yml \
          --s3-bucket theabayacollection-bucket \
          --output-template-file packaged-s3_static_web.yml

  post_build:
    commands:
      - echo "Uploading website files to S3..."
      - aws s3 cp index.html s3://theabayacollection-bucket/index.html --acl bucket-owner-full-control
      - aws s3 cp error.html s3://theabayacollection-bucket/error.html --acl bucket-owner-full-control
      - echo "Files uploaded successfully."

artifacts:
  files:
    - '**/*'

Upvotes: 0

Views: 31

Answers (0)

Related Questions