Warning
Secrets management and distribution is a very tricky subject. Don't use tools like this that you find on the net without thoroughly understanding their risks. For example, using this as-is will result in a secret in your bash history. This script works for us because we have significant compensating controls in the environment where it runs. This may not work well or be allowed by your organiztion. I accept no liability if you use this code and it does something bad!
AWS accounts are a great way to enforce hard boundaries on infrastructure and the code that runs on it. However, that can often make it more difficult to manage things like secrets across accounts. This script helps with that by pushing a secret to the same location in secrets manager across several AWS accounts for a properly configured user or service.
Though it is a best practice to use a separate secret for each environment, that is often not possible with certain third parties or organizations. I typically require using at least one separate secret for production vs non-production environments with a separate secret for each environment being strongly preferred.