Class: AWSCDK::ECS::BaseService

Inherits:
Resource
  • Object
show all
Includes:
IBaseService, AWSCDK::ElasticLoadBalancing::ILoadBalancerTarget, AWSCDK::ElasticLoadBalancingv2::IApplicationLoadBalancerTarget, AWSCDK::ElasticLoadBalancingv2::INetworkLoadBalancerTarget
Defined in:
ecs/base_service.rb

Overview

The base class for Ec2Service and FargateService services.

Direct Known Subclasses

EC2Service, ExternalService, FargateService

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope, id, props, additional_props, task_definition) ⇒ BaseService

Constructs a new instance of the BaseService class.

Parameters:



19
20
21
22
23
24
25
26
27
# File 'ecs/base_service.rb', line 19

def initialize(scope, id, props, additional_props, task_definition)
  props = props.is_a?(Hash) ? ::AWSCDK::ECS::BaseServiceProps.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope")
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkJhc2VTZXJ2aWNlUHJvcHMifQ==")), "props")
  Jsii::Type.check_type(additional_props, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJhbnkifQ==")), "additionalProps")
  Jsii::Type.check_type(task_definition, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLlRhc2tEZWZpbml0aW9uIn0=")), "taskDefinition")
  Jsii::Object.instance_method(:initialize).bind(self).call(scope, id, props, additional_props, task_definition)
end

Class Method Details

.from_service_arn_with_cluster(scope, id, service_arn) ⇒ AWSCDK::ECS::IBaseService

Import an existing ECS/Fargate Service using the service cluster format.

The format is the "new" format "arn:aws:ecs:region:aws_account_id:service/cluster-name/service-name".

Parameters:

  • scope (Constructs::Construct)
  • id (String)
  • service_arn (String)

Returns:

See Also:



84
85
86
87
88
89
# File 'ecs/base_service.rb', line 84

def self.from_service_arn_with_cluster(scope, id, service_arn)
  Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope")
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  Jsii::Type.check_type(service_arn, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "serviceArn")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ecs.BaseService", "fromServiceArnWithCluster", [scope, id, service_arn])
end

.jsii_overridable_methodsObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'ecs/base_service.rb', line 29

def self.jsii_overridable_methods
  {
    :node => { kind: :property, name: "node", is_optional: false },
    :env => { kind: :property, name: "env", is_optional: false },
    :physical_name => { kind: :property, name: "physicalName", is_optional: false },
    :stack => { kind: :property, name: "stack", is_optional: false },
    :cluster => { kind: :property, name: "cluster", is_optional: false },
    :connections => { kind: :property, name: "connections", is_optional: false },
    :service_arn => { kind: :property, name: "serviceArn", is_optional: false },
    :service_name => { kind: :property, name: "serviceName", is_optional: false },
    :service_ref => { kind: :property, name: "serviceRef", is_optional: false },
    :task_definition => { kind: :property, name: "taskDefinition", is_optional: false },
    :cloud_map_service => { kind: :property, name: "cloudMapService", is_optional: true },
    :load_balancers => { kind: :property, name: "loadBalancers", is_optional: false },
    :service_registries => { kind: :property, name: "serviceRegistries", is_optional: false },
    :cloudmap_service => { kind: :property, name: "cloudmapService", is_optional: true },
    :deployment_alarms => { kind: :property, name: "deploymentAlarms", is_optional: true },
    :network_configuration => { kind: :property, name: "networkConfiguration", is_optional: true },
    :to_string => { kind: :method, name: "toString", is_optional: false },
    :with => { kind: :method, name: "with", is_optional: false },
    :apply_cross_stack_reference_strength => { kind: :method, name: "applyCrossStackReferenceStrength", is_optional: false },
    :apply_removal_policy => { kind: :method, name: "applyRemovalPolicy", is_optional: false },
    :generate_physical_name => { kind: :method, name: "generatePhysicalName", is_optional: false },
    :get_resource_arn_attribute => { kind: :method, name: "getResourceArnAttribute", is_optional: false },
    :get_resource_name_attribute => { kind: :method, name: "getResourceNameAttribute", is_optional: false },
    :add_lifecycle_hook => { kind: :method, name: "addLifecycleHook", is_optional: false },
    :add_volume => { kind: :method, name: "addVolume", is_optional: false },
    :associate_cloud_map_service => { kind: :method, name: "associateCloudMapService", is_optional: false },
    :attach_to_application_target_group => { kind: :method, name: "attachToApplicationTargetGroup", is_optional: false },
    :attach_to_classic_lb => { kind: :method, name: "attachToClassicLB", is_optional: false },
    :attach_to_network_target_group => { kind: :method, name: "attachToNetworkTargetGroup", is_optional: false },
    :auto_scale_task_count => { kind: :method, name: "autoScaleTaskCount", is_optional: false },
    :configure_aws_vpc_networking_with_security_groups => { kind: :method, name: "configureAwsVpcNetworkingWithSecurityGroups", is_optional: false },
    :enable_cloud_map => { kind: :method, name: "enableCloudMap", is_optional: false },
    :enable_deployment_alarms => { kind: :method, name: "enableDeploymentAlarms", is_optional: false },
    :enable_service_connect => { kind: :method, name: "enableServiceConnect", is_optional: false },
    :force_new_deployment => { kind: :method, name: "forceNewDeployment", is_optional: false },
    :is_using_ecs_deployment_controller => { kind: :method, name: "isUsingECSDeploymentController", is_optional: false },
    :load_balancer_target => { kind: :method, name: "loadBalancerTarget", is_optional: false },
    :metric => { kind: :method, name: "metric", is_optional: false },
    :metric_cpu_utilization => { kind: :method, name: "metricCpuUtilization", is_optional: false },
    :metric_memory_utilization => { kind: :method, name: "metricMemoryUtilization", is_optional: false },
    :register_load_balancer_targets => { kind: :method, name: "registerLoadBalancerTargets", is_optional: false },
  }
end

Instance Method Details

#add_lifecycle_hook(target) ⇒ void

This method returns an undefined value.

Add a deployment lifecycle hook target.

Parameters:



339
340
341
342
# File 'ecs/base_service.rb', line 339

def add_lifecycle_hook(target)
  Jsii::Type.check_type(target, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLklEZXBsb3ltZW50TGlmZWN5Y2xlSG9va1RhcmdldCJ9")), "target")
  jsii_call_method("addLifecycleHook", [target])
end

#add_volume(volume) ⇒ void

This method returns an undefined value.

Adds a volume to the Service.

Parameters:



348
349
350
351
# File 'ecs/base_service.rb', line 348

def add_volume(volume)
  Jsii::Type.check_type(volume, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLlNlcnZpY2VNYW5hZ2VkVm9sdW1lIn0=")), "volume")
  jsii_call_method("addVolume", [volume])
end

#apply_cross_stack_reference_strength(strength) ⇒ void

This method returns an undefined value.

Override the cross-stack reference strength for this resource.

When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.

Parameters:



278
279
280
281
# File 'ecs/base_service.rb', line 278

def apply_cross_stack_reference_strength(strength)
  Jsii::Type.check_type(strength, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5SZWZlcmVuY2VTdHJlbmd0aCJ9")), "strength")
  jsii_call_method("applyCrossStackReferenceStrength", [strength])
end

#apply_removal_policy(policy) ⇒ void

This method returns an undefined value.

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

Parameters:



295
296
297
298
# File 'ecs/base_service.rb', line 295

def apply_removal_policy(policy)
  Jsii::Type.check_type(policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5SZW1vdmFsUG9saWN5In0=")), "policy")
  jsii_call_method("applyRemovalPolicy", [policy])
end

#associate_cloud_map_service(options) ⇒ void

This method returns an undefined value.

Associates this service with a CloudMap service.



357
358
359
360
361
# File 'ecs/base_service.rb', line 357

def associate_cloud_map_service(options)
  options = options.is_a?(Hash) ? ::AWSCDK::ECS::AssociateCloudMapServiceOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkFzc29jaWF0ZUNsb3VkTWFwU2VydmljZU9wdGlvbnMifQ==")), "options")
  jsii_call_method("associateCloudMapService", [options])
end

#attach_to_application_target_group(target_group) ⇒ AWSCDK::ElasticLoadBalancingv2::LoadBalancerTargetProps

This method is called to attach this service to an Application Load Balancer.

Don't call this function directly. Instead, call listener.addTargets() to add this service to a load balancer.



370
371
372
373
# File 'ecs/base_service.rb', line 370

def attach_to_application_target_group(target_group)
  Jsii::Type.check_type(target_group, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWxhc3RpY2xvYWRiYWxhbmNpbmd2Mi5JQXBwbGljYXRpb25UYXJnZXRHcm91cCJ9")), "targetGroup")
  jsii_call_method("attachToApplicationTargetGroup", [target_group])
end

#attach_to_classic_lb(load_balancer) ⇒ void

This method returns an undefined value.

Registers the service as a target of a Classic Load Balancer (CLB).

Don't call this. Call loadBalancer.addTarget() instead.

Parameters:



381
382
383
384
# File 'ecs/base_service.rb', line 381

def attach_to_classic_lb(load_balancer)
  Jsii::Type.check_type(load_balancer, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWxhc3RpY2xvYWRiYWxhbmNpbmcuTG9hZEJhbGFuY2VyIn0=")), "loadBalancer")
  jsii_call_method("attachToClassicLB", [load_balancer])
end

#attach_to_network_target_group(target_group) ⇒ AWSCDK::ElasticLoadBalancingv2::LoadBalancerTargetProps

This method is called to attach this service to a Network Load Balancer.

Don't call this function directly. Instead, call listener.addTargets() to add this service to a load balancer.



393
394
395
396
# File 'ecs/base_service.rb', line 393

def attach_to_network_target_group(target_group)
  Jsii::Type.check_type(target_group, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWxhc3RpY2xvYWRiYWxhbmNpbmd2Mi5JTmV0d29ya1RhcmdldEdyb3VwIn0=")), "targetGroup")
  jsii_call_method("attachToNetworkTargetGroup", [target_group])
end

#auto_scale_task_count(props) ⇒ AWSCDK::ECS::ScalableTaskCount

An attribute representing the minimum and maximum task count for an AutoScalingGroup.



402
403
404
405
406
# File 'ecs/base_service.rb', line 402

def auto_scale_task_count(props)
  props = props.is_a?(Hash) ? ::AWSCDK::ApplicationAutoScaling::EnableScalingProps.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXBwbGljYXRpb25hdXRvc2NhbGluZy5FbmFibGVTY2FsaW5nUHJvcHMifQ==")), "props")
  jsii_call_method("autoScaleTaskCount", [props])
end

#cloud_map_serviceAWSCDK::ServiceDiscovery::IService?

The CloudMap service created for this service, if any.



179
180
181
# File 'ecs/base_service.rb', line 179

def cloud_map_service()
  jsii_get_property("cloudMapService")
end

#cloudmap_serviceAWSCDK::ServiceDiscovery::Service?

The details of the AWS Cloud Map service.



214
215
216
# File 'ecs/base_service.rb', line 214

def cloudmap_service()
  jsii_get_property("cloudmapService")
end

#cloudmap_service=(value) ⇒ Object



218
219
220
221
# File 'ecs/base_service.rb', line 218

def cloudmap_service=(value)
  Jsii::Type.check_type(value, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3Nfc2VydmljZWRpc2NvdmVyeS5TZXJ2aWNlIn0=")), "cloudmapService") unless value.nil?
  jsii_set_property("cloudmapService", value)
end

#clusterAWSCDK::ECS::ICluster

The cluster that hosts the service.



137
138
139
# File 'ecs/base_service.rb', line 137

def cluster()
  jsii_get_property("cluster")
end

#configure_aws_vpc_networking_with_security_groups(vpc, assign_public_ip = nil, vpc_subnets = nil, security_groups = nil) ⇒ void

This method returns an undefined value.

This method is called to create a networkConfiguration.

Parameters:



415
416
417
418
419
420
421
422
# File 'ecs/base_service.rb', line 415

def configure_aws_vpc_networking_with_security_groups(vpc, assign_public_ip = nil, vpc_subnets = nil, security_groups = nil)
  Jsii::Type.check_type(vpc, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLklWcGMifQ==")), "vpc")
  Jsii::Type.check_type(assign_public_ip, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "assignPublicIp") unless assign_public_ip.nil?
  vpc_subnets = vpc_subnets.is_a?(Hash) ? ::AWSCDK::EC2::SubnetSelection.new(**vpc_subnets.transform_keys(&:to_sym)) : vpc_subnets
  Jsii::Type.check_type(vpc_subnets, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlN1Ym5ldFNlbGVjdGlvbiJ9")), "vpcSubnets") unless vpc_subnets.nil?
  Jsii::Type.check_type(security_groups, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19lYzIuSVNlY3VyaXR5R3JvdXAifSwia2luZCI6ImFycmF5In19")), "securityGroups") unless security_groups.nil?
  jsii_call_method("configureAwsVpcNetworkingWithSecurityGroups", [vpc, assign_public_ip, vpc_subnets, security_groups])
end

#connectionsAWSCDK::EC2::Connections

The security groups which manage the allowed network traffic for the service.



144
145
146
# File 'ecs/base_service.rb', line 144

def connections()
  jsii_get_property("connections")
end

#deployment_alarmsAWSCDK::ECS::CfnService::DeploymentAlarmsProperty?



224
225
226
# File 'ecs/base_service.rb', line 224

def deployment_alarms()
  jsii_get_property("deploymentAlarms")
end

#deployment_alarms=(value) ⇒ Object



228
229
230
231
232
# File 'ecs/base_service.rb', line 228

def deployment_alarms=(value)
  value = value.is_a?(Hash) ? ::AWSCDK::ECS::CfnService::DeploymentAlarmsProperty.new(**value.transform_keys(&:to_sym)) : value
  Jsii::Type.check_type(value, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkNmblNlcnZpY2UuRGVwbG95bWVudEFsYXJtc1Byb3BlcnR5In0=")), "deploymentAlarms") unless value.nil?
  jsii_set_property("deploymentAlarms", value)
end

#enable_cloud_map(options) ⇒ AWSCDK::ServiceDiscovery::Service

Enable CloudMap service discovery for the service.

Parameters:

Returns:



428
429
430
431
432
# File 'ecs/base_service.rb', line 428

def enable_cloud_map(options)
  options = options.is_a?(Hash) ? ::AWSCDK::ECS::CloudMapOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkNsb3VkTWFwT3B0aW9ucyJ9")), "options")
  jsii_call_method("enableCloudMap", [options])
end

#enable_deployment_alarms(alarm_names, options = nil) ⇒ void

This method returns an undefined value.

Enable Deployment Alarms which take advantage of arbitrary alarms and configure them after service initialization.

If you have already enabled deployment alarms, this function can be used to tell ECS about additional alarms that should interrupt a deployment.

New alarms specified in subsequent calls of this function will be appended to the existing list of alarms.

The same Alarm Behavior must be used on all deployment alarms. If you specify different AlarmBehavior values in multiple calls to this function, or the Alarm Behavior used here doesn't match the one used in the service constructor, an error will be thrown.

If the alarm's metric references the service, you cannot pass Alarm.alarmName here. That will cause a circular dependency between the service and its deployment alarm. See this package's README for options to alarm on service metrics, and avoid this circular dependency.

Parameters:



452
453
454
455
456
457
# File 'ecs/base_service.rb', line 452

def enable_deployment_alarms(alarm_names, options = nil)
  Jsii::Type.check_type(alarm_names, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "alarmNames")
  options = options.is_a?(Hash) ? ::AWSCDK::ECS::DeploymentAlarmOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkRlcGxveW1lbnRBbGFybU9wdGlvbnMifQ==")), "options") unless options.nil?
  jsii_call_method("enableDeploymentAlarms", [alarm_names, options])
end

#enable_service_connect(config = nil) ⇒ void

This method returns an undefined value.

Enable Service Connect on this service.

Parameters:



463
464
465
466
467
# File 'ecs/base_service.rb', line 463

def enable_service_connect(config = nil)
  config = config.is_a?(Hash) ? ::AWSCDK::ECS::ServiceConnectProps.new(**config.transform_keys(&:to_sym)) : config
  Jsii::Type.check_type(config, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLlNlcnZpY2VDb25uZWN0UHJvcHMifQ==")), "config") unless config.nil?
  jsii_call_method("enableServiceConnect", [config])
end

#envAWSCDK::Interfaces::ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.



109
110
111
# File 'ecs/base_service.rb', line 109

def env()
  jsii_get_property("env")
end

#force_new_deployment(nonce = nil) ⇒ void

This method returns an undefined value.

Forces a new deployment of the service.

This can be used to trigger a deployment without changing the task definition or desired count. ECS will start a new deployment even if there are no changes to the service configuration.

Important: When called without a nonce, a timestamp is generated automatically, which means every cdk synth produces a different template and every cdk deploy triggers a new deployment regardless of whether any code has changed. To avoid this, provide a stable nonce value that only changes when you intentionally want to force a redeployment (e.g., an image digest or a version string).

Parameters:

  • nonce (String, nil) (defaults to: nil)
    • A unique string (1-255 characters) that signals ECS to start a new deployment.


481
482
483
484
# File 'ecs/base_service.rb', line 481

def force_new_deployment(nonce = nil)
  Jsii::Type.check_type(nonce, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "nonce") unless nonce.nil?
  jsii_call_method("forceNewDeployment", [nonce])
end

#generate_physical_nameString

Returns:

  • (String)


301
302
303
# File 'ecs/base_service.rb', line 301

def generate_physical_name()
  jsii_call_method("generatePhysicalName", [])
end

#get_resource_arn_attribute(arn_attr, arn_components) ⇒ String

Returns an environment-sensitive token that should be used for the resource's "ARN" attribute (e.g. bucket.bucketArn).

Normally, this token will resolve to arn_attr, but if the resource is referenced across environments, arn_components will be used to synthesize a concrete ARN with the resource's physical name. Make sure to reference this.physicalName in arn_components.

Parameters:

  • arn_attr (String)

    The CFN attribute which resolves to the ARN of the resource.

  • arn_components (AWSCDK::ARNComponents)

    The format of the ARN of this resource.

Returns:

  • (String)


315
316
317
318
319
320
# File 'ecs/base_service.rb', line 315

def get_resource_arn_attribute(arn_attr, arn_components)
  Jsii::Type.check_type(arn_attr, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "arnAttr")
  arn_components = arn_components.is_a?(Hash) ? ::AWSCDK::ARNComponents.new(**arn_components.transform_keys(&:to_sym)) : arn_components
  Jsii::Type.check_type(arn_components, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5Bcm5Db21wb25lbnRzIn0=")), "arnComponents")
  jsii_call_method("getResourceArnAttribute", [arn_attr, arn_components])
end

#get_resource_name_attribute(name_attr) ⇒ String

Returns an environment-sensitive token that should be used for the resource's "name" attribute (e.g. bucket.bucketName).

Normally, this token will resolve to name_attr, but if the resource is referenced across environments, it will be resolved to this.physicalName, which will be a concrete name.

Parameters:

  • name_attr (String)

    The CFN attribute which resolves to the resource's name.

Returns:

  • (String)


330
331
332
333
# File 'ecs/base_service.rb', line 330

def get_resource_name_attribute(name_attr)
  Jsii::Type.check_type(name_attr, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "nameAttr")
  jsii_call_method("getResourceNameAttribute", [name_attr])
end

#is_using_ecs_deployment_controllerBoolean

Checks if the service is using the ECS deployment controller.

Returns:

  • (Boolean)

    true if the service is using the ECS deployment controller or if no deployment controller is specified (defaults to ECS)



489
490
491
# File 'ecs/base_service.rb', line 489

def is_using_ecs_deployment_controller()
  jsii_call_method("isUsingECSDeploymentController", [])
end

#load_balancer_target(options) ⇒ AWSCDK::ECS::IECSLoadBalancerTarget

Return a load balancing target for a specific container and port.

Use this function to create a load balancer target if you want to load balance to another container than the first essential container or the first mapped port on the container.

Use the return value of this function where you would normally use a load balancer target, instead of the Service object itself.

Examples:

listener = nil # AWSCDK::ElasticLoadBalancingv2::ApplicationListener
service = nil # AWSCDK::ECS::BaseService

listener.add_targets("ECS", {
    port: 80,
    targets: [
        service.load_balancer_target({
            container_name: "MyContainer",
            container_port: 1234,
        }),
    ],
})

Parameters:

Returns:



517
518
519
520
521
# File 'ecs/base_service.rb', line 517

def load_balancer_target(options)
  options = options.is_a?(Hash) ? ::AWSCDK::ECS::LoadBalancerTargetOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkxvYWRCYWxhbmNlclRhcmdldE9wdGlvbnMifQ==")), "options")
  jsii_call_method("loadBalancerTarget", [options])
end

#load_balancersArray<AWSCDK::ECS::CfnService::LoadBalancerProperty>

A list of Elastic Load Balancing load balancer objects, containing the load balancer name, the container name (as it appears in a container definition), and the container port to access from the load balancer.



186
187
188
# File 'ecs/base_service.rb', line 186

def load_balancers()
  jsii_get_property("loadBalancers")
end

#load_balancers=(value) ⇒ Object



190
191
192
193
194
# File 'ecs/base_service.rb', line 190

def load_balancers=(value)
  value = value.is_a?(Array) ? value.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::ECS::CfnService::LoadBalancerProperty.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : value
  Jsii::Type.check_type(value, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19lY3MuQ2ZuU2VydmljZS5Mb2FkQmFsYW5jZXJQcm9wZXJ0eSJ9LCJraW5kIjoiYXJyYXkifX0=")), "loadBalancers")
  jsii_set_property("loadBalancers", value)
end

#metric(metric_name, props = nil) ⇒ AWSCDK::CloudWatch::Metric

This method returns the specified CloudWatch metric name for this service.

Parameters:

Returns:



528
529
530
531
532
533
# File 'ecs/base_service.rb', line 528

def metric(metric_name, props = nil)
  Jsii::Type.check_type(metric_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "metricName")
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metric", [metric_name, props])
end

#metric_cpu_utilization(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Note:

Default: average over 5 minutes

This method returns the CloudWatch metric for this service's CPU utilization.

Parameters:

Returns:



540
541
542
543
544
# File 'ecs/base_service.rb', line 540

def metric_cpu_utilization(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricCpuUtilization", [props])
end

#metric_memory_utilization(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Note:

Default: average over 5 minutes

This method returns the CloudWatch metric for this service's memory utilization.

Parameters:

Returns:



551
552
553
554
555
# File 'ecs/base_service.rb', line 551

def metric_memory_utilization(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricMemoryUtilization", [props])
end

#network_configurationAWSCDK::ECS::CfnService::NetworkConfigurationProperty?



235
236
237
# File 'ecs/base_service.rb', line 235

def network_configuration()
  jsii_get_property("networkConfiguration")
end

#network_configuration=(value) ⇒ Object



239
240
241
242
243
# File 'ecs/base_service.rb', line 239

def network_configuration=(value)
  value = value.is_a?(Hash) ? ::AWSCDK::ECS::CfnService::NetworkConfigurationProperty.new(**value.transform_keys(&:to_sym)) : value
  Jsii::Type.check_type(value, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkNmblNlcnZpY2UuTmV0d29ya0NvbmZpZ3VyYXRpb25Qcm9wZXJ0eSJ9")), "networkConfiguration") unless value.nil?
  jsii_set_property("networkConfiguration", value)
end

#nodeConstructs::Node

The tree node.

Returns:

  • (Constructs::Node)


94
95
96
# File 'ecs/base_service.rb', line 94

def node()
  jsii_get_property("node")
end

#physical_nameString

Returns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource.

This value will resolve to one of the following:

  • a concrete value (e.g. "my-awesome-bucket")
  • undefined, when a name should be generated by CloudFormation
  • a concrete name generated automatically during synthesis, in cross-environment scenarios.

Returns:

  • (String)


123
124
125
# File 'ecs/base_service.rb', line 123

def physical_name()
  jsii_get_property("physicalName")
end

#register_load_balancer_targets(*targets) ⇒ void

This method returns an undefined value.

Use this function to create all load balancer targets to be registered in this service, add them to target groups, and attach target groups to listeners accordingly.

Alternatively, you can use listener.addTargets() to create targets and add them to target groups.

Examples:

listener = nil # AWSCDK::ElasticLoadBalancingv2::ApplicationListener
service = nil # AWSCDK::ECS::BaseService

service.register_load_balancer_targets({
    container_name: "web",
    container_port: 80,
    new_target_group_id: "ECS",
    listener: AWSCDK::ECS::ListenerConfig.application_listener(listener, {
        protocol: AWSCDK::ElasticLoadBalancingv2::ApplicationProtocol::HTTPS,
    }),
})

Parameters:



575
576
577
578
579
580
581
# File 'ecs/base_service.rb', line 575

def register_load_balancer_targets(*targets)
  targets.map! { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::ECS::ECSTarget.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 }
  targets.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkVjc1RhcmdldCJ9")), "targets[#{index}]")
  end
  jsii_call_method("registerLoadBalancerTargets", [*targets])
end

#service_arnString

The Amazon Resource Name (ARN) of the service.

Returns:

  • (String)


151
152
153
# File 'ecs/base_service.rb', line 151

def service_arn()
  jsii_get_property("serviceArn")
end

#service_nameString

The name of the service.

Returns:

  • (String)


158
159
160
# File 'ecs/base_service.rb', line 158

def service_name()
  jsii_get_property("serviceName")
end

#service_refAWSCDK::Interfaces::AWSECS::ServiceReference

A reference to this service.



165
166
167
# File 'ecs/base_service.rb', line 165

def service_ref()
  jsii_get_property("serviceRef")
end

#service_registriesArray<AWSCDK::ECS::CfnService::ServiceRegistryProperty>

The details of the service discovery registries to assign to this service.

For more information, see Service Discovery.



201
202
203
# File 'ecs/base_service.rb', line 201

def service_registries()
  jsii_get_property("serviceRegistries")
end

#service_registries=(value) ⇒ Object



205
206
207
208
209
# File 'ecs/base_service.rb', line 205

def service_registries=(value)
  value = value.is_a?(Array) ? value.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::ECS::CfnService::ServiceRegistryProperty.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : value
  Jsii::Type.check_type(value, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19lY3MuQ2ZuU2VydmljZS5TZXJ2aWNlUmVnaXN0cnlQcm9wZXJ0eSJ9LCJraW5kIjoiYXJyYXkifX0=")), "serviceRegistries")
  jsii_set_property("serviceRegistries", value)
end

#stackAWSCDK::Stack

The stack in which this resource is defined.

Returns:



130
131
132
# File 'ecs/base_service.rb', line 130

def stack()
  jsii_get_property("stack")
end

#task_definitionAWSCDK::ECS::TaskDefinition

The task definition to use for tasks in the service.



172
173
174
# File 'ecs/base_service.rb', line 172

def task_definition()
  jsii_get_property("taskDefinition")
end

#to_stringString

Returns a string representation of this construct.

Returns:

  • (String)


248
249
250
# File 'ecs/base_service.rb', line 248

def to_string()
  jsii_call_method("toString", [])
end

#with(*mixins) ⇒ Constructs::IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

Parameters:

  • mixins (Array<Constructs::IMixin>)

Returns:

  • (Constructs::IConstruct)


261
262
263
264
265
266
# File 'ecs/base_service.rb', line 261

def with(*mixins)
  mixins.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklNaXhpbiJ9")), "mixins[#{index}]")
  end
  jsii_call_method("with", [*mixins])
end