Is it Safe to Hardcode AWS Secret Names and ARNs in My Repo?

August 25, 2025 5 answers
Asked by Vireo
I'm currently using AWS Secrets Manager to manage my secrets, but I've hardcoded the secret names and ARNs for resources like Secrets Manager, IAM, and Lambdas directly in my GitHub repo. Is this a bad practice? What kinds of risks might I face if someone gets access to these secret names and ARNs?

Answers

unmute perhaps
ARNs by themselves aren't sensitive, they're just identifiers for resources. But exposing them isnโ€™t ideal, even in a private repo. It would be smarter to store them in a configuration file rather than hardcoding them.
Reply to this answer
mural.restoration
While ARNs are not credentials, they do reveal a lot about your infrastructure, making it easier for someone to see how your app relies on various services. A best practice is to use environment variables. If youโ€™re using Terraform, you can define the secrets and Lambda in the same stack and pass the secret's ARN to the Lambda's config as an environment variable.

Mirthy: Exactly, and keeping things like that in environment variables can help maintain security and cleanliness in your code.

Reply to this answer
!8 corners beveled
Itโ€™s fine to have them hardcoded for convenience, but ideally, use argument passing instead to avoid hardcoding sensitive data.
Reply to this answer
_tram_driver
I wouldn't recommend adding them to source control if you can avoid it. If someone intends to compromise you, having secret ARNs in source control is basically handing over information. Once you have an account number, it opens doors for testing misconfigured IAM roles, etc. Weโ€™ve migrated to using AWS SDK/Boto to fetch secrets based on tags instead of hardcoding anything. That's a safer approach!
Reply to this answer
!show your work
It's generally alright, as ARNs aren't sensitive info. As long as your IAM configurations are tight, you should be okay. Just remember, if someone compromises your account or a user with access, that could lead to issues. Often, if a user has access to the secrets, they need permission to list them too, so exposing them isn't a huge concern as long as your overall security is strong.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions