This is an automated email from the ASF dual-hosted git repository.

vincbeck pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new f83bf9366b Update `example_ec2` to Create Instance Which Supports 
Hibernation (#35790) (#35839)
f83bf9366b is described below

commit f83bf9366b1c8341c37ef9e3985343f70726c69a
Author: David <[email protected]>
AuthorDate: Tue Dec 5 10:23:07 2023 -0500

    Update `example_ec2` to Create Instance Which Supports Hibernation (#35790) 
(#35839)
---
 tests/system/providers/amazon/aws/example_ec2.py | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/tests/system/providers/amazon/aws/example_ec2.py 
b/tests/system/providers/amazon/aws/example_ec2.py
index aeffe4ad34..11320f1047 100644
--- a/tests/system/providers/amazon/aws/example_ec2.py
+++ b/tests/system/providers/amazon/aws/example_ec2.py
@@ -50,11 +50,20 @@ def get_latest_ami_id():
     # on how they name the new images.  This page should have AL2022 info when
     # it comes available: https://aws.amazon.com/linux/amazon-linux-2022/faqs/
     image_prefix = "Amazon Linux*"
+    root_device_name = "/dev/xvda"
 
     images = boto3.client("ec2").describe_images(
         Filters=[
             {"Name": "description", "Values": [image_prefix]},
-            {"Name": "architecture", "Values": ["arm64"]},
+            {
+                "Name": "architecture",
+                "Values": ["x86_64"],
+            },  # t3 instances are only compatible with x86 architecture
+            {
+                "Name": "root-device-type",
+                "Values": ["ebs"],
+            },  # instances which are capable of hibernation need to use an 
EBS-backed AMI
+            {"Name": "root-device-name", "Values": [root_device_name]},
         ],
         Owners=["amazon"],
     )
@@ -97,7 +106,7 @@ with DAG(
     image_id = get_latest_ami_id()
 
     config = {
-        "InstanceType": "t4g.micro",
+        "InstanceType": "t3.micro",
         "KeyName": key_name,
         "TagSpecifications": [
             {"ResourceType": "instance", "Tags": [{"Key": "Name", "Value": 
instance_name}]}
@@ -106,6 +115,9 @@ with DAG(
         # 
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html
         "MetadataOptions": {"HttpEndpoint": "enabled", "HttpTokens": 
"required"},
         "HibernationOptions": {"Configured": True},
+        "BlockDeviceMappings": [
+            {"DeviceName": "/dev/xvda", "Ebs": {"Encrypted": True, 
"DeleteOnTermination": True}}
+        ],
     }
 
     # EC2CreateInstanceOperator creates and starts the EC2 instances. To test 
the EC2StartInstanceOperator,
@@ -151,6 +163,7 @@ with DAG(
         instance_ids=instance_id,
     )
     # [END howto_operator_ec2_reboot_instance]
+    reboot_instance.wait_for_completion = True
 
     # [START howto_operator_ec2_hibernate_instance]
     hibernate_instance = EC2HibernateInstanceOperator(
@@ -158,6 +171,8 @@ with DAG(
         instance_ids=instance_id,
     )
     # [END howto_operator_ec2_hibernate_instance]
+    hibernate_instance.wait_for_completion = True
+    hibernate_instance.max_attempts = 75
 
     # [START howto_operator_ec2_terminate_instance]
     terminate_instance = EC2TerminateInstanceOperator(

Reply via email to