Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instance scale-in protection to Auto Scaling #2207

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

braydencw1
Copy link

SUMMARY
ISSUE TYPE
  • Bugfix Pull Request
  • Docs Pull Request
  • Feature Pull Request
  • New Module Pull Request
COMPONENT NAME
ADDITIONAL INFORMATION

Copy link

github-actions bot commented Jul 31, 2024

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/11156334037

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

File changes:

  • M collections/amazon/aws/autoscaling_group_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/autoscaling_group_module.html b/home/runner/work/amazon.aws/amazon.aws/docsbuild/head/collections/amazon/aws/autoscaling_group_module.html
index d6fbe0a..cef7dbf 100644
--- a/home/runner/work/amazon.aws/amazon.aws/docsbuild/base/collections/amazon/aws/autoscaling_group_module.html
+++ b/home/runner/work/amazon.aws/amazon.aws/docsbuild/head/collections/amazon/aws/autoscaling_group_module.html
@@ -557,6 +557,19 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-autoscal
 </div></td>
 </tr>
 <tr class="row-even"><td><div class="ansible-option-cell">
+<div class="ansibleOptionAnchor" id="parameter-protected_from_scale_in"></div><p class="ansible-option-title" id="ansible-collections-amazon-aws-autoscaling-group-module-parameter-protected-from-scale-in"><strong>protected_from_scale_in</strong></p>
+<a class="ansibleOptionLink" href="#parameter-protected_from_scale_in" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
+<p><em class="ansible-option-versionadded">added in amazon.aws 8.2.0</em></p>
+</div></td>
+<td><div class="ansible-option-cell"><p>If <code class="ansible-value docutils literal notranslate"><span class="pre">true</span></code>, instances will have scale-in protection enabled.</p>
+<p class="ansible-option-line"><strong class="ansible-option-choices">Choices:</strong></p>
+<ul class="simple">
+<li><p><code class="ansible-option-default-bold docutils literal notranslate"><strong><span class="pre">false</span></strong></code> <span class="ansible-option-choices-default-mark">← (default)</span></p></li>
+<li><p><code class="ansible-option-choices-entry docutils literal notranslate"><span class="pre">true</span></code></p></li>
+</ul>
+</div></td>
+</tr>
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-purge_tags"></div><p class="ansible-option-title" id="ansible-collections-amazon-aws-autoscaling-group-module-parameter-purge-tags"><strong>purge_tags</strong></p>
 <a class="ansibleOptionLink" href="#parameter-purge_tags" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
 <p><em class="ansible-option-versionadded">added in community.aws 3.2.0</em></p>
@@ -570,7 +583,7 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-autoscal
 </ul>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-region"></div>
 <div class="ansibleOptionAnchor" id="parameter-aws_region"></div>
 <div class="ansibleOptionAnchor" id="parameter-ec2_region"></div><p class="ansible-option-title" id="ansible-collections-amazon-aws-autoscaling-group-module-parameter-region"><span id="ansible-collections-amazon-aws-autoscaling-group-module-parameter-ec2-region"></span><span id="ansible-collections-amazon-aws-autoscaling-group-module-parameter-aws-region"></span><strong>region</strong></p>
@@ -585,7 +598,7 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-autoscal
 <p>Support for the <code class="docutils literal notranslate"><span class="pre">EC2_REGION</span></code> environment variable has been deprecated and will be removed in a release after 2024-12-01.</p>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-replace_all_instances"></div><p class="ansible-option-title" id="ansible-collections-amazon-aws-autoscaling-group-module-parameter-replace-all-instances"><strong>replace_all_instances</strong></p>
 <a class="ansibleOptionLink" href="#parameter-replace_all_instances" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
 </div></td>
@@ -597,7 +610,7 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-autoscal
 </ul>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-replace_batch_size"></div><p class="ansible-option-title" id="ansible-collections-amazon-aws-autoscaling-group-module-parameter-replace-batch-size"><strong>replace_batch_size</strong></p>
 <a class="ansibleOptionLink" href="#parameter-replace_batch_size" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">integer</span></p>
 </div></td>
@@ -605,7 +618,7 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-autoscal
 <p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-option-default docutils literal notranslate"><span class="pre">1</span></code></p>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-replace_instances"></div><p class="ansible-option-title" id="ansible-collections-amazon-aws-autoscaling-group-module-parameter-replace-instances"><strong>replace_instances</strong></p>
 <a class="ansibleOptionLink" href="#parameter-replace_instances" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">list</span> / <span class="ansible-option-elements">elements=string</span></p>
 </div></td>
@@ -613,7 +626,7 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-autoscal
 <p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-option-default docutils literal notranslate"><span class="pre">[]</span></code></p>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-secret_key"></div>
 <div class="ansibleOptionAnchor" id="parameter-aws_secret_access_key"></div>
 <div class="ansibleOptionAnchor" id="parameter-aws_secret_key"></div>
