Class ServiceManagedVolume
Represents a service-managed volume and always configured at launch.
Namespace: Amazon.CDK.AWS.ECS
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class ServiceManagedVolume : Construct
Syntax (vb)
Public Class ServiceManagedVolume Inherits Construct
Remarks
ExampleMetadata: infused
Examples
Cluster cluster;
var taskDefinition = new FargateTaskDefinition(this, "TaskDef");
var container = taskDefinition.AddContainer("web", new ContainerDefinitionOptions {
Image = ContainerImage.FromRegistry("amazon/amazon-ecs-sample"),
PortMappings = new [] { new PortMapping {
ContainerPort = 80,
Protocol = Protocol.TCP
} }
});
var volume = new ServiceManagedVolume(this, "EBSVolume", new ServiceManagedVolumeProps {
Name = "ebs1",
ManagedEBSVolume = new ServiceManagedEBSVolumeConfiguration {
Size = Size.Gibibytes(15),
VolumeType = EbsDeviceVolumeType.GP3,
FileSystemType = FileSystemType.XFS,
TagSpecifications = new [] { new EBSTagSpecification {
Tags = new Dictionary<string, string> {
{ "purpose", "production" }
},
PropagateTags = EbsPropagatedTagSource.SERVICE
} }
}
});
volume.MountIn(container, new ContainerMountPoint {
ContainerPath = "/var/lib",
ReadOnly = false
});
taskDefinition.AddVolume(volume);
var service = new FargateService(this, "FargateService", new FargateServiceProps {
Cluster = cluster,
TaskDefinition = taskDefinition,
MinHealthyPercent = 100
});
service.AddVolume(volume);
Synopsis
Constructors
ServiceManagedVolume(Construct, string, IServiceManagedVolumeProps) | Represents a service-managed volume and always configured at launch. |
Properties
Config | Volume configuration. |
ConfiguredAtLaunch | configuredAtLaunch indicates volume at launch time, referenced by taskdefinition volume. |
Name | Name of the volume, referenced by taskdefintion and mount point. |
Role | An IAM role that allows ECS to make calls to EBS APIs. |
Methods
MountIn(ContainerDefinition, IContainerMountPoint) | Mounts the service managed volume to a specified container at a defined mount point. |
Constructors
ServiceManagedVolume(Construct, string, IServiceManagedVolumeProps)
Represents a service-managed volume and always configured at launch.
public ServiceManagedVolume(Construct scope, string id, IServiceManagedVolumeProps props)
Parameters
- scope Construct
- id string
- props IServiceManagedVolumeProps
Remarks
ExampleMetadata: infused
Examples
Cluster cluster;
var taskDefinition = new FargateTaskDefinition(this, "TaskDef");
var container = taskDefinition.AddContainer("web", new ContainerDefinitionOptions {
Image = ContainerImage.FromRegistry("amazon/amazon-ecs-sample"),
PortMappings = new [] { new PortMapping {
ContainerPort = 80,
Protocol = Protocol.TCP
} }
});
var volume = new ServiceManagedVolume(this, "EBSVolume", new ServiceManagedVolumeProps {
Name = "ebs1",
ManagedEBSVolume = new ServiceManagedEBSVolumeConfiguration {
Size = Size.Gibibytes(15),
VolumeType = EbsDeviceVolumeType.GP3,
FileSystemType = FileSystemType.XFS,
TagSpecifications = new [] { new EBSTagSpecification {
Tags = new Dictionary<string, string> {
{ "purpose", "production" }
},
PropagateTags = EbsPropagatedTagSource.SERVICE
} }
}
});
volume.MountIn(container, new ContainerMountPoint {
ContainerPath = "/var/lib",
ReadOnly = false
});
taskDefinition.AddVolume(volume);
var service = new FargateService(this, "FargateService", new FargateServiceProps {
Cluster = cluster,
TaskDefinition = taskDefinition,
MinHealthyPercent = 100
});
service.AddVolume(volume);
Properties
Config
Volume configuration.
public virtual IServiceManagedEBSVolumeConfiguration? Config { get; }
Property Value
IServiceManagedEBSVolumeConfiguration
Remarks
ExampleMetadata: infused
ConfiguredAtLaunch
configuredAtLaunch indicates volume at launch time, referenced by taskdefinition volume.
public virtual bool ConfiguredAtLaunch { get; }
Property Value
Remarks
ExampleMetadata: infused
Name
Name of the volume, referenced by taskdefintion and mount point.
public virtual string Name { get; }
Property Value
Remarks
ExampleMetadata: infused
Role
An IAM role that allows ECS to make calls to EBS APIs.
public virtual IRole Role { get; }
Property Value
Remarks
If not provided, a new role with appropriate permissions will be created by default.
Methods
MountIn(ContainerDefinition, IContainerMountPoint)
Mounts the service managed volume to a specified container at a defined mount point.
public virtual void MountIn(ContainerDefinition container, IContainerMountPoint mountPoint)
Parameters
- container ContainerDefinition
The container to mount the volume on.
- mountPoint IContainerMountPoint
The mounting point details within the container.
Remarks
ExampleMetadata: infused