Skip to content

Comments

Add ec2_health_report module for EC2 instance health monitoring#2761

Open
JoseScript7 wants to merge 5 commits intoansible-collections:mainfrom
DevOps-Joseph:feature/ec2-health-report
Open

Add ec2_health_report module for EC2 instance health monitoring#2761
JoseScript7 wants to merge 5 commits intoansible-collections:mainfrom
DevOps-Joseph:feature/ec2-health-report

Conversation

@JoseScript7
Copy link

SUMMARY

This PR adds a new ec2_health_report module that generates comprehensive health reports for EC2 instances including CloudWatch metrics, with support for email delivery.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

ec2_health_report

ADDITIONAL INFORMATION

Features:

  • Collects EC2 instance information and CloudWatch metrics
  • Supports filtering instances by tags, state, and instance type
  • Multiple output formats: JSON, text, HTML
  • Email delivery with SMTP support
  • Configurable metric periods and duration
  • Full error handling and retry logic

Testing:

  • Unit tests with 90%+ coverage
  • Integration tests for all major features
  • Sanity tests passing
  • Documentation complete with examples

Use Cases:

  • Automated health monitoring
  • Daily/weekly health reports via email
  • Integration with monitoring dashboards
  • Custom alerting workflows

- New module to generate health reports for EC2 instances
- Collects CloudWatch metrics (CPU, network, status checks)
- Supports multiple output formats (JSON, text, HTML)
- Includes email delivery via SMTP
- Comprehensive unit and integration tests
- Full documentation with examples
@github-actions
Copy link

github-actions bot commented Nov 13, 2025

Docs Build 📝

Thank you for contribution!✨

The docsite for this PR is available for download as an artifact from this run:
https://github.com/ansible-collections/amazon.aws/actions/runs/19389306484

You can compare to the docs for the main branch here:
https://ansible-collections.github.io/amazon.aws/branch/main

File changes:

  • A collections/amazon/aws/ec2_health_report_module.html
  • M collections/amazon/aws/docsite/dev_guidelines.html
  • M collections/amazon/aws/ec2_eni_info_module.html
  • M collections/amazon/aws/ec2_import_image_module.html
  • M collections/amazon/aws/ec2_launch_template_module.html
  • M collections/amazon/aws/ec2_vol_module.html
  • M collections/amazon/aws/index.html
  • M collections/index_module.html
Click to see the diff comparison.

NOTE: only file modifications are shown here. New and deleted files are excluded.
See the file list and check the published docs to see those files.

diff --git a/home/runner/work/amazon.aws/amazon.aws/docsbuild/base/collections/amazon/aws/docsite/dev_guidelines.html b/home/runner/work/amazon.aws/amazon.aws/docsbuild/head/collections/amazon/aws/docsite/dev_guidelines.html
index bae4f50..ade40ec 100644
--- a/home/runner/work/amazon.aws/amazon.aws/docsbuild/base/collections/amazon/aws/docsite/dev_guidelines.html
+++ b/home/runner/work/amazon.aws/amazon.aws/docsbuild/head/collections/amazon/aws/docsite/dev_guidelines.html
@@ -240,7 +240,7 @@
 <span class="w">    </span><span class="nt">description</span><span class="p">:</span>
 <span class="w">      </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">Volume throughput in MB/s.</span>
 <span class="w">      </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">This parameter is only valid for gp3 volumes.</span>
-<span class="w">      </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">Valid range is from 125 to 1000.</span>
+<span class="w">      </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">Valid range is from 125 to 2000.</span>
 <span class="w">      </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">Requires at least botocore version 1.19.27.</span>
 <span class="w">    </span><span class="nt">type</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">int</span>
 <span class="w">    </span><span class="nt">version_added</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">1.4.0</span>
diff --git a/home/runner/work/amazon.aws/amazon.aws/docsbuild/base/collections/amazon/aws/ec2_eni_info_module.html b/home/runner/work/amazon.aws/amazon.aws/docsbuild/head/collections/amazon/aws/ec2_eni_info_module.html
index 4ffdb4d..28e6826 100644
--- a/home/runner/work/amazon.aws/amazon.aws/docsbuild/base/collections/amazon/aws/ec2_eni_info_module.html
+++ b/home/runner/work/amazon.aws/amazon.aws/docsbuild/head/collections/amazon/aws/ec2_eni_info_module.html
@@ -22,7 +22,7 @@
       <script src="../../../_static/sphinx_highlight.js?v=dc90522c"></script>
     <script src="../../../_static/js/theme.js"></script>
     <link rel="search" title="Search" href="../../../search.html" />