@@ -630,7 +643,7 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-autoscal
 <p>Support for the <code class="docutils literal notranslate"><span class="pre">EC2_SECRET_KEY</span></code> environment variable has been deprecated and will be removed in a release after 2024-12-01.</p>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-session_token"></div>
 <div class="ansibleOptionAnchor" id="parameter-aws_session_token"></div>
 <div class="ansibleOptionAnchor" id="parameter-security_token"></div>
@@ -648,7 +661,7 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-autoscal
 <p>Support for the <code class="docutils literal notranslate"><span class="pre">EC2_SECRET_KEY</span></code> and <code class="docutils literal notranslate"><span class="pre">AWS_SECURITY_TOKEN</span></code> environment variables has been deprecated and will be removed in a release after 2024-12-01.</p>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-state"></div><p class="ansible-option-title" id="ansible-collections-amazon-aws-autoscaling-group-module-parameter-state"><strong>state</strong></p>
 <a class="ansibleOptionLink" href="#parameter-state" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -660,7 +673,7 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-autoscal
 </ul>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-suspend_processes"></div><p class="ansible-option-title" id="ansible-collections-amazon-aws-autoscaling-group-module-parameter-suspend-processes"><strong>suspend_processes</strong></p>
 <a class="ansibleOptionLink" href="#parameter-suspend_processes" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">list</span> / <span class="ansible-option-elements">elements=string</span></p>
 </div></td>
@@ -672,7 +685,7 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-autoscal
 <p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-option-default docutils literal notranslate"><span class="pre">[]</span></code></p>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-tags"></div><p class="ansible-option-title" id="ansible-collections-amazon-aws-autoscaling-group-module-parameter-tags"><strong>tags</strong></p>
 <a class="ansibleOptionLink" href="#parameter-tags" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">list</span> / <span class="ansible-option-elements">elements=dictionary</span></p>
 </div></td>
@@ -682,14 +695,14 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-autoscal
 <p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-option-default docutils literal notranslate"><span class="pre">[]</span></code></p>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-target_group_arns"></div><p class="ansible-option-title" id="ansible-collections-amazon-aws-autoscaling-group-module-parameter-target-group-arns"><strong>target_group_arns</strong></p>
 <a class="ansibleOptionLink" href="#parameter-target_group_arns" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">list</span> / <span class="ansible-option-elements">elements=string</span></p>
 </div></td>
 <td><div class="ansible-option-cell"><p>List of target group ARNs to use for the group. Use for application load balancers.</p>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-termination_policies"></div><p class="ansible-option-title" id="ansible-collections-amazon-aws-autoscaling-group-module-parameter-termination-policies"><strong>termination_policies</strong></p>
 <a class="ansibleOptionLink" href="#parameter-termination_policies" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">list</span> / <span class="ansible-option-elements">elements=string</span></p>
 </div></td>
@@ -701,7 +714,7 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-autoscal
 <p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-option-default docutils literal notranslate"><span class="pre">[&quot;Default&quot;]</span></code></p>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-validate_certs"></div><p class="ansible-option-title" id="ansible-collections-amazon-aws-autoscaling-group-module-parameter-validate-certs"><strong>validate_certs</strong></p>
 <a class="ansibleOptionLink" href="#parameter-validate_certs" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
 </div></td>
@@ -714,14 +727,14 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-autoscal
 </ul>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-vpc_zone_identifier"></div><p class="ansible-option-title" id="ansible-collections-amazon-aws-autoscaling-group-module-parameter-vpc-zone-identifier"><strong>vpc_zone_identifier</strong></p>
 <a class="ansibleOptionLink" href="#parameter-vpc_zone_identifier" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">list</span> / <span class="ansible-option-elements">elements=string</span></p>
 </div></td>
 <td><div class="ansible-option-cell"><p>List of VPC subnets to use</p>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-wait_for_instances"></div><p class="ansible-option-title" id="ansible-collections-amazon-aws-autoscaling-group-module-parameter-wait-for-instances"><strong>wait_for_instances</strong></p>
 <a class="ansibleOptionLink" href="#parameter-wait_for_instances" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
 </div></td>
@@ -733,7 +746,7 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-autoscal
 </ul>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-wait_timeout"></div><p class="ansible-option-title" id="ansible-collections-amazon-aws-autoscaling-group-module-parameter-wait-timeout"><strong>wait_timeout</strong></p>
 <a class="ansibleOptionLink" href="#parameter-wait_timeout" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">integer</span></p>
 </div></td>

Copy link
Contributor

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

✔️ ansible-galaxy-importer SUCCESS in 4m 49s
✔️ build-ansible-collection SUCCESS in 10m 26s
✔️ ansible-test-splitter SUCCESS in 4m 13s
integration-amazon.aws-1 TIMED_OUT in 1h 00m 26s
Skipped 43 jobs

