Beispiel #1
0
    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)

        vpc = ec2.Vpc(self, "PirateVpc", max_azs=1)

        cluster = ecs.Cluster(self,
                              "PirateCluster",
                              container_insights=True,
                              vpc=vpc)

        cluster.add_capacity(
            'Shipyard',
            block_devices=[
                autoscaling.BlockDevice(
                    device_name='/dev/xvda',
                    volume=autoscaling.BlockDeviceVolume.ebs(
                        volume_size=1000))  # 1 TB
            ],
            instance_type=ec2.InstanceType('m4.4xlarge'))

        task_definition = ecs.Ec2TaskDefinition(
            self,
            'PirateTask',
            family='eth2',
            volumes=[
                ecs.Volume(
                    name='v',
                    docker_volume_configuration=ecs.DockerVolumeConfiguration(
                        driver='local',
                        scope=ecs.Scope.
                        SHARED,  # So it persists between beyond the lifetime of the task
                        autoprovision=True))
            ])

        container = task_definition.add_container(
            'barbosa',
            image=ecs.ContainerImage.from_registry(
                'sigp/lighthouse'),  # TODO: configurable
            command=[
                '--network pyrmont beacon', '--http', '--http-address 0.0.0.0'
            ],
            cpu=4 * 1024,  # 4vCPU -> 8-30GB memory
            container_name='Pirate',
            logging=ecs.LogDrivers.aws_logs(stream_prefix='pirate'),
            memory_reservation_mib=16 * 1024,  # 16GB
            port_mappings=[
                ecs.PortMapping(container_port=9000,
                                host_port=9000),  # protocol=TCP
                ecs.PortMapping(container_port=5052,
                                host_port=5052),  # protocol=TCP
            ],
            secrets={
                # TODO: populate these with our keys
            },
            user='******')

        service = ecs_patterns.ApplicationLoadBalancedEc2Service(
            self,
            "Pirateship",
            #                certificate=???,  # TODO: set up the public domain
            cluster=cluster,
            desired_count=1,
            #                domain_name='ethpirates.com',
            #                domain_zone=???,  # TODO: set up the public domain
            public_load_balancer=True,
            task_definition=task_definition)
Beispiel #2
0
efsvol=efs.FileSystem(stack,'efsvolume',vpc=vpc,file_system_name='onetest',security_group=security_group)

efsdns=efsvol.file_system_id+".efs.us-east-1.amazonaws.com"

efs_to_connect="addr=" + efsdns +",nfsvers=4.0,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2"
#efs_to_connect="addr=" + efsvol.file_system_id
device_set=efsdns+":/"
driveropts={
    "type": "nfs",
    "device":device_set,
    "o": efs_to_connect
    #"o": "addr=fs-XXXXXX.efs.us-east-1.amazonaws.com,nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport"

}

docker_vol_config=ecs.DockerVolumeConfiguration(driver='local', scope=ecs.Scope.TASK, driver_opts=driveropts, labels=None)

docker_volume=ecs.Volume(name='docker_vol',docker_volume_configuration=docker_vol_config)

efs_mount=ecs.MountPoint(container_path='/efs',read_only=True, source_volume='docker_vol')

cluster = ecs.Cluster(
    stack, "wes-onetest-ecs",
    vpc=vpc
)
cluster.add_capacity("DefaultAutoScalingGroup",
                     instance_type=ec2.InstanceType("c5.xlarge"), key_name='aws-eb',max_capacity=4,machine_image=amitouse,
                     desired_capacity=2,min_capacity=2)

# Create a task definition with its own elastic network interface