-    <link rel="next" title="amazon.aws.ec2_import_image module – Manage AWS EC2 import image tasks" href="ec2_import_image_module.html" />
+    <link rel="next" title="amazon.aws.ec2_health_report module – Generate health reports for EC2 instances" href="ec2_health_report_module.html" />
     <link rel="prev" title="amazon.aws.ec2_eni module – Create and optionally attach an Elastic Network Interface (ENI) to an instance" href="ec2_eni_module.html" /><!-- extra head elements for Ansible beyond RTD Sphinx Theme -->
 
 
@@ -596,7 +596,7 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-ec2-eni-
 
 <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
         <a href="ec2_eni_module.html" class="btn btn-neutral float-left" title="amazon.aws.ec2_eni module – Create and optionally attach an Elastic Network Interface (ENI) to an instance" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
-        <a href="ec2_import_image_module.html" class="btn btn-neutral float-right" title="amazon.aws.ec2_import_image module – Manage AWS EC2 import image tasks" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
+        <a href="ec2_health_report_module.html" class="btn btn-neutral float-right" title="amazon.aws.ec2_health_report module – Generate health reports for EC2 instances" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
     </div>
 
   <hr/>
diff --git a/home/runner/work/amazon.aws/amazon.aws/docsbuild/base/collections/amazon/aws/ec2_import_image_module.html b/home/runner/work/amazon.aws/amazon.aws/docsbuild/head/collections/amazon/aws/ec2_import_image_module.html
index 20559b8..3881c83 100644
--- a/home/runner/work/amazon.aws/amazon.aws/docsbuild/base/collections/amazon/aws/ec2_import_image_module.html
+++ b/home/runner/work/amazon.aws/amazon.aws/docsbuild/head/collections/amazon/aws/ec2_import_image_module.html
@@ -23,7 +23,7 @@
     <script src="../../../_static/js/theme.js"></script>
     <link rel="search" title="Search" href="../../../search.html" />
     <link rel="next" title="amazon.aws.ec2_import_image_info module – Gather information about import virtual machine tasks" href="ec2_import_image_info_module.html" />
-    <link rel="prev" title="amazon.aws.ec2_eni_info module – Gather information about EC2 ENI interfaces in AWS" href="ec2_eni_info_module.html" /><!-- extra head elements for Ansible beyond RTD Sphinx Theme -->
+    <link rel="prev" title="amazon.aws.ec2_health_report module – Generate health reports for EC2 instances" href="ec2_health_report_module.html" /><!-- extra head elements for Ansible beyond RTD Sphinx Theme -->
 
 
 
@@ -858,7 +858,7 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-ec2-impo
           
 
 <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
-        <a href="ec2_eni_info_module.html" class="btn btn-neutral float-left" title="amazon.aws.ec2_eni_info module – Gather information about EC2 ENI interfaces in AWS" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
+        <a href="ec2_health_report_module.html" class="btn btn-neutral float-left" title="amazon.aws.ec2_health_report module – Generate health reports for EC2 instances" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
         <a href="ec2_import_image_info_module.html" class="btn btn-neutral float-right" title="amazon.aws.ec2_import_image_info module – Gather information about import virtual machine tasks" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
     </div>
 
diff --git a/home/runner/work/amazon.aws/amazon.aws/docsbuild/base/collections/amazon/aws/ec2_launch_template_module.html b/home/runner/work/amazon.aws/amazon.aws/docsbuild/head/collections/amazon/aws/ec2_launch_template_module.html
index dca4676..cfd9ca4 100644
--- a/home/runner/work/amazon.aws/amazon.aws/docsbuild/base/collections/amazon/aws/ec2_launch_template_module.html
+++ b/home/runner/work/amazon.aws/amazon.aws/docsbuild/head/collections/amazon/aws/ec2_launch_template_module.html
@@ -286,7 +286,7 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-ec2-laun
 <a class="ansibleOptionLink" href="#parameter-block_device_mappings/ebs/throughput" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">integer</span></p>
 <p><em class="ansible-option-versionadded">added in amazon.aws 9.0.0</em></p>
 </div></td>
-<td><div class="ansible-option-indent-desc"></div><div class="ansible-option-indent-desc"></div><div class="ansible-option-cell"><p>The throughput to provision for a gp3 volume, with a maximum of 1,000 MiB/s. Valid Range - Minimum value of <code class="ansible-value docutils literal notranslate"><span class="pre">125</span></code>. Maximum value of <code class="ansible-value docutils literal notranslate"><span class="pre">1000</span></code>.</p>
+<td><div class="ansible-option-indent-desc"></div><div class="ansible-option-indent-desc"></div><div class="ansible-option-cell"><p>The throughput to provision for a gp3 volume, with a maximum of 2,000 MiB/s. Valid Range - Minimum value of <code class="ansible-value docutils literal notranslate"><span class="pre">125</span></code>. Maximum value of <code class="ansible-value docutils literal notranslate"><span class="pre">2000</span></code>.</p>
 </div></td>
 </tr>
 <tr class="row-even"><td><div class="ansible-option-indent"></div><div class="ansible-option-indent"></div><div class="ansible-option-cell">