Copy link
Contributor

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

✔️ ansible-galaxy-importer SUCCESS in 4m 20s
✔️ build-ansible-collection SUCCESS in 10m 28s
✔️ ansible-test-splitter SUCCESS in 4m 15s
integration-amazon.aws-1 TIMED_OUT in 1h 00m 26s
Skipped 43 jobs

Copy link
Collaborator

@alinabuzachis alinabuzachis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@braydencw1 Thank you for taking time to work on this. Can you please add a changelog fragment https://docs.ansible.com/ansible/latest/community/development_process.html#creating-a-changelog-fragment for this change and cover it with some integration tests?

@alinabuzachis alinabuzachis added this to the 8.2.0 milestone Aug 22, 2024
@tremble tremble added the backport-8 PR should be backported to the stable-8 branch label Aug 28, 2024
Co-authored-by: Mark Chappell <[email protected]>
Copy link
Contributor

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

✔️ ansible-galaxy-importer SUCCESS in 7m 10s
✔️ build-ansible-collection SUCCESS in 10m 40s
✔️ ansible-test-splitter SUCCESS in 4m 15s
integration-amazon.aws-1 FAILURE in 50m 22s
Skipped 43 jobs

Copy link
Contributor

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

✔️ ansible-galaxy-importer SUCCESS in 5m 13s
✔️ build-ansible-collection SUCCESS in 10m 32s
✔️ ansible-test-splitter SUCCESS in 4m 15s
integration-amazon.aws-1 TIMED_OUT in 1h 00m 22s
Skipped 43 jobs

@braydencw1
Copy link
Author

@braydencw1 Thank you for taking time to work on this. Can you please add a changelog fragment https://docs.ansible.com/ansible/latest/community/development_process.html#creating-a-changelog-fragment for this change and cover it with some integration tests?

Anything else I need to do ??? Does the testing tend to fail out in some parts? Timing out on an integration test ?

Copy link
Contributor

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

✔️ ansible-galaxy-importer SUCCESS in 5m 07s
✔️ build-ansible-collection SUCCESS in 10m 34s
✔️ ansible-test-splitter SUCCESS in 4m 16s
integration-amazon.aws-1 FAILURE in 54m 23s
Skipped 43 jobs

Copy link
Contributor

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

✔️ ansible-galaxy-importer SUCCESS in 3m 54s
✔️ build-ansible-collection SUCCESS in 10m 49s
✔️ ansible-test-splitter SUCCESS in 4m 12s
integration-amazon.aws-1 TIMED_OUT in 1h 00m 24s
Skipped 43 jobs

Signed-off-by: Alina Buzachis <[email protected]>
Copy link
Contributor

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

✔️ ansible-galaxy-importer SUCCESS in 5m 22s
✔️ build-ansible-collection SUCCESS in 10m 34s
✔️ ansible-test-splitter SUCCESS in 4m 20s
integration-amazon.aws-1 FAILURE in 52m 45s
Skipped 43 jobs

Copy link
Contributor

@tremble tremble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just had a bit of a poke about in the code.

The integration test is failing because the update_size() code isn't actually being triggered, and as such nothing's actually being changed.

I think the handling of NewInstancesProtectedFromScaleIn needs to move into the (poorly named) create_autoscaling_group() function.

@alinabuzachis The more I look at this module, the more I fear we need to start splitting it up to be able to actually maintain it...

Copy link
Contributor

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

✔️ ansible-galaxy-importer SUCCESS in 4m 08s
✔️ build-ansible-collection SUCCESS in 10m 34s
✔️ ansible-test-splitter SUCCESS in 4m 18s
integration-amazon.aws-1 FAILURE in 22m 22s
Skipped 43 jobs

Copy link
Contributor

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

✔️ ansible-galaxy-importer SUCCESS in 4m 25s
✔️ build-ansible-collection SUCCESS in 10m 30s
✔️ ansible-test-splitter SUCCESS in 4m 41s
integration-amazon.aws-1 FAILURE in 15m 11s
Skipped 43 jobs

Copy link
Contributor

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

✔️ ansible-galaxy-importer SUCCESS in 4m 54s
✔️ build-ansible-collection SUCCESS in 10m 38s
✔️ ansible-test-splitter SUCCESS in 4m 47s
integration-amazon.aws-1 FAILURE in 59m 44s
Skipped 43 jobs

@tremble
Copy link
Contributor

tremble commented Oct 25, 2024

While this PR manages (or should manage) the default state of scale-in protection for newly created instances, with 9.0.0 we've added a new module autoscaling_instance (#2296) which supports managing the state for individual instances.

#2296 shouldn't be considered as "replacing" this PR, it is however related to this PR and may be of interest to anyone who comes across it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8 PR should be backported to the stable-8 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants