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
}