class ServiceManagedVolume (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.ECS.ServiceManagedVolume |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsecs#ServiceManagedVolume |
Java | software.amazon.awscdk.services.ecs.ServiceManagedVolume |
Python | aws_cdk.aws_ecs.ServiceManagedVolume |
TypeScript (source) | aws-cdk-lib » aws_ecs » ServiceManagedVolume |
Implements
IConstruct
, IDependable
Represents a service-managed volume and always configured at launch.
Example
declare const cluster: ecs.Cluster;
const taskDefinition = new ecs.FargateTaskDefinition(this, 'TaskDef');
const container = taskDefinition.addContainer('web', {
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
portMappings: [{
containerPort: 80,
protocol: ecs.Protocol.TCP,
}],
});
const volume = new ecs.ServiceManagedVolume(this, 'EBSVolume', {
name: 'ebs1',
managedEBSVolume: {
size: Size.gibibytes(15),
volumeType: ec2.EbsDeviceVolumeType.GP3,
fileSystemType: ecs.FileSystemType.XFS,
tagSpecifications: [{
tags: {
purpose: 'production',
},
propagateTags: ecs.EbsPropagatedTagSource.SERVICE,
}],
},
});
volume.mountIn(container, {
containerPath: '/var/lib',
readOnly: false,
});
taskDefinition.addVolume(volume);
const service = new ecs.FargateService(this, 'FargateService', {
cluster,
taskDefinition,
});
service.addVolume(volume);
Initializer
new ServiceManagedVolume(scope: Construct, id: string, props: ServiceManagedVolumeProps)
Parameters
- scope
Construct
- id
string
- props
Service
Managed Volume Props
Construct Props
Name | Type | Description |
---|---|---|
name | string | The name of the volume. |
managed | Service | Configuration for an Amazon Elastic Block Store (EBS) volume managed by ECS. |
name
Type:
string
The name of the volume.
This corresponds to the name provided in the ECS TaskDefinition.
managedEBSVolume?
Type:
Service
(optional, default: undefined)
Configuration for an Amazon Elastic Block Store (EBS) volume managed by ECS.
Properties
Name | Type | Description |
---|---|---|
configured | boolean | configuredAtLaunch indicates volume at launch time, referenced by taskdefinition volume. |
name | string | Name of the volume, referenced by taskdefintion and mount point. |
node | Node | The tree node. |
role | IRole | An IAM role that allows ECS to make calls to EBS APIs. |
config? | Service | Volume configuration. |
configuredAtLaunch
Type:
boolean
configuredAtLaunch indicates volume at launch time, referenced by taskdefinition volume.
name
Type:
string
Name of the volume, referenced by taskdefintion and mount point.
node
Type:
Node
The tree node.
role
Type:
IRole
An IAM role that allows ECS to make calls to EBS APIs.
If not provided, a new role with appropriate permissions will be created by default.
config?
Type:
Service
(optional)
Volume configuration.
Methods
Name | Description |
---|---|
mount | Mounts the service managed volume to a specified container at a defined mount point. |
to | Returns a string representation of this construct. |
In(container, mountPoint)
mountpublic mountIn(container: ContainerDefinition, mountPoint: ContainerMountPoint): void
Parameters
- container
Container
— The container to mount the volume on.Definition - mountPoint
Container
— The mounting point details within the container.Mount Point
Mounts the service managed volume to a specified container at a defined mount point.
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.