The AWS CLI comes with a useful subcommand to validate a CloudFormation template.
Simply run the following to validate a CloudFormation template file:
aws cloudformation validate-template --template-body file://cf-infra.yaml
Remember to swap out cf-infra.yaml
with your CloudFormation template file.