createCapacityProvider
inline suspend fun EcsClient.createCapacityProvider(crossinline block: CreateCapacityProviderRequest.Builder.() -> Unit): CreateCapacityProviderResponse
Creates a capacity provider. Capacity providers are associated with a cluster and are used in capacity provider strategies to facilitate cluster auto scaling. You can create capacity providers for Amazon ECS Managed Instances and EC2 instances. Fargate has the predefined FARGATE
and FARGATE_SPOT
capacity providers.
Samples
import aws.sdk.kotlin.services.ecs.model.AutoScalingGroupProvider
import aws.sdk.kotlin.services.ecs.model.ManagedScaling
import aws.sdk.kotlin.services.ecs.model.ManagedScalingStatus
import aws.sdk.kotlin.services.ecs.model.ManagedTerminationProtection
fun main() {
//sampleStart
// This example creates a capacity provider that uses the specified Auto Scaling group MyASG and has
// managed scaling and manager termination protection enabled.
val resp = ecsClient.createCapacityProvider {
name = "MyCapacityProvider"
autoScalingGroupProvider = AutoScalingGroupProvider {
autoScalingGroupArn = "arn:aws:autoscaling:us-east-1:123456789012:autoScalingGroup:57ffcb94-11f0-4d6d-bf60-3bac5EXAMPLE:autoScalingGroupName/MyASG"
managedScaling = ManagedScaling {
status = ManagedScalingStatus.fromValue("ENABLED")
targetCapacity = 100
}
managedTerminationProtection = ManagedTerminationProtection.fromValue("ENABLED")
}
}
//sampleEnd
}