Skip to content
v2.274.0

BaseServiceProps Struct ​

Complete base service properties that are required to be supplied by the implementation of the BaseService class.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_ecs as ecs } from 'aws-cdk-lib';
import { aws_iam as iam } from 'aws-cdk-lib';
import { aws_servicediscovery as servicediscovery } from 'aws-cdk-lib';
import { aws_kms as interfaces_kms } from 'aws-cdk-lib/interfaces';

declare const cluster: ecs.Cluster;
declare const containerDefinition: ecs.ContainerDefinition;
declare const deploymentLifecycleHookTarget: ecs.IDeploymentLifecycleHookTarget;
declare const keyRef: interfaces_kms.IKeyRef;
declare const logDriver: ecs.LogDriver;
declare const namespace: servicediscovery.INamespace;
declare const role: iam.Role;
declare const serviceManagedVolume: ecs.ServiceManagedVolume;
declare const taskDefinitionRevision: ecs.TaskDefinitionRevision;
const baseServiceProps: ecs.BaseServiceProps = {
  cluster: cluster,
  launchType: ecs.LaunchType.EC2,

  // the properties below are optional
  bakeTime: cdk.Duration.minutes(30),
  canaryConfiguration: {
    stepBakeTime: cdk.Duration.minutes(30),
    stepPercent: 123,
  },
  capacityProviderStrategies: [{
    capacityProvider: 'capacityProvider',

    // the properties below are optional
    base: 123,
    weight: 123,
  }],
  circuitBreaker: {
    enable: false,
    rollback: false,
  },
  cloudMapOptions: {
    cloudMapNamespace: namespace,
    container: containerDefinition,
    containerPort: 123,
    dnsRecordType: servicediscovery.DnsRecordType.A,
    dnsTtl: cdk.Duration.minutes(30),
    failureThreshold: 123,
    name: 'name',
  },
  deploymentAlarms: {
    alarmNames: ['alarmNames'],

    // the properties below are optional
    behavior: ecs.AlarmBehavior.ROLLBACK_ON_ALARM,
  },
  deploymentController: {
    type: ecs.DeploymentControllerType.ECS,
  },
  deploymentStrategy: ecs.DeploymentStrategy.ROLLING,
  desiredCount: 123,
  enableECSManagedTags: false,
  enableExecuteCommand: false,
  forceNewDeployment: {
    enabled: false,

    // the properties below are optional
    nonce: 'nonce',
  },
  healthCheckGracePeriod: cdk.Duration.minutes(30),
  lifecycleHooks: [deploymentLifecycleHookTarget],
  linearConfiguration: {
    stepBakeTime: cdk.Duration.minutes(30),
    stepPercent: 123,
  },
  maxHealthyPercent: 123,
  minHealthyPercent: 123,
  propagateTags: ecs.PropagatedTagSource.SERVICE,
  serviceConnectConfiguration: {
    accessLogConfiguration: {
      format: ecs.ServiceConnectAccessLogFormat.TEXT,

      // the properties below are optional
      includeQueryParameters: false,
    },
    logDriver: logDriver,
    namespace: 'namespace',
    services: [{
      portMappingName: 'portMappingName',

      // the properties below are optional
      discoveryName: 'discoveryName',
      dnsName: 'dnsName',
      idleTimeout: cdk.Duration.minutes(30),
      ingressPortOverride: 123,
      perRequestTimeout: cdk.Duration.minutes(30),
      port: 123,
      tls: {
        awsPcaAuthorityArn: 'awsPcaAuthorityArn',
        kmsKey: keyRef,
        role: role,
      },
    }],
  },
  serviceName: 'serviceName',
  taskDefinitionRevision: taskDefinitionRevision,
  volumeConfigurations: [serviceManagedVolume],
};

Properties ​

bakeTimeoptionalDurationbake_timeoptionalDurationbakeTimeoptionalDurationBakeTimeoptionalDurationBakeTimeoptionalDuration= none#
bake time minutes for service.
canaryConfigurationoptionalTrafficShiftConfigcanary_configurationoptionalTrafficShiftConfigcanaryConfigurationoptionalTrafficShiftConfigCanaryConfigurationoptionalTrafficShiftConfigCanaryConfigurationoptionalTrafficShiftConfig#
Configuration for canary deployment strategy.

