Skip to content

Commit d6e4859

Browse files
authored
Add support for stack and change set level hooks
* add special CFN stack hook targets to hook schema * WIP
1 parent a73666d commit d6e4859

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/rpdk/core/project.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@
153153

154154
MARKDOWN_RESERVED_CHARACTERS = frozenset({"^", "*", "+", ".", "(", "[", "{", "#"})
155155

156+
HOOK_SPECIAL_TARGET_NAMES = frozenset(("STACK", "CHANGE_SET"))
157+
156158

157159
def escape_markdown(string):
158160
"""Escapes the reserved Markdown characters."""
@@ -1314,6 +1316,11 @@ def _load_target_info(
13141316

13151317
LOG.debug("Hook schema target names: %s", str(target_names))
13161318

1319+
if self.artifact_type == ARTIFACT_TYPE_HOOK:
1320+
target_names = list(
1321+
filter(lambda x: x not in HOOK_SPECIAL_TARGET_NAMES, target_names)
1322+
)
1323+
13171324
if local_only:
13181325
targets = TypeNameResolver.resolve_type_names_locally(
13191326
target_names, local_info

tests/test_project.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2526,10 +2526,16 @@ def test__load_target_info_for_hooks(project):
25262526
project.schema = {
25272527
"handlers": {
25282528
"preCreate": {
2529-
"targetNames": ["AWS::TestHook::Target", "AWS::TestHook::OtherTarget"]
2529+
"targetNames": [
2530+
"AWS::TestHook::Target",
2531+
"AWS::TestHook::OtherTarget",
2532+
"STACK",
2533+
"CHANGE_SET",
2534+
]
25302535
},
25312536
"preUpdate": {
25322537
"targetNames": [
2538+
"CHANGE_SET",
25332539
"AWS::TestHookOne::Target",
25342540
"AWS::TestHookTwo::Target",
25352541
"AWS::ArrayHook::Target",

0 commit comments

Comments
 (0)