Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle serverless pseudo params within cirrus re #139
- Loading branch information
Showing
2 changed files
with
37 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import re | ||
|
||
|
||
FN_SUB = 'Fn::Sub' | ||
PARAMS = re.compile(r'#{(AWS::[a-zA-Z]+)}') | ||
|
||
|
||
def replace_pseudo_params_with_sub(key, val): | ||
if not isinstance(val, str): | ||
return val | ||
|
||
val, subcount = PARAMS.subn(r'${\g<1>}', val) | ||
|
||
if subcount and key != FN_SUB: | ||
val = {FN_SUB: val} | ||
|
||
return val |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters