Class: AWSCDK::ECS::FargateService

Inherits:
BaseService
  • Object
show all
Includes:
IFargateService
Defined in:
ecs/fargate_service.rb

Overview

This creates a service using the Fargate launch type on an ECS cluster.

Can also be used with Managed Instances compatible task definitions when using capacity provider strategies.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope, id, props) ⇒ FargateService

Constructs a new instance of the FargateService class.

Parameters:



17
18
19
20
21
22
23
# File 'ecs/fargate_service.rb', line 17

def initialize(scope, id, props)
  props = props.is_a?(Hash) ? ::AWSCDK::ECS::FargateServiceProps.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("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkZhcmdhdGVTZXJ2aWNlUHJvcHMifQ==")), "props")
  Jsii::Object.instance_method(:initialize).bind(self).call(scope, id, props)
end

Class Method Details

.from_fargate_service_arn(scope, id, fargate_service_arn) ⇒ AWSCDK::ECS::IFargateService

Imports from the specified service ARN.

Parameters:

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

Returns:



77
78
79
80
81
82
# File 'ecs/fargate_service.rb', line 77

def self.from_fargate_service_arn(scope, id, fargate_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(fargate_service_arn, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "fargateServiceArn")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ecs.FargateService", "fromFargateServiceArn", [scope, id, fargate_service_arn])
end

.from_fargate_service_attributes(scope, id, attrs) ⇒ AWSCDK::ECS::IBaseService

Imports from the specified service attributes.

Parameters:

Returns:



90
91
92
93
94
95
96
# File 'ecs/fargate_service.rb', line 90

def self.from_fargate_service_attributes(scope, id, attrs)
  Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope")
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  attrs = attrs.is_a?(Hash) ? ::AWSCDK::ECS::FargateServiceAttributes.new(**attrs.transform_keys(&:to_sym)) : attrs
  Jsii::Type.check_type(attrs, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkZhcmdhdGVTZXJ2aWNlQXR0cmlidXRlcyJ9")), "attrs")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_ecs.FargateService", "fromFargateServiceAttributes", [scope, id, attrs])
end

.jsii_overridable_methodsObject



25
26
27
28
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
# File 'ecs/fargate_service.rb', line 25

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

.PROPERTY_INJECTION_IDString

Uniquely identifies this class.

Returns:

  • (String)


255
256
257
# File 'ecs/fargate_service.rb', line 255

def self.PROPERTY_INJECTION_ID()
  Jsii::Kernel.instance.get_static("aws-cdk-lib.aws_ecs.FargateService", "PROPERTY_INJECTION_ID")
end

Instance Method Details

#add_lifecycle_hook(target) ⇒ void

This method returns an undefined value.

Add a deployment lifecycle hook target.

Parameters:



353
354
355
356
# File 'ecs/fargate_service.rb', line 353

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:



362
363
364
365
# File 'ecs/fargate_service.rb', line 362

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:



292
293
294
295
# File 'ecs/fargate_service.rb', line 292

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:



309
310
311
312
# File 'ecs/fargate_service.rb', line 309

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.



371
372
373
374
375
# File 'ecs/fargate_service.rb', line 371

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.



384
385
386
387
# File 'ecs/fargate_service.rb', line 384

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:



395
396
397
398
# File 'ecs/fargate_service.rb', line 395

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.



407
408
409
410
# File 'ecs/fargate_service.rb', line 407

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.



416
417
418
419
420
# File 'ecs/fargate_service.rb', line 416

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.



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

def cloud_map_service()
  jsii_get_property("cloudMapService")
end

#cloudmap_serviceAWSCDK::ServiceDiscovery::Service?

The details of the AWS Cloud Map service.



221
222
223
# File 'ecs/fargate_service.rb', line 221

def cloudmap_service()
  jsii_get_property("cloudmapService")
end

#cloudmap_service=(value) ⇒ Object



225
226
227
228
# File 'ecs/fargate_service.rb', line 225

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.



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

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:



429
430
431
432
433
434
435
436
# File 'ecs/fargate_service.rb', line 429

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.



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

def connections()
  jsii_get_property("connections")
end

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



231
232
233
# File 'ecs/fargate_service.rb', line 231

def deployment_alarms()
  jsii_get_property("deploymentAlarms")
end

#deployment_alarms=(value) ⇒ Object



235
236
237
238
239
# File 'ecs/fargate_service.rb', line 235

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:



442
443
444
445
446
# File 'ecs/fargate_service.rb', line 442

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:



466
467
468
469
470
471
# File 'ecs/fargate_service.rb', line 466

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:



477
478
479
480
481
# File 'ecs/fargate_service.rb', line 477

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.



116
117
118
# File 'ecs/fargate_service.rb', line 116

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.


495
496
497
498
# File 'ecs/fargate_service.rb', line 495

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)


