it will work in localhost if your environment is set. basically, if you used aws cli and configured the cli tools. you can check if you have ~/.aws/credentials if you have that, i think your local environment was able to pick that up and use the credentials there