createTags
inline suspend fun Ec2Client.createTags(crossinline block: CreateTagsRequest.Builder.() -> Unit): CreateTagsResponse
Adds or overwrites only the specified tags for the specified Amazon EC2 resource or resources. When you specify an existing tag key, the value is overwritten with the new value. Each resource can have a maximum of 50 tags. Each tag consists of a key and optional value. Tag keys must be unique per resource.
For more information about tags, see Tag your Amazon EC2 resources in the Amazon Elastic Compute Cloud User Guide. For more information about creating IAM policies that control users' access to resources based on tags, see Supported resource-level permissions for Amazon EC2 API actions in the Amazon Elastic Compute Cloud User Guide.
Samples
import aws.sdk.kotlin.services.ec2.model.Tag
fun main() {
//sampleStart
// This example adds the tag Stack production to the specified image, or overwrites an existing tag for
// the AMI where the tag key is Stack.
ec2Client.createTags {
resources = listOf<String>(
"ami-78a54011"
)
tags = listOf<Tag>(
Tag {
key = "Stack"
value = "production"
}
)
}
//sampleEnd
}