avatarTeri Radichel

Summarize

An Import Value in a Sub in AWS CloudFormation

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

⚙️ Check out my series on Automating Cybersecurity Metrics | Code.

🔒 Related Stories: Bugs | AWS Security | Secure Code | CloudFormation

💻 Free Content on Jobs in Cybersecurity | ✉️ Sign up for the Email List

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Just for the record: I have stopped using CloudFormation ImportValue due to too many issues trying to figure out the syntax, keeping the import and export names aligned, and because I am now working on a multi-account architecture. I opt for simply looking up and inserting the values as parameters instead with certain guardrails in the framework I’m building here:

I was having a hard time remembering how to use an sub with an import to reference a domain name in some output.

I found this old block of code that apparently worked before.

I don’t know if the issue I was having was the result of having an empty value in there or somehow a join would have helped em, but in any case, this works.

I passed in two parameters to a CloudFormation template. You have to use Fn::ImportValue with Sub (not !ImportValue). I really wish AWS would fix it so you could use the short version but anyway it doesn’t work.

In the case I was testing, I later realized my AWS CLI configuration was reverting to the incorrect region so a stack I was trying to reference did not exist. If that was the source of the problem — a null value or empty string due to a missing stack — AWS error messaging is absolutely unclear in that case.

At any rate, I’m noting this code for future reference when I need it next time.

Trying to use Sub with Import in CloudFormation is a constant source of wasted time in my experience. I know this works so hopefully it saves me time in the future!

This is also related to the following errors I got while troubleshooting the problem:

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
Error Message
Import Value
Sub
Cloudformation
Syntax
Recommended from ReadMedium