EC2.Client.
modify_image_attribute
(**kwargs)¶Modifies the specified attribute of the specified AMI. You can specify only one attribute at a time.
To specify the attribute, you can use the Attribute
parameter, or one of the following parameters: Description
, ImdsSupport
, or LaunchPermission
.
Images with an Amazon Web Services Marketplace product code cannot be made public.
To enable the SriovNetSupport enhanced networking attribute of an image, enable SriovNetSupport on an instance and create an AMI from the instance.
See also: AWS API Documentation
Request Syntax
response = client.modify_image_attribute(
Attribute='string',
Description={
'Value': 'string'
},
ImageId='string',
LaunchPermission={
'Add': [
{
'Group': 'all',
'UserId': 'string',
'OrganizationArn': 'string',
'OrganizationalUnitArn': 'string'
},
],
'Remove': [
{
'Group': 'all',
'UserId': 'string',
'OrganizationArn': 'string',
'OrganizationalUnitArn': 'string'
},
]
},
OperationType='add'|'remove',
ProductCodes=[
'string',
],
UserGroups=[
'string',
],
UserIds=[
'string',
],
Value='string',
DryRun=True|False,
OrganizationArns=[
'string',
],
OrganizationalUnitArns=[
'string',
],
ImdsSupport={
'Value': 'string'
}
)
The name of the attribute to modify.
Valid values: description
| imdsSupport
| launchPermission
A new description for the AMI.
The attribute value. The value is case-sensitive.
[REQUIRED]
The ID of the AMI.
A new launch permission for the AMI.
The Amazon Web Services account ID, organization ARN, or OU ARN to add to the list of launch permissions for the AMI.
Describes a launch permission.
The name of the group.
The Amazon Web Services account ID.
Constraints: Up to 10 000 account IDs can be specified in a single request.
The Amazon Resource Name (ARN) of an organization.
The Amazon Resource Name (ARN) of an organizational unit (OU).
The Amazon Web Services account ID, organization ARN, or OU ARN to remove from the list of launch permissions for the AMI.
Describes a launch permission.
The name of the group.
The Amazon Web Services account ID.
Constraints: Up to 10 000 account IDs can be specified in a single request.
The Amazon Resource Name (ARN) of an organization.
The Amazon Resource Name (ARN) of an organizational unit (OU).
Attribute
parameter is launchPermission
.Not supported.
The user groups. This parameter can be used only when the Attribute
parameter is launchPermission
.
The Amazon Web Services account IDs. This parameter can be used only when the Attribute
parameter is launchPermission
.
Attribute
parameter is description
or imdsSupport
.DryRunOperation
. Otherwise, it is UnauthorizedOperation
.The Amazon Resource Name (ARN) of an organization. This parameter can be used only when the Attribute
parameter is launchPermission
.
The Amazon Resource Name (ARN) of an organizational unit (OU). This parameter can be used only when the Attribute
parameter is launchPermission
.
Set to v2.0
to indicate that IMDSv2 is specified in the AMI. Instances launched from this AMI will have HttpTokens
automatically set to required
so that, by default, the instance requires that IMDSv2 is used when requesting instance metadata. In addition, HttpPutResponseHopLimit
is set to 2
. For more information, see Configure the AMI in the Amazon EC2 User Guide .
Warning
Do not use this parameter unless your AMI software supports IMDSv2. After you set the value to v2.0
, you can't undo it. The only way to “reset” your AMI is to create a new AMI from the underlying snapshot.
The attribute value. The value is case-sensitive.
None
Examples
This example makes the specified AMI public.
response = client.modify_image_attribute(
ImageId='ami-5731123e',
LaunchPermission={
'Add': [
{
'Group': 'all',
},
],
},
)
print(response)
Expected Output:
{
'ResponseMetadata': {
'...': '...',
},
}
This example grants launch permissions for the specified AMI to the specified AWS account.
response = client.modify_image_attribute(
ImageId='ami-5731123e',
LaunchPermission={
'Add': [
{
'UserId': '123456789012',
},
],
},
)
print(response)
Expected Output:
{
'ResponseMetadata': {
'...': '...',
},
}