Skip to content

Commit

Permalink
Update EC2 and EMR system tests to use IMDSv2 (apache#29003)
Browse files Browse the repository at this point in the history
The IMDSv2 metadata protocol is more secure than v1
  • Loading branch information
o-nikolas authored Jan 18, 2023
1 parent eaf5675 commit 5d84b59
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/system/providers/amazon/aws/example_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def create_instance(instance_name: str, key_pair_id: str):
InstanceType="t2.micro",
KeyName=key_pair_id,
TagSpecifications=[{"ResourceType": "instance", "Tags": [{"Key": "Name", "Value": instance_name}]}],
# Use IMDSv2 for greater security, see the following doc for more details:
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html
MetadataOptions={"HttpEndpoint": "enabled", "HttpTokens": "required"},
)["Instances"][0]["InstanceId"]

# Wait for it to exist
Expand Down
6 changes: 6 additions & 0 deletions tests/system/providers/amazon/aws/example_emr.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
"EnableApplicationScopedIAMRole": True,
},
},
# Use IMDSv2 for greater security, see the following doc for more details:
# https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-create-security-configuration.html
"InstanceMetadataServiceConfiguration": {
"MinimumInstanceMetadataServiceVersion": 2,
"HttpPutResponseHopLimit": 2,
},
}

# [START howto_operator_emr_steps_config]
Expand Down

0 comments on commit 5d84b59

Please sign in to comment.