Class CfnService

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IInspectable, ITaggable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.95.0 (build f1ff514)", date="2024-03-26T18:09:23.033Z") @Stability(Stable) public class CfnService extends CfnResource implements IInspectable, ITaggable
The AWS::ECS::Service resource creates an Amazon Elastic Container Service (Amazon ECS) service that runs and maintains the requested number of tasks and associated load balancers.

The stack update fails if you change any properties that require replacement and at least one Amazon ECS Service Connect ServiceConnectService is configured. This is because AWS CloudFormation creates the replacement service first, but each ServiceConnectService must have a name that is unique in the namespace. > Starting April 15, 2023, AWS ; will not onboard new customers to Amazon Elastic Inference (EI), and will help current customers migrate their workloads to options that offer better price and performance. After April 15, 2023, new customers will not be able to launch instances with Amazon EI accelerators in Amazon SageMaker, Amazon ECS , or Amazon EC2 . However, customers who have used Amazon EI at least once during the past 30-day period are considered current customers and will be able to continue using the service.

Example:

 // The code below shows an example of how to instantiate this type.
 // The values are placeholders you should change.
 import software.amazon.awscdk.services.ecs.*;
 CfnService cfnService = CfnService.Builder.create(this, "MyCfnService")
         .capacityProviderStrategy(List.of(CapacityProviderStrategyItemProperty.builder()
                 .base(123)
                 .capacityProvider("capacityProvider")
                 .weight(123)
                 .build()))
         .cluster("cluster")
         .deploymentConfiguration(DeploymentConfigurationProperty.builder()
                 .alarms(DeploymentAlarmsProperty.builder()
                         .alarmNames(List.of("alarmNames"))
                         .enable(false)
                         .rollback(false)
                         .build())
                 .deploymentCircuitBreaker(DeploymentCircuitBreakerProperty.builder()
                         .enable(false)
                         .rollback(false)
                         .build())
                 .maximumPercent(123)
                 .minimumHealthyPercent(123)
                 .build())
         .deploymentController(DeploymentControllerProperty.builder()
                 .type("type")
                 .build())
         .desiredCount(123)
         .enableEcsManagedTags(false)
         .enableExecuteCommand(false)
         .healthCheckGracePeriodSeconds(123)
         .launchType("launchType")
         .loadBalancers(List.of(LoadBalancerProperty.builder()
                 .containerName("containerName")
                 .containerPort(123)
                 .loadBalancerName("loadBalancerName")
                 .targetGroupArn("targetGroupArn")
                 .build()))
         .networkConfiguration(NetworkConfigurationProperty.builder()
                 .awsvpcConfiguration(AwsVpcConfigurationProperty.builder()
                         .assignPublicIp("assignPublicIp")
                         .securityGroups(List.of("securityGroups"))
                         .subnets(List.of("subnets"))
                         .build())
                 .build())
         .placementConstraints(List.of(PlacementConstraintProperty.builder()
                 .type("type")
                 // the properties below are optional
                 .expression("expression")
                 .build()))
         .placementStrategies(List.of(PlacementStrategyProperty.builder()
                 .type("type")
                 // the properties below are optional
                 .field("field")
                 .build()))
         .platformVersion("platformVersion")
         .propagateTags("propagateTags")
         .role("role")
         .schedulingStrategy("schedulingStrategy")
         .serviceConnectConfiguration(ServiceConnectConfigurationProperty.builder()
                 .enabled(false)
                 // the properties below are optional
                 .logConfiguration(LogConfigurationProperty.builder()
                         .logDriver("logDriver")
                         .options(Map.of(
                                 "optionsKey", "options"))
                         .secretOptions(List.of(SecretProperty.builder()
                                 .name("name")
                                 .valueFrom("valueFrom")
                                 .build()))
                         .build())
                 .namespace("namespace")
                 .services(List.of(ServiceConnectServiceProperty.builder()
                         .portName("portName")
                         // the properties below are optional
                         .clientAliases(List.of(ServiceConnectClientAliasProperty.builder()
                                 .port(123)
                                 // the properties below are optional
                                 .dnsName("dnsName")
                                 .build()))
                         .discoveryName("discoveryName")
                         .ingressPortOverride(123)
                         .timeout(TimeoutConfigurationProperty.builder()
                                 .idleTimeoutSeconds(123)
                                 .perRequestTimeoutSeconds(123)
                                 .build())
                         .tls(ServiceConnectTlsConfigurationProperty.builder()
                                 .issuerCertificateAuthority(ServiceConnectTlsCertificateAuthorityProperty.builder()
                                         .awsPcaAuthorityArn("awsPcaAuthorityArn")
                                         .build())
                                 // the properties below are optional
                                 .kmsKey("kmsKey")
                                 .roleArn("roleArn")
                                 .build())
                         .build()))
                 .build())
         .serviceName("serviceName")
         .serviceRegistries(List.of(ServiceRegistryProperty.builder()
                 .containerName("containerName")
                 .containerPort(123)
                 .port(123)
                 .registryArn("registryArn")
                 .build()))
         .tags(List.of(CfnTag.builder()
                 .key("key")
                 .value("value")
                 .build()))
         .taskDefinition("taskDefinition")
         .volumeConfigurations(List.of(ServiceVolumeConfigurationProperty.builder()
                 .name("name")
                 // the properties below are optional
                 .managedEbsVolume(ServiceManagedEBSVolumeConfigurationProperty.builder()
                         .roleArn("roleArn")
                         // the properties below are optional
                         .encrypted(false)
                         .filesystemType("filesystemType")
                         .iops(123)
                         .kmsKeyId("kmsKeyId")
                         .sizeInGiB(123)
                         .snapshotId("snapshotId")
                         .tagSpecifications(List.of(EBSTagSpecificationProperty.builder()
                                 .resourceType("resourceType")
                                 // the properties below are optional
                                 .propagateTags("propagateTags")
                                 .tags(List.of(CfnTag.builder()
                                         .key("key")
                                         .value("value")
                                         .build()))
                                 .build()))
                         .throughput(123)
                         .volumeType("volumeType")
                         .build())
                 .build()))
         .build();
 

