Skip to main content

Amazon Web Services

AWS products able to run Snapshot SDK:

  1. Elastic Compute Cloud (EC2)
  2. Elastic Container Service (ECS)
  3. Elastic Kubernetes Service (EKS)

Elastic Compute Cloud (EC2)#

Amazon Elastic Compute Cloud provides secure, resizable compute in the cloud, offering the broadest choice of processor, storage, networking, OS, and purchase model.

Setup instructions using new console experience:#

  1. Visit EC2 console and Launch an Ubuntu linux instance Launch Ubuntu Instance

  2. Enter a desired name, Select Ubuntu Amazon machine Image(AMI), Select an SSH Key pair then click Launch instance You can leave the other options as the default Launch Ubuntu Instance

  3. Once the instance is running and has finished initializing, connect via SSH to begin the install The ssh command looks like below:

    ssh -i "Snapshot-SDK-ECS.pem" [email protected]
    tip

    If you get an error Load key "Snapshot-SDK-ECS.pem": bad permissions, Fix by updating key file permissions: chmod 400 Snapshot-SDK-ECS.pem

    tip

    For other ways of starting an SSH session, right click on the instance then click on Connect. Launch Ubuntu Instance

  4. After a successful connection, proceede with Snapshot SDK installation steps
    Ensure the Inbound Rules of the Security Group attached to the EC2 instance allow incoming connection on the PORT mapped to 8080 of the SDK container.
    The SDK API should now be accessible via the EC2 instance public IP that is visible in the instance details.

Elastic Container Service (ECS)#

Amazon ECS is a fully managed container orchestration service that makes it easy for you to deploy, manage, and scale containerized applications.
ECS provides two main ways you can run the Snapshot SDK service:

  • EC2 launch type
  • Fargate launch type
tip

Incase of a failed service startup or taking too long:

  • Check the service events by clicking on the service.
  • Check the container logs on AWS Cloudwatch.
  • SSH into the EC2 instance and check container logs using docker commands.
tip

To make edits to the container, create a revision of the task definition then update the service to use the new revision. Select Force new deployment so that the services is restarted with the new configurations.

EC2 launch type#

Run your containerized applications on Amazon EC2 instances that you register to your Amazon ECS cluster and manage yourself.

Setup instructions using new console experience:#

tip

User account creating the cluster should have these permissions besides EC2 and ECS if not an administrator:

  • iam:CreateRole
  • iam:AttachRolePolicy
  • logs:CreateLogGroup
  • logs:CreateLogStream
  • iam:ListInstanceProfilesForRole
  • iam:AddRoleToInstanceProfile
  • iam:CreateInstanceProfile
  • iam:AttachRolePolicy
  • iam:CreateRole
  1. Create an ECS cluster, Ensure to select EC2 Linux+Networking template ECS EC2 launch type

  2. Enter a cluster name and select a desired EC2 instance size
    Select a Key pair to be able to SSH to the instance later
    Select to create a new VPC or choose an existing VPC and Subnet then click on Create at the bottom. ECS EC2 launch type

  3. After the cluster is created, click on View Cluster, click on Task Definitions on the left sidebar, click on Create new Task Definition ECS EC2 launch type

  4. Select EC2 launch type compatibility then click on Next step ECS EC2 launch type

  5. Scroll to the bottom and click on Configure via JSON then paste the JSON below into the input. ECS EC2 launch type

    danger

    Edit these properties in the JSON before saving:

    • containerDefinitions.environment.0.value with your TOKEN
    • containerDefinitions.environment.1.value with your LICENSE_KEY
    {    "family": "platerecognizer-alpr",    "containerDefinitions": [        {            "name": "snapshot",            "volumesFrom": [],            "memory": 600,            "memoryReservation": 100,            "portMappings": [                {                    "hostPort": 80,                    "protocol": "tcp",                    "containerPort": 8080                }            ],            "essential": true,            "entryPoint": [],            "mountPoints": [                {                    "containerPath": "/license",                    "sourceVolume": "snapshot-license-volume"                }            ],            "environment": [                {                    "name": "TOKEN",                    "value": "XXX"                },                {                    "name": "LICENSE_KEY",                    "value": "YYY"                }            ],            "links": [],            "image": "platerecognizer/alpr",            "command": [],            "logConfiguration": {                "logDriver": "awslogs",                "options": {                    "awslogs-group": "/ecs/snapshot-sdk",                    "awslogs-region": "us-east-1",                    "awslogs-stream-prefix": "snapshot",                    "awslogs-create-group": "true"                }            }        }    ],    "requiresCompatibilities": [        "EC2"    ],    "compatibilities": [        "EXTERNAL",        "EC2"    ],    "volumes": [        {            "host": {                "sourcePath": "/root/snapshot-license"            },            "name": "snapshot-license-volume"        }    ]}

    Click save, then click create

  6. Go back into viewing the cluster, select the Services tab then click on Create ECS EC2 launch type

  7. Configure the service

    • Select EC2 Launch type
    • Select the Task Definition you previously created
    • Enter a preferred Service name
    • Enter 1 as the desired number of tasks then click on Next Step

    ECS EC2 launch type

  8. Select None in Load balancer type then click on Next Step ECS EC2 launch type

  9. Select default value of Set Auto scaling then click on Next Step ECS EC2 launch type

  10. Review configurations then confirm by clicking on Create Service
    After service is successfully created, click on View Service to check startup status.
    The service will automatically start after a few seconds.
    The service is running okay once the status becomes ACTIVE and the Running tasks count equals Desired tasks count.
    Visit the EC2 instance IP on PORT 80 to access the Snapshot API

Fargate launch type#

Run the Snapshot SDK container without the need of provisioning and managing the underlying infrastructure.
AWS Fargate is the serverless way to run the Snapshot SDK.
Enough Server resources (CPU and RAM) are automatically provisioned and managed by AWS ECS.