Default: no canary configuration

Only valid when deploymentStrategy is set to CANARY.

capacityProviderStrategiesoptionalCapacityProviderStrategy[]capacity_provider_strategiesoptionaltyping.List[CapacityProviderStrategy]capacityProviderStrategiesoptionalList<CapacityProviderStrategy>CapacityProviderStrategiesoptionalCapacityProviderStrategy[]CapacityProviderStrategiesoptional*[]CapacityProviderStrategy= undefined#
A list of Capacity Provider strategies used to place a service.
circuitBreakeroptionalDeploymentCircuitBreakercircuit_breakeroptionalDeploymentCircuitBreakercircuitBreakeroptionalDeploymentCircuitBreakerCircuitBreakeroptionalDeploymentCircuitBreakerCircuitBreakeroptionalDeploymentCircuitBreaker= disabled#
Whether to enable the deployment circuit breaker.

If this property is defined, circuit breaker will be implicitly enabled.

cloudMapOptionsoptionalCloudMapOptionscloud_map_optionsoptionalCloudMapOptionscloudMapOptionsoptionalCloudMapOptionsCloudMapOptionsoptionalCloudMapOptionsCloudMapOptionsoptionalCloudMapOptions#
The options for configuring an Amazon ECS service to use service discovery.

Default: AWS Cloud Map service discovery is not enabled.

clusterIClusterclusterIClusterclusterIClusterClusterIClusterClusterIClusterrequired#
The name of the cluster that hosts the service.
deploymentAlarmsoptionalDeploymentAlarmConfigdeployment_alarmsoptionalDeploymentAlarmConfigdeploymentAlarmsoptionalDeploymentAlarmConfigDeploymentAlarmsoptionalDeploymentAlarmConfigDeploymentAlarmsoptionalDeploymentAlarmConfig#
The alarm(s) to monitor during deployment, and behavior to apply if at least one enters a state of alarm during the deployment or bake time.

Default: No alarms will be monitored during deployment.

deploymentControlleroptionalDeploymentControllerdeployment_controlleroptionalDeploymentControllerdeploymentControlleroptionalDeploymentControllerDeploymentControlleroptionalDeploymentControllerDeploymentControlleroptionalDeploymentController#
Specifies which deployment controller to use for the service.

Default: Rolling update (ECS)

For more information, see Amazon ECS Deployment Types

deploymentStrategyoptionalDeploymentStrategydeployment_strategyoptionalDeploymentStrategydeploymentStrategyoptionalDeploymentStrategyDeploymentStrategyoptionalDeploymentStrategyDeploymentStrategyoptionalDeploymentStrategy= ROLLING#
The deployment strategy to use for the service.
desiredCountoptionalnumberdesired_countoptionalint | floatdesiredCountoptionalNumberDesiredCountoptionaldoubleDesiredCountoptional*float64#
The desired number of instantiations of the task definition to keep running on the service.

Default: When creating the service, default is 1; when updating the service, default uses the current task number.

enableECSManagedTagsoptionalbooleanenable_ecs_managed_tagsoptionalboolenableECSManagedTagsoptionalBooleanEnableECSManagedTagsoptionalboolEnableECSManagedTagsoptional*bool= false#
Specifies whether to enable Amazon ECS managed tags for the tasks within the service.

For more information, see Tagging Your Amazon ECS Resources

enableExecuteCommandoptionalbooleanenable_execute_commandoptionalboolenableExecuteCommandoptionalBooleanEnableExecuteCommandoptionalboolEnableExecuteCommandoptional*bool= undefined#
Whether to enable the ability to execute into a container.
forceNewDeploymentoptionalForceNewDeploymentforce_new_deploymentoptionalForceNewDeploymentforceNewDeploymentoptionalForceNewDeploymentForceNewDeploymentoptionalForceNewDeploymentForceNewDeploymentoptionalForceNewDeployment#
Configuration for forcing a new deployment of the service.

Default: no forced deployment

notes

By default, deployments aren't forced. You can use this option to start a new deployment with no service definition changes. For example, you can update a service's tasks to use a newer Docker image with the same image/tag combination (my_image:latest) or to roll Fargate tasks onto a newer platform version.