See Also:
  • Field Details

    • CFN_RESOURCE_TYPE_NAME

      @Stability(Stable) public static final String CFN_RESOURCE_TYPE_NAME
      The CloudFormation resource type name for this resource class.
  • Constructor Details

    • CfnService

      protected CfnService(software.amazon.jsii.JsiiObjectRef objRef)
    • CfnService

      protected CfnService(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • CfnService

      @Stability(Stable) public CfnService(@NotNull software.constructs.Construct scope, @NotNull String id, @Nullable CfnServiceProps props)
      Parameters:
      scope - Scope in which this resource is defined. This parameter is required.
      id - Construct identifier for this resource (unique in its scope). This parameter is required.
      props - Resource properties.
    • CfnService

      @Stability(Stable) public CfnService(@NotNull software.constructs.Construct scope, @NotNull String id)
      Parameters:
      scope - Scope in which this resource is defined. This parameter is required.
      id - Construct identifier for this resource (unique in its scope). This parameter is required.
  • Method Details

    • inspect

      @Stability(Stable) public void inspect(@NotNull TreeInspector inspector)
      Examines the CloudFormation resource and discloses attributes.

      Specified by:
      inspect in interface IInspectable
      Parameters:
      inspector - tree inspector to collect and process attributes. This parameter is required.
    • renderProperties

      @Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String,Object> props)
      Overrides:
      renderProperties in class CfnResource
      Parameters:
      props - This parameter is required.
    • getAttrName

      @Stability(Stable) @NotNull public String getAttrName()
      The name of the Amazon ECS service, such as sample-webapp .
    • getAttrServiceArn

      @Stability(Stable) @NotNull public String getAttrServiceArn()
      Not currently supported in AWS CloudFormation .
    • getCfnProperties

      @Stability(Stable) @NotNull protected Map<String,Object> getCfnProperties()
      Overrides:
      getCfnProperties in class CfnResource
    • getTags

      @Stability(Stable) @NotNull public TagManager getTags()
      Tag Manager which manages the tags for this resource.
      Specified by:
      getTags in interface ITaggable
    • getCapacityProviderStrategy

      @Stability(Stable) @Nullable public Object getCapacityProviderStrategy()
      The capacity provider strategy to use for the service.
    • setCapacityProviderStrategy

      @Stability(Stable) public void setCapacityProviderStrategy(@Nullable IResolvable value)
      The capacity provider strategy to use for the service.
    • setCapacityProviderStrategy

      @Stability(Stable) public void setCapacityProviderStrategy(@Nullable List<Object> value)
      The capacity provider strategy to use for the service.
    • getCluster

      @Stability(Stable) @Nullable public String getCluster()
      The short name or full Amazon Resource Name (ARN) of the cluster that you run your service on.
    • setCluster

      @Stability(Stable) public void setCluster(@Nullable String value)
      The short name or full Amazon Resource Name (ARN) of the cluster that you run your service on.
    • getDeploymentConfiguration

      @Stability(Stable) @Nullable public Object getDeploymentConfiguration()
      Optional deployment parameters that control how many tasks run during the deployment and the ordering of stopping and starting tasks.
    • setDeploymentConfiguration

      @Stability(Stable) public void setDeploymentConfiguration(@Nullable IResolvable value)
      Optional deployment parameters that control how many tasks run during the deployment and the ordering of stopping and starting tasks.
    • setDeploymentConfiguration

      @Stability(Stable) public void setDeploymentConfiguration(@Nullable CfnService.DeploymentConfigurationProperty value)
      Optional deployment parameters that control how many tasks run during the deployment and the ordering of stopping and starting tasks.
    • getDeploymentController

      @Stability(Stable) @Nullable public Object getDeploymentController()
      The deployment controller to use for the service.
    • setDeploymentController

      @Stability(Stable) public void setDeploymentController(@Nullable IResolvable value)
      The deployment controller to use for the service.
    • setDeploymentController

      @Stability(Stable) public void setDeploymentController(@Nullable CfnService.DeploymentControllerProperty value)
      The deployment controller to use for the service.
    • getDesiredCount

      @Stability(Stable) @Nullable public Number getDesiredCount()
      The number of instantiations of the specified task definition to place and keep running in your service.
    • setDesiredCount

      @Stability(Stable) public void setDesiredCount(@Nullable Number value)
      The number of instantiations of the specified task definition to place and keep running in your service.
    • getEnableEcsManagedTags

      @Stability(Stable) @Nullable public Object getEnableEcsManagedTags()
      Specifies whether to turn on Amazon ECS managed tags for the tasks within the service.
    • setEnableEcsManagedTags

      @Stability(Stable) public void setEnableEcsManagedTags(@Nullable Boolean value)
      Specifies whether to turn on Amazon ECS managed tags for the tasks within the service.
    • setEnableEcsManagedTags

      @Stability(Stable) public void setEnableEcsManagedTags(@Nullable IResolvable value)
      Specifies whether to turn on Amazon ECS managed tags for the tasks within the service.
    • getEnableExecuteCommand

      @Stability(Stable) @Nullable public Object getEnableExecuteCommand()
      Determines whether the execute command functionality is turned on for the service.
    • setEnableExecuteCommand

      @Stability(Stable) public void setEnableExecuteCommand(@Nullable Boolean value)
      Determines whether the execute command functionality is turned on for the service.
    • setEnableExecuteCommand

      @Stability(Stable) public void setEnableExecuteCommand(@Nullable IResolvable value)
      Determines whether the execute command functionality is turned on for the service.
    • getHealthCheckGracePeriodSeconds

      @Stability(Stable) @Nullable public Number getHealthCheckGracePeriodSeconds()
      The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing target health checks after a task has first started.
    • setHealthCheckGracePeriodSeconds

      @Stability(Stable) public void setHealthCheckGracePeriodSeconds(@Nullable Number value)
      The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing target health checks after a task has first started.
    • getLaunchType

      @Stability(Stable) @Nullable public String getLaunchType()
      The launch type on which to run your service.
    • setLaunchType

      @Stability(Stable) public void setLaunchType(@Nullable String value)
      The launch type on which to run your service.
    • getLoadBalancers

      @Stability(Stable) @Nullable public Object getLoadBalancers()
      A list of load balancer objects to associate with the service.
    • setLoadBalancers

      @Stability(Stable) public void setLoadBalancers(@Nullable IResolvable value)
      A list of load balancer objects to associate with the service.
    • setLoadBalancers

      @Stability(Stable) public void setLoadBalancers(@Nullable List<Object> value)
      A list of load balancer objects to associate with the service.
    • getNetworkConfiguration

      @Stability(Stable) @Nullable public Object getNetworkConfiguration()
      The network configuration for the service.
    • setNetworkConfiguration

      @Stability(Stable) public void setNetworkConfiguration(@Nullable IResolvable value)
      The network configuration for the service.
    • setNetworkConfiguration

      @Stability(Stable) public void setNetworkConfiguration(@Nullable CfnService.NetworkConfigurationProperty value)
      The network configuration for the service.
    • getPlacementConstraints

      @Stability(Stable) @Nullable public Object getPlacementConstraints()
      An array of placement constraint objects to use for tasks in your service.
    • setPlacementConstraints

      @Stability(Stable) public void setPlacementConstraints(@Nullable IResolvable value)
      An array of placement constraint objects to use for tasks in your service.
    • setPlacementConstraints

      @Stability(Stable) public void setPlacementConstraints(@Nullable List<Object> value)
      An array of placement constraint objects to use for tasks in your service.
    • getPlacementStrategies

      @Stability(Stable) @Nullable public Object getPlacementStrategies()
      The placement strategy objects to use for tasks in your service.
    • setPlacementStrategies

      @Stability(Stable) public void setPlacementStrategies(@Nullable IResolvable value)
      The placement strategy objects to use for tasks in your service.
    • setPlacementStrategies

      @Stability(Stable) public void setPlacementStrategies(@Nullable List<Object> value)
      The placement strategy objects to use for tasks in your service.
    • getPlatformVersion

      @Stability(Stable) @Nullable public String getPlatformVersion()
      The platform version that your tasks in the service are running on.
    • setPlatformVersion

      @Stability(Stable) public void setPlatformVersion(@Nullable String value)
      The platform version that your tasks in the service are running on.
    • getPropagateTags

      @Stability(Stable) @Nullable public String getPropagateTags()
      Specifies whether to propagate the tags from the task definition to the task.
    • setPropagateTags

      @Stability(Stable) public void setPropagateTags(@Nullable String value)
      Specifies whether to propagate the tags from the task definition to the task.
    • getRole

      @Stability(Stable) @Nullable public String getRole()
      The name or full Amazon Resource Name (ARN) of the IAM role that allows Amazon ECS to make calls to your load balancer on your behalf.
    • setRole

      @Stability(Stable) public void setRole(@Nullable String value)
      The name or full Amazon Resource Name (ARN) of the IAM role that allows Amazon ECS to make calls to your load balancer on your behalf.
    • getSchedulingStrategy

      @Stability(Stable) @Nullable public String getSchedulingStrategy()
      The scheduling strategy to use for the service.

      For more information, see Services .

    • setSchedulingStrategy

      @Stability(Stable) public void setSchedulingStrategy(@Nullable String value)
      The scheduling strategy to use for the service.

      For more information, see Services .

    • getServiceConnectConfiguration

      @Stability(Stable) @Nullable public Object getServiceConnectConfiguration()
      The configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace.
    • setServiceConnectConfiguration

      @Stability(Stable) public void setServiceConnectConfiguration(@Nullable IResolvable value)
      The configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace.
    • setServiceConnectConfiguration

      @Stability(Stable) public void setServiceConnectConfiguration(@Nullable CfnService.ServiceConnectConfigurationProperty value)
      The configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace.
    • getServiceName

      @Stability(Stable) @Nullable public String getServiceName()
      The name of your service.
    • setServiceName

      @Stability(Stable) public void setServiceName(@Nullable String value)
      The name of your service.
    • getServiceRegistries

      @Stability(Stable) @Nullable public Object getServiceRegistries()
      The details of the service discovery registry to associate with this service.

      For more information, see Service discovery .

    • setServiceRegistries

      @Stability(Stable) public void setServiceRegistries(@Nullable IResolvable value)
      The details of the service discovery registry to associate with this service.

      For more information, see Service discovery .

    • setServiceRegistries

      @Stability(Stable) public void setServiceRegistries(@Nullable List<Object> value)
      The details of the service discovery registry to associate with this service.

      For more information, see Service discovery .

    • getTagsRaw

      @Stability(Stable) @Nullable public List<CfnTag> getTagsRaw()
      The metadata that you apply to the service to help you categorize and organize them.
    • setTagsRaw

      @Stability(Stable) public void setTagsRaw(@Nullable List<CfnTag> value)
      The metadata that you apply to the service to help you categorize and organize them.
    • getTaskDefinition

      @Stability(Stable) @Nullable public String getTaskDefinition()
      The family and revision ( family:revision ) or full ARN of the task definition to run in your service.
    • setTaskDefinition

      @Stability(Stable) public void setTaskDefinition(@Nullable String value)
      The family and revision ( family:revision ) or full ARN of the task definition to run in your service.
    • getVolumeConfigurations

      @Stability(Stable) @Nullable public Object getVolumeConfigurations()
      The configuration for a volume specified in the task definition as a volume that is configured at launch time.
    • setVolumeConfigurations

      @Stability(Stable) public void setVolumeConfigurations(@Nullable IResolvable value)
      The configuration for a volume specified in the task definition as a volume that is configured at launch time.
    • setVolumeConfigurations

      @Stability(Stable) public void setVolumeConfigurations(@Nullable List<Object> value)
      The configuration for a volume specified in the task definition as a volume that is configured at launch time.