Interface FargateServiceProps
- All Superinterfaces:
BaseServiceOptions,software.amazon.jsii.JsiiSerializable
- All Known Implementing Classes:
FargateServiceProps.Jsii$Proxy
Example:
import software.amazon.awscdk.services.cloudwatch.*;
Cluster cluster;
TaskDefinition taskDefinition;
String serviceName = "MyFargateService";
FargateService service = FargateService.Builder.create(this, "Service")
.serviceName(serviceName)
.cluster(cluster)
.taskDefinition(taskDefinition)
.minHealthyPercent(100)
.build();
Metric cpuMetric = Metric.Builder.create()
.metricName("CPUUtilization")
.namespace("AWS/ECS")
.period(Duration.minutes(5))
.statistic("Average")
.dimensionsMap(Map.of(
"ClusterName", cluster.getClusterName(),
// Using `service.serviceName` here will cause a circular dependency
"ServiceName", serviceName))
.build();
Alarm myAlarm = Alarm.Builder.create(this, "CPUAlarm")
.alarmName("cpuAlarmName")
.metric(cpuMetric)
.evaluationPeriods(2)
.threshold(80)
.build();
service.enableDeploymentAlarms(List.of(myAlarm.getAlarmName()), DeploymentAlarmOptions.builder()
.behavior(AlarmBehavior.FAIL_ON_ALARM)
.build());
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classA builder forFargateServicePropsstatic final classAn implementation forFargateServiceProps -
Method Summary
Modifier and TypeMethodDescriptionstatic FargateServiceProps.Builderbuilder()default BooleanSpecifies whether the task's elastic network interface receives a public IP address.default AvailabilityZoneRebalancingWhether to use Availability Zone rebalancing for the service.default FargatePlatformVersionThe platform version on which to run your service.default List<ISecurityGroup> The security groups to associate with the service.The task definition to use for tasks in the service.default SubnetSelectionThe subnets to associate with the service.Methods inherited from interface software.amazon.awscdk.services.ecs.BaseServiceOptions
getBakeTime, getCapacityProviderStrategies, getCircuitBreaker, getCloudMapOptions, getCluster, getDeploymentAlarms, getDeploymentController, getDeploymentStrategy, getDesiredCount, getEnableECSManagedTags, getEnableExecuteCommand, getHealthCheckGracePeriod, getLifecycleHooks, getMaxHealthyPercent, getMinHealthyPercent, getPropagateTags, getServiceConnectConfiguration, getServiceName, getTaskDefinitionRevision, getVolumeConfigurationsMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Method Details
-
getTaskDefinition
The task definition to use for tasks in the service.[disable-awslint:ref-via-interface]
-
getAssignPublicIp
Specifies whether the task's elastic network interface receives a public IP address.If true, each task will receive a public IP address.
Default: false
-
getAvailabilityZoneRebalancing
Whether to use Availability Zone rebalancing for the service.If enabled,
maxHealthyPercentmust be greater than 100, and the service must not be a target of a Classic Load Balancer.Default: AvailabilityZoneRebalancing.ENABLED
- See Also:
-
getPlatformVersion
The platform version on which to run your service.If one is not specified, the LATEST platform version is used by default. For more information, see AWS Fargate Platform Versions in the Amazon Elastic Container Service Developer Guide.
Default: Latest
-
getSecurityGroups
The security groups to associate with the service.If you do not specify a security group, a new security group is created.
Default: - A new security group is created.
-
getVpcSubnets
The subnets to associate with the service.Default: - Public subnets if `assignPublicIp` is set, otherwise the first available one of Private, Isolated, Public, in that order.
-
builder
- Returns:
- a
FargateServiceProps.BuilderofFargateServiceProps
-