@@ -67,7 +67,10 @@ def _process_resources(self, resources: List[Dict], show_changes: bool = False,
6767 'identifier' : resource ['identifier' ],
6868 'action' : resource ['action' ],
6969 'provider' : resource .get ('provider' , 'unknown' ),
70- 'module' : resource .get ('module' , 'root' )
70+ 'module' : resource .get ('module' , 'root' ),
71+ # Add replacement and triggers for reporting
72+ 'replacement' : resource .get ('replacement' , False ),
73+ 'replacement_triggers' : resource .get ('replacement_triggers' , []),
7174 }
7275
7376 # Process changes if requested
@@ -102,7 +105,9 @@ def _process_resources(self, resources: List[Dict], show_changes: bool = False,
102105 'raw' : {
103106 'before' : resource .get ('before' , {}),
104107 'after' : resource .get ('after' , {})
105- }
108+ },
109+ # Add replacement triggers to details if present
110+ 'replacement_triggers' : resource .get ('replacement_triggers' , [])
106111 }
107112
108113 processed_resources .append (resource_data )
@@ -140,9 +145,9 @@ def _print_summary(self, report: Dict) -> None:
140145 """Format the change summary section."""
141146 self ._write (f"\n { self ._colorize ('Total Changes: ' + str (report ['total_changes' ]), 'bold' )} \n " )
142147
143- # Add change counts by type
148+ # Add change counts by type (do not show 'replace' in summary)
144149 for action in ['create' , 'update' , 'delete' ]:
145- count = report ['change_breakdown' ][ action ]
150+ count = report ['change_breakdown' ]. get ( action , 0 )
146151 self ._write (f"{ action .title ()} : { count } \n " )
147152
148153 def _print_resource_details (self , resources : list , show_changes : bool = False ) -> None :
@@ -153,7 +158,8 @@ def _print_resource_details(self, resources: list, show_changes: bool = False) -
153158 action_colors = {
154159 'CREATE' : 'green' ,
155160 'UPDATE' : 'blue' ,
156- 'DELETE' : 'red'
161+ 'DELETE' : 'red' ,
162+ 'REPLACE' : 'yellow' ,
157163 }
158164
159165 for resource in resources :
@@ -164,9 +170,14 @@ def _print_resource_details(self, resources: list, show_changes: bool = False) -
164170 f"\n { colored_action } { resource ['resource_type' ]} : "
165171 f"{ resource ['identifier' ]} \n "
166172 )
167-
173+ # Show replacement triggers if this is a replacement
174+ if resource .get ('replacement' , False ) and resource .get ('replacement_triggers' ):
175+ triggers = ', ' .join (resource ['replacement_triggers' ])
176+ self ._write (f" Replacement triggered by: { triggers } \n " )
168177 if show_changes :
169178 self ._print_attribute_changes (resource )
179+ # Ensure a newline at the end to avoid shell prompt artifacts
180+ self ._write ("\n " )
170181
171182 def _print_attribute_changes (self , resource : Dict ) -> None :
172183 """Format attribute changes for a resource."""
@@ -182,7 +193,8 @@ def _print_attribute_changes(self, resource: Dict) -> None:
182193 symbol_colors = {
183194 '+' : 'green' , # create
184195 '~' : 'blue' , # update
185- '-' : 'red' # delete
196+ '-' : 'red' , # delete
197+ '-/+' : 'yellow' # replace
186198 }
187199
188200 for attr in sorted (all_attrs - skip_attrs ):
@@ -196,9 +208,12 @@ def _print_attribute_changes(self, resource: Dict) -> None:
196208 elif resource ['action' ] == 'delete' :
197209 symbol = self ._colorize ('-' , symbol_colors ['-' ])
198210 lines .append (f" { symbol } { attr } = { before_val } " )
199- else : # update
211+ elif resource [ 'action' ] == ' update' :
200212 symbol = self ._colorize ('~' , symbol_colors ['~' ])
201213 lines .append (f" { symbol } { attr } = { before_val } -> { after_val } " )
214+ elif resource ['action' ] == 'replace' :
215+ symbol = self ._colorize ('-/+' , symbol_colors ['-/+' ])
216+ lines .append (f" { symbol } { attr } = { before_val } -> { after_val } " )
202217
203218 self ._write ('\n ' .join (lines ))
204219
0 commit comments