Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

modifyImageAttribute

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.

Samples

import aws.sdk.kotlin.services.ec2.model.LaunchPermission
import aws.sdk.kotlin.services.ec2.model.LaunchPermissionModifications
import aws.sdk.kotlin.services.ec2.model.PermissionGroup

fun main() { 
   //sampleStart 
   // This example grants launch permissions for the specified AMI to the specified AWS account.
val resp = ec2Client.modifyImageAttribute {
    imageId = "ami-5731123e"
    launchPermission = LaunchPermissionModifications {
        add = listOf<LaunchPermission>(
            LaunchPermission {
                userId = "123456789012"
            }                
        )
    }
} 
   //sampleEnd
}
import aws.sdk.kotlin.services.ec2.model.LaunchPermission
import aws.sdk.kotlin.services.ec2.model.LaunchPermissionModifications
import aws.sdk.kotlin.services.ec2.model.PermissionGroup

fun main() { 
   //sampleStart 
   // This example makes the specified AMI public.
val resp = ec2Client.modifyImageAttribute {
    imageId = "ami-5731123e"
    launchPermission = LaunchPermissionModifications {
        add = listOf<LaunchPermission>(
            LaunchPermission {
                group = PermissionGroup.fromValue("all")
            }                
        )
    }
} 
   //sampleEnd
}