This is equivalent to calling the forceNewDeployment() method, but allows you to configure it declaratively at construction time, including the ability to explicitly disable it with enabled: false.

healthCheckGracePeriodoptionalDurationhealth_check_grace_periodoptionalDurationhealthCheckGracePeriodoptionalDurationHealthCheckGracePeriodoptionalDurationHealthCheckGracePeriodoptionalDuration#
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.

Default: defaults to 60 seconds if at least one load balancer is in-use and it is not already set

launchTypeLaunchTypelaunch_typeLaunchTypelaunchTypeLaunchTypeLaunchTypeLaunchTypeLaunchTypeLaunchTyperequired#
The launch type on which to run your service.

LaunchType will be omitted if capacity provider strategies are specified on the service.

lifecycleHooksoptionalIDeploymentLifecycleHookTarget[]lifecycle_hooksoptionaltyping.List[IDeploymentLifecycleHookTarget]lifecycleHooksoptionalList<IDeploymentLifecycleHookTarget>LifecycleHooksoptionalIDeploymentLifecycleHookTarget[]LifecycleHooksoptional*[]IDeploymentLifecycleHookTarget= none;#
The lifecycle hooks to execute during deployment stages.
linearConfigurationoptionalTrafficShiftConfiglinear_configurationoptionalTrafficShiftConfiglinearConfigurationoptionalTrafficShiftConfigLinearConfigurationoptionalTrafficShiftConfigLinearConfigurationoptionalTrafficShiftConfig#
Configuration for linear deployment strategy.

Default: no linear configuration

Only valid when deploymentStrategy is set to LINEAR.

maxHealthyPercentoptionalnumbermax_healthy_percentoptionalint | floatmaxHealthyPercentoptionalNumberMaxHealthyPercentoptionaldoubleMaxHealthyPercentoptional*float64#
The maximum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that can run in a service during a deployment.

Default: 100 if daemon, otherwise 200

minHealthyPercentoptionalnumbermin_healthy_percentoptionalint | floatminHealthyPercentoptionalNumberMinHealthyPercentoptionaldoubleMinHealthyPercentoptional*float64#
The minimum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that must continue to run and remain healthy during a deployment.

Default: 0 if daemon, otherwise 50

propagateTagsoptionalPropagatedTagSourcepropagate_tagsoptionalPropagatedTagSourcepropagateTagsoptionalPropagatedTagSourcePropagateTagsoptionalPropagatedTagSourcePropagateTagsoptionalPropagatedTagSource= PropagatedTagSource.NONE#
Specifies whether to propagate the tags from the task definition or the service to the tasks in the service.

Valid values are: PropagatedTagSource.SERVICE, PropagatedTagSource.TASK_DEFINITION or PropagatedTagSource.NONE

serviceConnectConfigurationoptionalServiceConnectPropsservice_connect_configurationoptionalServiceConnectPropsserviceConnectConfigurationoptionalServiceConnectPropsServiceConnectConfigurationoptionalServiceConnectPropsServiceConnectConfigurationoptionalServiceConnectProps#
Configuration for Service Connect.

Default: No ports are advertised via Service Connect on this service, and the service cannot make requests to other services via Service Connect.

serviceNameoptionalstringservice_nameoptionalstrserviceNameoptionalStringServiceNameoptionalstringServiceNameoptional*string#
The name of the service.

Default: CloudFormation-generated name.

taskDefinitionRevisionoptionalTaskDefinitionRevisiontask_definition_revisionoptionalTaskDefinitionRevisiontaskDefinitionRevisionoptionalTaskDefinitionRevisionTaskDefinitionRevisionoptionalTaskDefinitionRevisionTaskDefinitionRevisionoptionalTaskDefinitionRevision#
Revision number for the task definition or `latest` to use the latest active task revision.

Default: Uses the revision of the passed task definition deployed by CloudFormation

volumeConfigurationsoptionalServiceManagedVolume[]volume_configurationsoptionaltyping.List[ServiceManagedVolume]volumeConfigurationsoptionalList<ServiceManagedVolume>VolumeConfigurationsoptionalServiceManagedVolume[]VolumeConfigurationsoptional*[]ServiceManagedVolume= undefined#
Configuration details for a volume used by the service.

This allows you to specify details about the EBS volume that can be attached to ECS tasks.