Class: AWSCDK::ECS::Volume

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
ecs/volume.rb

Overview

A data volume used in a task definition.

For tasks that use a Docker volume, specify a DockerVolumeConfiguration. For tasks that use a bind mount host volume, specify a host and optional sourcePath.

For more information, see Using Data Volumes in Tasks.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, configured_at_launch: nil, docker_volume_configuration: nil, efs_volume_configuration: nil, host: nil) ⇒ Volume

Returns a new instance of Volume.

Parameters:

  • name (String)

    The name of the volume.

  • configured_at_launch (Boolean, nil) (defaults to: nil)

    Indicates if the volume should be configured at launch.

  • docker_volume_configuration (AWSCDK::ECS::DockerVolumeConfiguration, nil) (defaults to: nil)

    This property is specified when you are using Docker volumes.

  • efs_volume_configuration (AWSCDK::ECS::EFSVolumeConfiguration, nil) (defaults to: nil)

    This property is specified when you are using Amazon EFS.

  • host (AWSCDK::ECS::Host, nil) (defaults to: nil)

    This property is specified when you are using bind mount host volumes.



17
18
19
20
21
22
23
24
25
26
27
28
# File 'ecs/volume.rb', line 17

def initialize(name:, configured_at_launch: nil, docker_volume_configuration: nil, efs_volume_configuration: nil, host: nil)
  @name = name
  Jsii::Type.check_type(@name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "name")
  @configured_at_launch = configured_at_launch
  Jsii::Type.check_type(@configured_at_launch, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "configuredAtLaunch") unless @configured_at_launch.nil?
  @docker_volume_configuration = docker_volume_configuration.is_a?(Hash) ? ::AWSCDK::ECS::DockerVolumeConfiguration.new(**docker_volume_configuration.transform_keys(&:to_sym)) : docker_volume_configuration
  Jsii::Type.check_type(@docker_volume_configuration, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkRvY2tlclZvbHVtZUNvbmZpZ3VyYXRpb24ifQ==")), "dockerVolumeConfiguration") unless @docker_volume_configuration.nil?
  @efs_volume_configuration = efs_volume_configuration.is_a?(Hash) ? ::AWSCDK::ECS::EFSVolumeConfiguration.new(**efs_volume_configuration.transform_keys(&:to_sym)) : efs_volume_configuration
  Jsii::Type.check_type(@efs_volume_configuration, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkVmc1ZvbHVtZUNvbmZpZ3VyYXRpb24ifQ==")), "efsVolumeConfiguration") unless @efs_volume_configuration.nil?
  @host = host.is_a?(Hash) ? ::AWSCDK::ECS::Host.new(**host.transform_keys(&:to_sym)) : host
  Jsii::Type.check_type(@host, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkhvc3QifQ==")), "host") unless @host.nil?
end

Instance Attribute Details

#configured_at_launchBoolean? (readonly)

Note:

Default: false

Indicates if the volume should be configured at launch.

Returns:

  • (Boolean, nil)


41
42
43
# File 'ecs/volume.rb', line 41

def configured_at_launch
  @configured_at_launch
end

#docker_volume_configurationAWSCDK::ECS::DockerVolumeConfiguration? (readonly)

This property is specified when you are using Docker volumes.

Docker volumes are only supported when you are using the EC2 launch type. Windows containers only support the use of the local driver. To use bind mounts, specify a host instead.



49
50
51
# File 'ecs/volume.rb', line 49

def docker_volume_configuration
  @docker_volume_configuration
end

#efs_volume_configurationAWSCDK::ECS::EFSVolumeConfiguration? (readonly)

Note:

Default: No Elastic FileSystem is setup

This property is specified when you are using Amazon EFS.

When specifying Amazon EFS volumes in tasks using the Fargate launch type, Fargate creates a supervisor container that is responsible for managing the Amazon EFS volume. The supervisor container uses a small amount of the task's memory. The supervisor container is visible when querying the task metadata version 4 endpoint, but is not visible in CloudWatch Container Insights.



60
61
62
# File 'ecs/volume.rb', line 60

def efs_volume_configuration
  @efs_volume_configuration
end

#hostAWSCDK::ECS::Host? (readonly)

This property is specified when you are using bind mount host volumes.

Bind mount host volumes are supported when you are using either the EC2 or Fargate launch types. The contents of the host parameter determine whether your bind mount host volume persists on the host container instance and where it is stored. If the host parameter is empty, then the Docker daemon assigns a host path for your data volume. However, the data is not guaranteed to persist after the containers associated with it stop running.

Returns:



70
71
72
# File 'ecs/volume.rb', line 70

def host
  @host
end

#nameString (readonly)

The name of the volume.

Up to 255 letters (uppercase and lowercase), numbers, and hyphens are allowed. This name is referenced in the sourceVolume parameter of container definition mountPoints.

Returns:

  • (String)


36
37
38
# File 'ecs/volume.rb', line 36

def name
  @name
end

Class Method Details

.jsii_propertiesObject



72
73
74
75
76
77
78
79
80
# File 'ecs/volume.rb', line 72

def self.jsii_properties
  {
    :name => "name",
    :configured_at_launch => "configuredAtLaunch",
    :docker_volume_configuration => "dockerVolumeConfiguration",
    :efs_volume_configuration => "efsVolumeConfiguration",
    :host => "host",
  }
end

Instance Method Details

#to_jsiiObject



82
83
84
85
86
87
88
89
90
91
92
# File 'ecs/volume.rb', line 82

def to_jsii
  result = {}
  result.merge!({
    "name" => @name,
    "configuredAtLaunch" => @configured_at_launch,
    "dockerVolumeConfiguration" => @docker_volume_configuration,
    "efsVolumeConfiguration" => @efs_volume_configuration,
    "host" => @host,
  })
  result.compact
end