Devops: AWS Cloudfront invalidation

I am trying to invalidate AWS CloudFront ID through gitlab pipelines. So after the code compiles, it is transferred to AWS S3 and now, we have to invalidate the CloudFront ID so that the updated website is opened.

When I go through terminal:
I first have to send this command "aws cloudfront create-invalidation --distribution-id $ID "
then an internal command opens – at this time, we have to send “–paths / /* /index.html”

If I join the two commands, it does not work. If I separate the commands in the YML file, then it fails