- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
ModifyImageAttributeCommand
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.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { EC2Client, ModifyImageAttributeCommand } from "@aws-sdk/client-ec2"; // ES Modules import
// const { EC2Client, ModifyImageAttributeCommand } = require("@aws-sdk/client-ec2"); // CommonJS import
const client = new EC2Client(config);
const input = { // ModifyImageAttributeRequest
Attribute: "STRING_VALUE",
Description: { // AttributeValue
Value: "STRING_VALUE",
},
ImageId: "STRING_VALUE", // required
LaunchPermission: { // LaunchPermissionModifications
Add: [ // LaunchPermissionList
{ // LaunchPermission
OrganizationArn: "STRING_VALUE",
OrganizationalUnitArn: "STRING_VALUE",
UserId: "STRING_VALUE",
Group: "all",
},
],
Remove: [
{
OrganizationArn: "STRING_VALUE",
OrganizationalUnitArn: "STRING_VALUE",
UserId: "STRING_VALUE",
Group: "all",
},
],
},
OperationType: "add" || "remove",
ProductCodes: [ // ProductCodeStringList
"STRING_VALUE",
],
UserGroups: [ // UserGroupStringList
"STRING_VALUE",
],
UserIds: [ // UserIdStringList
"STRING_VALUE",
],
Value: "STRING_VALUE",
OrganizationArns: [ // OrganizationArnStringList
"STRING_VALUE",
],
OrganizationalUnitArns: [ // OrganizationalUnitArnStringList
"STRING_VALUE",
],
ImdsSupport: {
Value: "STRING_VALUE",
},
DryRun: true || false,
};
const command = new ModifyImageAttributeCommand(input);
const response = await client.send(command);
// {};
Example Usage
ModifyImageAttributeCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
ImageId Required | string | undefined | The ID of the AMI. |
Attribute | string | undefined | The name of the attribute to modify. Valid values: |
Description | AttributeValue | undefined | A new description for the AMI. |
DryRun | boolean | undefined | Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is |
ImdsSupport | AttributeValue | undefined | Set to Do not use this parameter unless your AMI software supports IMDSv2. After you set the value to |
LaunchPermission | LaunchPermissionModifications | undefined | A new launch permission for the AMI. |
OperationType | OperationType | undefined | The operation type. This parameter can be used only when the |
OrganizationArns | string[] | undefined | The Amazon Resource Name (ARN) of an organization. This parameter can be used only when the |
OrganizationalUnitArns | string[] | undefined | The Amazon Resource Name (ARN) of an organizational unit (OU). This parameter can be used only when the |
ProductCodes | string[] | undefined | Not supported. |
UserGroups | string[] | undefined | The user groups. This parameter can be used only when the |
UserIds | string[] | undefined | The Amazon Web Services account IDs. This parameter can be used only when the |
Value | string | undefined | The value of the attribute being modified. This parameter can be used only when the |
ModifyImageAttributeCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
EC2ServiceException | Base exception class for all service exceptions from EC2 service. |