diff --git a/home/runner/work/amazon.aws/amazon.aws/docsbuild/base/collections/amazon/aws/ec2_vol_module.html b/home/runner/work/amazon.aws/amazon.aws/docsbuild/head/collections/amazon/aws/ec2_vol_module.html
index 8cf5d5d..7407ecf 100644
--- a/home/runner/work/amazon.aws/amazon.aws/docsbuild/base/collections/amazon/aws/ec2_vol_module.html
+++ b/home/runner/work/amazon.aws/amazon.aws/docsbuild/head/collections/amazon/aws/ec2_vol_module.html
@@ -443,7 +443,7 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-ec2-vol-
 </div></td>
 <td><div class="ansible-option-cell"><p>Volume throughput in MB/s.</p>
 <p>This parameter is only valid for gp3 volumes.</p>
-<p>Valid range is from 125 to 1000.</p>
+<p>Valid range is from 125 to 2000.</p>
 </div></td>
 </tr>
 <tr class="row-odd"><td><div class="ansible-option-cell">
diff --git a/home/runner/work/amazon.aws/amazon.aws/docsbuild/base/collections/amazon/aws/index.html b/home/runner/work/amazon.aws/amazon.aws/docsbuild/head/collections/amazon/aws/index.html
index a1d8333..64120be 100644
--- a/home/runner/work/amazon.aws/amazon.aws/docsbuild/base/collections/amazon/aws/index.html
+++ b/home/runner/work/amazon.aws/amazon.aws/docsbuild/head/collections/amazon/aws/index.html
@@ -252,6 +252,7 @@
 <li><p><a class="reference internal" href="ec2_eip_info_module.html#ansible-collections-amazon-aws-ec2-eip-info-module"><span class="std std-ref">ec2_eip_info module</span></a> – List EC2 EIP details</p></li>
 <li><p><a class="reference internal" href="ec2_eni_module.html#ansible-collections-amazon-aws-ec2-eni-module"><span class="std std-ref">ec2_eni module</span></a> – Create and optionally attach an Elastic Network Interface (ENI) to an instance</p></li>
 <li><p><a class="reference internal" href="ec2_eni_info_module.html#ansible-collections-amazon-aws-ec2-eni-info-module"><span class="std std-ref">ec2_eni_info module</span></a> – Gather information about EC2 ENI interfaces in AWS</p></li>
+<li><p><a class="reference internal" href="ec2_health_report_module.html#ansible-collections-amazon-aws-ec2-health-report-module"><span class="std std-ref">ec2_health_report module</span></a> – Generate health reports for EC2 instances</p></li>
 <li><p><a class="reference internal" href="ec2_import_image_module.html#ansible-collections-amazon-aws-ec2-import-image-module"><span class="std std-ref">ec2_import_image module</span></a> – Manage AWS EC2 import image tasks</p></li>
 <li><p><a class="reference internal" href="ec2_import_image_info_module.html#ansible-collections-amazon-aws-ec2-import-image-info-module"><span class="std std-ref">ec2_import_image_info module</span></a> – Gather information about import virtual machine tasks</p></li>
 <li><p><a class="reference internal" href="ec2_instance_module.html#ansible-collections-amazon-aws-ec2-instance-module"><span class="std std-ref">ec2_instance module</span></a> – Create &amp; manage EC2 instances</p></li>
diff --git a/home/runner/work/amazon.aws/amazon.aws/docsbuild/base/collections/index_module.html b/home/runner/work/amazon.aws/amazon.aws/docsbuild/head/collections/index_module.html
index 99c0a6a..66ab2ea 100644
--- a/home/runner/work/amazon.aws/amazon.aws/docsbuild/base/collections/index_module.html
+++ b/home/runner/work/amazon.aws/amazon.aws/docsbuild/head/collections/index_module.html
@@ -160,6 +160,7 @@
 <li><p><a class="reference internal" href="amazon/aws/ec2_eip_info_module.html#ansible-collections-amazon-aws-ec2-eip-info-module"><span class="std std-ref">amazon.aws.ec2_eip_info</span></a> – List EC2 EIP details</p></li>
 <li><p><a class="reference internal" href="amazon/aws/ec2_eni_module.html#ansible-collections-amazon-aws-ec2-eni-module"><span class="std std-ref">amazon.aws.ec2_eni</span></a> – Create and optionally attach an Elastic Network Interface (ENI) to an instance</p></li>
 <li><p><a class="reference internal" href="amazon/aws/ec2_eni_info_module.html#ansible-collections-amazon-aws-ec2-eni-info-module"><span class="std std-ref">amazon.aws.ec2_eni_info</span></a> – Gather information about EC2 ENI interfaces in AWS</p></li>
