Init commit.

Signed-off-by: Arthur She <arthur.she@linaro.org>
Change-Id: I4447175e085259148f9b6d85d209f4dd56adaaa7
diff --git a/packer_config.json b/packer_config.json
new file mode 100644
index 0000000..abfd697
--- /dev/null
+++ b/packer_config.json
@@ -0,0 +1,52 @@
+{
+  "variables": {
+    "vpc_region": "us-east-1",
+    "ssh_username": "ubuntu"
+  },
+  "builders": [
+    {
+      "type": "amazon-ebs",
+      "name": "ubuntu-20.04-mbedtls",
+      "vpc_id":  "vpc-d28c0ca9",
+      "subnet_id": "subnet-a0d573af",
+      "region": "{{user `vpc_region`}}",
+      "source_ami_filter": {
+        "filters": {
+          "virtualization-type": "hvm",
+          "name": "ubuntu/images/*ubuntu-focal-20.04-amd64-server-*",
+          "root-device-type": "ebs"
+        },
+        "owners": ["099720109477"],
+        "most_recent": true
+      },
+      "instance_type": "m5a.large",
+      "ssh_username": "{{user `ssh_username`}}",
+      "ami_name": "jenkins-amd64-{{isotime \"2006-01-02-1504\"}}",
+      "ami_users": [
+        "987685672616"
+      ],
+      "snapshot_users": [
+	"987685672616"
+      ],
+      "launch_block_device_mappings": [
+        {
+          "device_name": "/dev/sda1",
+          "volume_type": "gp2",
+          "volume_size": "20",
+          "delete_on_termination": true
+        }
+      ]
+    }
+  ],
+  "provisioners": [
+    {
+      "type": "shell",
+      "inline": [ "sleep 60" ]
+    },
+    {
+      "type": "shell",
+      "script": "ubuntu.sh",
+      "execute_command": "{{.Vars}} sudo -E sh -eux '{{.Path}}'"
+    }
+  ]
+}
diff --git a/ubuntu.sh b/ubuntu.sh
new file mode 100755
index 0000000..71cd532
--- /dev/null
+++ b/ubuntu.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+set -eu
+apt-get -qq update
+DEBIAN_FRONTEND=noninteractive apt-get install -qy \
+    apt-transport-https \
+    ca-certificates \
+    curl \
+    gnupg \
+    gnupg-agent \
+    openjdk-11-jdk-headless \
+    python3 \
+    python3-venv \
+    software-properties-common \
+    unzip
+
+curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
+add-apt-repository \
+   "deb https://download.docker.com/linux/ubuntu \
+   $(lsb_release -cs) \
+   stable"
+
+apt-get -qq update
+DEBIAN_FRONTEND=noninteractive apt-get install -qy --no-install-recommends \
+    docker-ce \
+    docker-ce-cli
+
+update-alternatives --install /usr/bin/python python /usr/bin/python3 1
+
+if [ $(uname -m) = "aarch64" ]
+then
+    AWS_ZIP=https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip
+else
+    AWS_ZIP=https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip
+fi
+
+curl "$AWS_ZIP" -o "/tmp/awscli-bundle.zip"
+unzip -q -d /tmp/awscli /tmp/awscli-bundle.zip
+/tmp/awscli/aws/install -i /usr/local/aws
+aws --version
+
+adduser ubuntu docker
+
+mkdir /home/ubuntu/.aws
+echo '[default]' >> /home/ubuntu/.aws/config
+echo 'region = us-east-1' >> /home/ubuntu/.aws/config
+
+
+sed -i -e 's/#PermitTTY.*/PermitTTY yes/g' /etc/ssh/sshd_config
+