Setup instructions using new console experience:#

tip

User account creating the cluster should have these permissions besides EFS, EC2 and ECS if not an administrator:

  • iam:CreateRole
  • iam:AttachRolePolicy
  • logs:CreateLogGroup
  • logs:CreateLogStream
  • iam:ListInstanceProfilesForRole
  • iam:AddRoleToInstanceProfile
  • iam:CreateInstanceProfile
  • iam:AttachRolePolicy
  • iam:CreateRole
  1. Create a new file system in EFS for persisting the license and note the EFS ID and security group ID

    Note: The Amazon EFS file system, Amazon ECS cluster, and Fargate tasks must all be in the same VPC.
    Allow inbound connections on port 2049 (Network File System, or NFS) from the security group associated with the service

    ECS Fargate launch type

  2. Create an ECS cluster with Networking only selected, On the next step, choose a cluster name then click create. ECS Fargate launch type

  3. After the cluster is created, click on View Cluster, click on Task Definitions on the left sidebar, click on Create new Task Definition ECS Fargate launch type

  4. Select Fargate launch type compatibility then click on Next step at the bottom ECS Fargate launch type

  5. Configure task and container definitions
    First create a task execution role in IAM like explained here
    Scroll to the bottom and click on Configure via JSON then paste the JSON below into the input. ECS Fargate launch type

    danger

    Edit these properties in the JSON before saving:

    • containerDefinitions.environment.0.value with your LICENSE_KEY
    • containerDefinitions.environment.1.value with your TOKEN
    • volumes.0.efsVolumeConfiguration.fileSystemId with your EFS File system ID
    
    {  "requiresCompatibilities": [    "FARGATE"  ],  "inferenceAccelerators": [
      ],  "containerDefinitions": [    {      "dnsSearchDomains": null,      "environmentFiles": [
          ],      "logConfiguration": {        "logDriver": "awslogs",        "options": {          "awslogs-group": "/ecs/snapshot-sdk-fargate",          "awslogs-region": "us-east-1",          "awslogs-stream-prefix": "snapshot-fargate",          "awslogs-create-group": "true"        }      },      "entryPoint": [
          ],      "portMappings": [        {          "hostPort": 80,          "protocol": "tcp",          "containerPort": 8080        }      ],      "command": [
          ],      "linuxParameters": null,      "cpu": 0,      "environment": [        {          "name": "LICENSE_KEY",          "value": "XXX"        },        {          "name": "TOKEN",          "value": "YYY"        }      ],      "resourceRequirements": null,      "ulimits": null,      "dnsServers": null,      "mountPoints": [        {          "containerPath": "/license",          "sourceVolume": "snapshot-license-volume"        }      ],      "workingDirectory": null,      "secrets": null,      "dockerSecurityOptions": null,      "memory": 600,      "memoryReservation": 100,      "volumesFrom": null,      "stopTimeout": null,      "image": "platerecognizer/alpr",      "startTimeout": null,      "firelensConfiguration": null,      "dependsOn": null,      "disableNetworking": null,      "interactive": null,      "healthCheck": null,      "essential": true,      "links": [
          ],      "hostname": null,      "extraHosts": null,      "pseudoTerminal": null,      "user": null,      "readonlyRootFilesystem": null,      "dockerLabels": null,      "systemControls": null,      "privileged": null,      "name": "snapshot-fargate",      "repositoryCredentials": {        "credentialsParameter": ""      }    }  ],  "volumes": [    {      "name": "snapshot-license-volume",      "efsVolumeConfiguration": {        "fileSystemId": "fs-1234",        "rootDirectory": "/"      }    }  ],  "networkMode": "awsvpc",  "memory": "1024",  "cpu": "256",  "executionRoleArn": "<create_new>",  "family": "snapshot-sdk-fargate",  "tags": [
      ],  "placementConstraints": [
      ],  "runtimePlatform": {    "operatingSystemFamily": "LINUX"  }}

    Scroll back to the top and ensure the ecsTaskExecutionRole is selected under Task role and Task execution role ECS Fargate launch type

  6. Configure service in the cluster

    • Select FARGATE Launch type
    • Select the farget Task definition
    • Enter a desired Service name
    • Enter 1 as the Number of tasks
    • Leave the other as the default and click Next

    ECS Fargate launch type

  7. Select a Cluster VPC similar to the EFS and a similar subnet then set Auto-assign public IP as ENABLED ECS Fargate launch type

  8. Leave the reset of the steps with the default values till you reach Review.
    Review configurations then confirm by clicking on Create Service.
    After service is successfully created, click on View Service to check startup status.
    The service will automatically start after a few seconds.
    The service is running okay once the status becomes ACTIVE and the Running tasks count equals Desired tasks count.
    Visit the service Task public IP on PORT 8080 to access the Snapshot API

Elastic Kubernetes Service (EKS)#

Amazon EKS is a managed Kubernetes service to run Kubernetes in the AWS cloud and on-premises data centers. In the cloud, Amazon EKS automatically manages the availability and scalability of the Kubernetes control plane nodes responsible for scheduling containers, managing application availability, storing cluster data, and other key tasks.

Setup instructions using AWS CLI:#

  1. Install AWS CLI and configure Authentication.

  2. Install eksctl and use it to create a cluster with desired number of nodes.

    eksctl create cluster --name=cluster-1 --nodes=4
  3. After the cluster has been created, the appropriate kubernetes configuration will be added to your kubeconfig file. This is, the file that you have configured in the environment variable KUBECONFIG or ~/.kube/config by default.

  4. Use the config to connect and proceed with installing the Snapshot Helm charts

    kubectl --kubeconfig ~/.kube/config get pods