Have a website deployed on AWS Amplify using that calls a lambda function to connect with stripe. Everything was working until i decided to push my code to github. I was then alerted i couldnt push files with sensitive API keys ( my mistake i know ). So then i changed it with a .env file to try to push it again but then i was alerted it was still in the commit history. I asked chat GPT what to do and it told me i had to 'remove the API key from the commit history to comply with GitHub's security checks'. one of the steps was the following
Rewrite Git History to Remove the Key: Run this command to remove the file from all previous commits:
git filter-branch --force --index-filter \
git rm --cached --ignore-unmatch amplify/team-provider-info.json" \
--prune-empty --tag-name-filter cat -- --all
This command removes the file from your commit history without affecting the rest of the project files
Force-Push to GitHub: Push the cleaned history to GitHub:
git push origin main --force
I was then hit with this error in my amplify deployment logs
ā There was an error initializing your environment.
43
2024-11-02T01:36:14.491Z [INFO]: š No CloudFormation
template found at
/codebuild/output/src3605424703/src/Fictional-
records/amplify/backend/function/stripeCheckout
/stripeCheckout-cloudformation-template.json
Currently I have tried
'amplify push' got
There was an error pulling the backend environment main
amplify function update
Cant really undo the commit since technically the file never got pushed to github
If anyone as any idea of whats going on please let me know im not sure what exactly was deleted or how to get things back to normal
Figured it out just had to delete my whole amplify folder and configuration and reconfigure amplify to the application. The git command above actually accidentally deleted my cloud formation template I believe