Support alternate EC2:ModifyInstanceAttribute request syntax (#4234)
This commit is contained in:
parent
6f4b6080f8
commit
a1e415ec03
@ -177,6 +177,7 @@ class InstanceResponse(BaseResponse):
|
||||
|
||||
def modify_instance_attribute(self):
|
||||
handlers = [
|
||||
self._attribute_value_handler,
|
||||
self._dot_value_instance_attribute_handler,
|
||||
self._block_device_mapping_handler,
|
||||
self._security_grp_instance_attribute_handler,
|
||||
@ -258,6 +259,21 @@ class InstanceResponse(BaseResponse):
|
||||
)
|
||||
return EC2_MODIFY_INSTANCE_ATTRIBUTE
|
||||
|
||||
def _attribute_value_handler(self):
|
||||
attribute_key = self._get_param("Attribute")
|
||||
|
||||
if attribute_key is None:
|
||||
return
|
||||
|
||||
if self.is_not_dryrun("ModifyInstanceAttribute"):
|
||||
value = self._get_param("Value")
|
||||
normalized_attribute = camelcase_to_underscores(attribute_key)
|
||||
instance_id = self._get_param("InstanceId")
|
||||
self.ec2_backend.modify_instance_attribute(
|
||||
instance_id, normalized_attribute, value
|
||||
)
|
||||
return EC2_MODIFY_INSTANCE_ATTRIBUTE
|
||||
|
||||
def _security_grp_instance_attribute_handler(self):
|
||||
new_security_grp_list = []
|
||||
for key, value in self.querystring.items():
|
||||
|
@ -1775,8 +1775,9 @@ def test_instance_termination_protection():
|
||||
r"The instance '{}' may not be terminated.*$".format(instance_id)
|
||||
)
|
||||
|
||||
# Use alternate request syntax for setting attribute.
|
||||
client.modify_instance_attribute(
|
||||
InstanceId=instance_id, DisableApiTermination={"Value": False}
|
||||
InstanceId=instance_id, Attribute="disableApiTermination", Value="false"
|
||||
)
|
||||
client.terminate_instances(InstanceIds=[instance_id])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user