diff --git a/cfn_review_bot/cfn.py b/cfn_review_bot/cfn.py index 4ae87e9..17a5d76 100644 --- a/cfn_review_bot/cfn.py +++ b/cfn_review_bot/cfn.py @@ -203,6 +203,9 @@ def wait_for_ready(self, target): for change_set in target.change_sets: self.wait_for_change_set(change_set) + if change_set.is_noop: + target.analysis_results.stack_summary.noop += 1 + def wait_for_change_set(self, change_set: ChangeSet): if change_set.id is None: return diff --git a/cfn_review_bot/main.py b/cfn_review_bot/main.py index 310ca5a..4be52fc 100644 --- a/cfn_review_bot/main.py +++ b/cfn_review_bot/main.py @@ -110,22 +110,26 @@ def _main(): targets=params.target, regions=params.region, stacks=params.stack)) for target in targets: - print(target.header, file=sys.stderr, flush=True) + print(target.header + ' [ANALYSING]', file=sys.stderr, flush=True) target.cfn_session = setup_session( target, session, session_prefix, params.project) target.cfn_session.analyse_target(target) if not params.dry_run: + print(target.header + ' [PREPARING CHANGE SETS]', file=sys.stderr, flush=True) target.cfn_session.prepare_change_sets(target) + if not params.dry_run: + for target in targets: + print(target.header + ' [WAITING FOR CHANGE SETS]', file=sys.stderr, flush=True) + target.cfn_session.wait_for_ready(target) + + for target in targets: + print(target.header, file=sys.stderr, flush=True) print(target, file=sys.stderr, flush=True) if params.markdown_summary: - if not params.dry_run: - for target in targets: - target.cfn_session.wait_for_ready(target) - print(markdown.summary(targets), end='', flush=True) diff --git a/cfn_review_bot/model.py b/cfn_review_bot/model.py index 440af8a..63014cf 100644 --- a/cfn_review_bot/model.py +++ b/cfn_review_bot/model.py @@ -113,6 +113,7 @@ class StackStats: adopted: int = 0 orphaned: int = 0 unmanaged: int = 0 + noop: int = 0 def __str__(self): parts = [] @@ -123,6 +124,8 @@ def __str__(self): parts += [f'{self.updated} updated'] if self.adopted: parts[-1] += f' ({self.adopted} adopted)' + if self.noop: + parts[-1] += f', {self.noop} with no-op changes' if self.orphaned: parts += [f'{self.orphaned} orphaned'] @@ -228,6 +231,8 @@ def __str__(self): lines += [' (change set was not created)'] else: lines += [f' {change_set.id}'] + if change_set.is_noop: + lines[-1] += ' [NO-OP]' lines += [''] diff --git a/cfn_review_bot/templates/summary.md b/cfn_review_bot/templates/summary.md index ef0fc23..d6bef38 100644 --- a/cfn_review_bot/templates/summary.md +++ b/cfn_review_bot/templates/summary.md @@ -18,12 +18,12 @@ {% if target.analysis_results.failed_stacks %} **Failed Stacks:** `{{ '`, `'.join(target.analysis_results.failed_stacks) }}` {% endif %} -{% for change_set in target.change_sets %} +{% for change_set in target.change_sets if not change_set.is_noop %} {% if loop.first %} {% endif %}
-{% if change_set.is_failed %}{{ ':woman_shrugging:' if change_set.is_noop else ':x:' }}{% endif %}{{ ':sparkles:' if change_set.type == change_set.type.CREATE }}{{ change_set.detail.StackName }} [change set] +{% if change_set.is_failed %}:x:{% endif %}{{ ':sparkles:' if change_set.type == change_set.type.CREATE }}{{ change_set.detail.StackName }} [change set] {% if change_set.detail.Status != 'CREATE_COMPLETE' %} #### Change Set Status: `{{ change_set.detail.Status }}`