Getting the ARN or ID for A Resource Deployed With CloudFormation
ACM.361 Consistent naming conventions makes life easier again
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
⚙️ Check out my series on Automating Cybersecurity Metrics | Code.
🔒 Related Stories: AWS Security | Secure Code | Cybersecurity | IAM
💻 Free Content on Jobs in Cybersecurity | ✉️ Sign up for the Email List
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In the last post, as part of my code revamp, I fixed an issue that has been bugging me for a while. I used the role name that deployed a resource instead of the profile name and I explained why.
As part of my revamp to create environments for deploying applications in a consistent way, I want to call out another change I’m making to all my templates as I re-deploy them.
In almost every template I pass in a parameter called NameParam.
In almost every template I have outputs that provide the ARN or ID (depending on the resource). At first I was appending Export or something like that to the end of the outputs.
But what I decided later is that it’s just easier to have an output for every resource that is the resource name and it returns the ID or ARN, whichever is appropriate for that resource.
For example I changed my user template outputs to this:
I have functions that look up IDs by names using CloudFormation stacks such as AccountID that look like this:
Now if you think about it, I can look up the ARN or ID for any resource using the resource name if it was deployed by CloudFormation like this:
The get_stack_export function looks like this:
Instead of writing a function for every single resource to get the ID or ARN from an export, I can use my common function for all of them in my shared_functions.sh file.
Follow for updates.
Teri Radichel | © 2nd Sight Lab 2023
About Teri Radichel:
~~~~~~~~~~~~~~~~~~~~
⭐️ Author: Cybersecurity Books
⭐️ Presentations: Presentations by Teri Radichel
⭐️ Recognition: SANS Award, AWS Security Hero, IANS Faculty
⭐️ Certifications: SANS ~ GSE 240
⭐️ Education: BA Business, Master of Software Engineering, Master of Infosec
⭐️ Company: Penetration Tests, Assessments, Phone Consulting ~ 2nd Sight Lab
Need Help With Cybersecurity, Cloud, or Application Security?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
🔒 Request a penetration test or security assessment
🔒 Schedule a consulting call
🔒 Cybersecurity Speaker for Presentation
Follow for more stories like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
❤️ Sign Up my Medium Email List
❤️ Twitter: @teriradichel
❤️ LinkedIn: https://www.linkedin.com/in/teriradichel
❤️ Mastodon: @teriradichel@infosec.exchange
❤️ Facebook: 2nd Sight Lab
❤️ YouTube: @2ndsightlab