315
316
317
# File 'ecs/fargate_service.rb', line 315

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)


329
330
331
332
333
334
# File 'ecs/fargate_service.rb', line 329

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)


344
345
346
347
# File 'ecs/fargate_service.rb', line 344

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)



503
504
505
# File 'ecs/fargate_service.rb', line 503

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:

# Example automatically generated from non-compiling source. May contain errors.
listener = nil
service = nil
listener.add_targets("ECS", {
    port: 80,
    targets: [
        service.load_balancer_target({
            container_name: "MyContainer",
            container_port: 1234,
        }),
    ],
})

Parameters:

Returns:



531
532
533
534
535
# File 'ecs/fargate_service.rb', line 531

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.



193
194
195
# File 'ecs/fargate_service.rb', line 193

def load_balancers()
  jsii_get_property("loadBalancers")
end

#load_balancers=(value) ⇒ Object



197
198
199
200
201
# File 'ecs/fargate_service.rb', line 197

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:



542
543
544
545
546
547
# File 'ecs/fargate_service.rb', line 542

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:



554
555
556
557
558
# File 'ecs/fargate_service.rb', line 554

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:



565
566
567
568
569
# File 'ecs/fargate_service.rb', line 565

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?



242
243
244
# File 'ecs/fargate_service.rb', line 242

def network_configuration()
  jsii_get_property("networkConfiguration")
end

#network_configuration=(value) ⇒ Object



246
247
248
249
250
# File 'ecs/fargate_service.rb', line 246

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)


101
102
103
# File 'ecs/fargate_service.rb', line 101

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)


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

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:

# Example automatically generated from non-compiling source. May contain errors.
listener = nil
service = nil
service.register_load_balancer_targets({
    container_name: "web",
    container_port: 80,
    new_target_group_id: "ECS",
    listener: ECS::ListenerConfig.application_listener(listener, {
        protocol: Elbv2::ApplicationProtocol::HTTPS,
    }),
})

Parameters:



589
590
591
592
593
594
595
# File 'ecs/fargate_service.rb', line 589

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)


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

def service_arn()
  jsii_get_property("serviceArn")
end

#service_nameString

The name of the service.

Returns:

  • (String)


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

def service_name()
  jsii_get_property("serviceName")
end

#service_refAWSCDK::Interfaces::AWSECS::ServiceReference

A reference to this service.



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

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.



208
209
210
# File 'ecs/fargate_service.rb', line 208

def service_registries()
  jsii_get_property("serviceRegistries")
end

#service_registries=(value) ⇒ Object



212
213
214
215
216
# File 'ecs/fargate_service.rb', line 212

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:



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

def stack()
  jsii_get_property("stack")
end

#task_definitionAWSCDK::ECS::TaskDefinition

The task definition to use for tasks in the service.



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

def task_definition()
  jsii_get_property("taskDefinition")
end

#to_stringString

Returns a string representation of this construct.

Returns:

  • (String)


262
263
264
# File 'ecs/fargate_service.rb', line 262

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)


275
276
277
278
279
280
# File 'ecs/fargate_service.rb', line 275

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