ContainerMountPoint
- class aws_cdk.aws_ecs.ContainerMountPoint(*, container_path, read_only)
Bases:
BaseMountPoint
Defines the mount point details for attaching a volume to a container.
- Parameters:
container_path (
str
) – The path on the container to mount the host volume at.read_only (
bool
) – Specifies whether to give the container read-only access to the volume. If this value is true, the container has read-only access to the volume. If this value is false, then the container can write to the volume.
- ExampleMetadata:
infused
Example:
# cluster: ecs.Cluster task_definition = ecs.FargateTaskDefinition(self, "TaskDef") container = task_definition.add_container("web", image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample"), port_mappings=[ecs.PortMapping( container_port=80, protocol=ecs.Protocol.TCP )] ) volume = ecs.ServiceManagedVolume(self, "EBSVolume", name="ebs1", managed_eBSVolume=ecs.ServiceManagedEBSVolumeConfiguration( size=Size.gibibytes(15), volume_type=ec2.EbsDeviceVolumeType.GP3, file_system_type=ecs.FileSystemType.XFS, tag_specifications=[ecs.EBSTagSpecification( tags={ "purpose": "production" }, propagate_tags=ecs.EbsPropagatedTagSource.SERVICE )] ) ) volume.mount_in(container, container_path="/var/lib", read_only=False ) task_definition.add_volume(volume) service = ecs.FargateService(self, "FargateService", cluster=cluster, task_definition=task_definition, min_healthy_percent=100 ) service.add_volume(volume)
Attributes
- container_path
The path on the container to mount the host volume at.
- read_only
Specifies whether to give the container read-only access to the volume.
If this value is true, the container has read-only access to the volume. If this value is false, then the container can write to the volume.