avatarTeri Radichel

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

1681

Abstract

Sub in AWS CloudFormation</h2> <div><h3>CloudFormation error messages and how to fix them.</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*4oxP4LXk8l8c3mpRvO7ejg.png)"></div> </div> </div> </a> </div><p id="6943">You have to use the long form Fn::ImportValue with !Sub.</p><p id="b439">Here’s what I was doing wrong. Do you see the problem?</p><div id="da34"><pre><span class="hljs-symbol">Role:</span> Fn:ImportValue: !<span class="hljs-keyword">Sub</span> <span class="hljs-string">"{NameParam}LambdaRole"</span></pre></div><p id="0749">This took me way too long.</p><div id="048e"><pre><span class="hljs-symbol">Role:</span> Fn::ImportValue: !<span class="hljs-keyword">Sub</span> <span class="hljs-string">"{NameParam}LambdaRole"</span></pre></div><p id="bba6">Do you see the difference now?</p><p id="bf32">I had one colon between Fn and ImportValue instead of two.</p><p id="f245">I have the following thoughts on this:</p><ol><li>Why doesn’t a sub just work inside an ImportValue function by default like this:</li></ol><div id="f6d0"><pre><span class="hljs-title function_">Fn::ImportValue</span> <span class="hljs-string">"<span class="hljs-variable">{NameParam}</span>LambdaRole"</span></pre></div><p id="1662">2. Why can’t I use the short form?</p><div id="fb81"><pre>!ImportValue <span class="hljs-string">"<span class="hljs-variable">{NameParam}</span>LambdaRole"</span></pre></div><p id="ad9e">3. The error message! Align the error messa

Options

ge to the problem please.</p><p id="b77e">#awswishlist</p><p id="8910">Follow for updates.</p><p id="4a3a">Teri Radichel | <i>© <a href="https://2ndsightlab.com/?source=post_page---------------------------">2nd Sight Lab</a> 2023</i></p><div id="8b5f"><pre><span class="hljs-section">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</pre></div><div id="caae"><pre><span class="hljs-section">Need Help With Cybersecurity, Cloud, or Application Security?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span>
🔒 Request a penetration test or security assessment
🔒 Schedule a consulting call
🔒 Cybersecurity Speaker for Presentation</pre></div><div id="81fb"><pre>Follow <span class="hljs-keyword">for</span> more stories like <span class="hljs-keyword">this</span>:

❤️ Sign Up my Medium Email List ❤️ Twitter: <span class="hljs-meta">@teriradichel</span> ❤️ LinkedIn: https:<span class="hljs-comment">//www.linkedin.com/in/teriradichel</span> ❤️ Mastodon: <span class="hljs-meta">@teriradichel</span><span class="hljs-meta">@infosec</span>.exchange ❤️ Facebook: 2nd Sight Lab ❤️ YouTube: @2ndsightlab</pre></div><figure id="7286"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*4oxP4LXk8l8c3mpRvO7ejg.png"><figcaption></figcaption></figure></article></body>

Properties validation failed for resource Lambda with message: #/Role: failed validation constraint for keyword [pattern]

A single character missing caused this error which doesn’t align with the actual problem

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

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

🔒 Related Stories: Bugs | AWS Security | Secure Code

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

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

I was getting this error and kept staring at it because I couldn’t see what the problem was. I used an ImportValue to get the ARN from the output value of the CloudFormation template that created a role.

I was also using the sub function — so a sub in side an ImportValue. I wrote about that here:

You have to use the long form Fn::ImportValue with !Sub.

Here’s what I was doing wrong. Do you see the problem?

Role:
   Fn:ImportValue:
      !Sub "${NameParam}LambdaRole"

This took me way too long.

Role:
   Fn::ImportValue:
      !Sub "${NameParam}LambdaRole"

Do you see the difference now?

I had one colon between Fn and ImportValue instead of two.

I have the following thoughts on this:

  1. Why doesn’t a sub just work inside an ImportValue function by default like this:
Fn::ImportValue "${NameParam}LambdaRole"

2. Why can’t I use the short form?

!ImportValue "${NameParam}LambdaRole"

3. The error message! Align the error message to the problem please.

#awswishlist

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
Bug
AWS
Cloudformation
Lambda
Importvalue
Recommended from ReadMedium