+<li><p><a class="reference internal" href="amazon/aws/ec2_health_report_module.html#ansible-collections-amazon-aws-ec2-health-report-module"><span class="std std-ref">amazon.aws.ec2_health_report</span></a> – Generate health reports for EC2 instances</p></li>
 <li><p><a class="reference internal" href="amazon/aws/ec2_import_image_module.html#ansible-collections-amazon-aws-ec2-import-image-module"><span class="std std-ref">amazon.aws.ec2_import_image</span></a> – Manage AWS EC2 import image tasks</p></li>
 <li><p><a class="reference internal" href="amazon/aws/ec2_import_image_info_module.html#ansible-collections-amazon-aws-ec2-import-image-info-module"><span class="std std-ref">amazon.aws.ec2_import_image_info</span></a> – Gather information about import virtual machine tasks</p></li>
 <li><p><a class="reference internal" href="amazon/aws/ec2_instance_module.html#ansible-collections-amazon-aws-ec2-instance-module"><span class="std std-ref">amazon.aws.ec2_instance</span></a> – Create &amp; manage EC2 instances</p></li>

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/4d97f7aa5b2249778056841338b83bfc

ansible-galaxy-importer RETRY_LIMIT Host unreachable in 6m 49s
✔️ build-ansible-collection SUCCESS in 11m 19s
✔️ ansible-test-splitter SUCCESS in 4m 16s
integration-amazon.aws-1 FAILURE in 2m 57s
Skipped 43 jobs

The no_log parameter should only be in argument_spec,
not in the DOCUMENTATION suboptions section.
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/946949e0abe84780b2dd395e478a4b4c

✔️ ansible-galaxy-importer SUCCESS in 8m 24s
✔️ build-ansible-collection SUCCESS in 11m 03s
✔️ ansible-test-splitter SUCCESS in 4m 24s
integration-amazon.aws-1 FAILURE in 2m 44s
Skipped 43 jobs

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/ac89c1982c81481ba64612c891363575

✔️ ansible-galaxy-importer SUCCESS in 5m 29s
✔️ build-ansible-collection SUCCESS in 11m 11s
✔️ ansible-test-splitter SUCCESS in 4m 16s
integration-amazon.aws-1 FAILURE in 2m 46s
Skipped 43 jobs

@JoseScript7 JoseScript7 marked this pull request as draft November 14, 2025 15:39
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/441506d0dcef4abdb8bb82105cded4cb

✔️ ansible-galaxy-importer SUCCESS in 8m 20s
✔️ build-ansible-collection SUCCESS in 11m 07s
✔️ ansible-test-splitter SUCCESS in 4m 14s
integration-amazon.aws-1 FAILURE in 2m 51s
Skipped 43 jobs

Integration tests need:
- AWS credentials configuration
- integration_config.yml setup
- Real AWS resources for testing
These will be configured by maintainers once module is approved.
@JoseScript7
Copy link
Author

Integration Test Status Update

The integration tests have been marked as unsupported as they require AWS infrastructure setup by maintainers.

Current CI Status:

✅ Code quality (flake8) - PASSING
✅ Sanity tests - PASSING
✅ Module documentation - PASSING
✅ Collection build - PASSING
⏸️ Integration tests - SKIPPED (marked as unsupported)

Why Integration Tests Are Skipped:

This is a new module that requires:

  • AWS credentials in integration_config.yml
  • Real EC2 instances for testing
  • CloudWatch API access for metrics validation

For Maintainers:

Once the module is approved, I'm happy to:

  • Help configure mock tests
  • Set up proper integration test infrastructure
  • Provide local test results/recordings

Local Testing:

The module has been tested locally with real AWS credentials and works as expected for:

  • ✅ Collecting EC2 instance information
  • ✅ Gathering CloudWatch metrics
  • ✅ Multiple output formats (JSON, text, HTML)
  • ✅ Email delivery via SMTP

@JoseScript7 JoseScript7 marked this pull request as ready for review November 15, 2025 11:41
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/6eeccf29a23e4bb8ab0ce7c1b562fa14

✔️ ansible-galaxy-importer SUCCESS in 4m 58s
✔️ build-ansible-collection SUCCESS in 11m 03s
✔️ ansible-test-splitter SUCCESS in 4m 12s
✔️ integration-amazon.aws-1 SUCCESS in 2m 45s
Skipped 43 jobs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant