Copy of github.com/askrobots/network-computer (MIT): a desk you reach from anything. The original lives on GitHub.

2 downloads

network-computer/infra/create-aws.sh
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/demo/network-computer.git
HTTPS
https://gitstable.com/git/demo/network-computer.git
SSH
ssh://git@gitstable.com:2222/demo/network-computer.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

GitStable demo README: say this is a copy and where the original is cde82c2 13 hours, 36 minutes ago History
create-aws.sh · 2.3 KB · 44 lines
1#!/bin/sh
2# Create an EC2 instance and provision it.
3# Needs: awscli v2 configured (aws configure).
4# Default region us-east-2 (Ohio, ~25-30ms from Houston, simplest).
5# For the Houston Local Zone (single-digit ms) see the notes in infra/README.md.
6# Usage: infra/create-aws.sh [name] [region] [type]
7set -e
8NAME=${1:-nc-ohio}; REGION=${2:-us-east-2}; TYPE=${3:-t3.medium}
9DIR=$(dirname "$0")
10command -v aws >/dev/null || { echo "install awscli: brew install awscli && aws configure"; exit 1; }
11
12echo "resolving latest Ubuntu 24.04 AMI in $REGION..."
13AMI=$(aws ec2 describe-images --region "$REGION" --owners 099720109477 \
14 --filters "Name=name,Values=ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-amd64-server-*" \
15 --query 'sort_by(Images,&CreationDate)[-1].ImageId' --output text)
16[ "$AMI" != None ] || { echo "no Ubuntu 24.04 AMI found"; exit 1; }
17
18# import the local SSH key
19KEYNAME=nc-$(hostname -s)
20aws ec2 import-key-pair --region "$REGION" --key-name "$KEYNAME" \
21 --public-key-material "fileb://$HOME/.ssh/id_ed25519.pub" 2>/dev/null || true
22
23# security group with the ports the host needs
24SG=$(aws ec2 create-security-group --region "$REGION" --group-name nc-$NAME \
25 --description "network-computer" --query GroupId --output text 2>/dev/null || \
26 aws ec2 describe-security-groups --region "$REGION" --group-names nc-$NAME --query 'SecurityGroups[0].GroupId' --output text)
27for r in "tcp 22" "tcp 8765" "udp 3478" "udp 49152-65535"; do
28 set -- $r
29 aws ec2 authorize-security-group-ingress --region "$REGION" --group-id "$SG" \
30 --ip-permissions "IpProtocol=$1,FromPort=${2%-*},ToPort=${2#*-},IpRanges=[{CidrIp=0.0.0.0/0}]" 2>/dev/null || true
31done
32
33echo "launching $TYPE from $AMI..."
34IID=$(aws ec2 run-instances --region "$REGION" --image-id "$AMI" --instance-type "$TYPE" \
35 --key-name "$KEYNAME" --security-group-ids "$SG" \
36 --block-device-mappings 'DeviceName=/dev/sda1,Ebs={VolumeSize=30}' \
37 --tag-specifications "ResourceType=instance,Tags=[{Key=Name,Value=$NAME}]" \
38 --query 'Instances[0].InstanceId' --output text)
39echo "instance $IID, waiting for public ip..."
40aws ec2 wait instance-running --region "$REGION" --instance-ids "$IID"
41IP=$(aws ec2 describe-instances --region "$REGION" --instance-ids "$IID" \
42 --query 'Reservations[0].Instances[0].PublicIpAddress' --output text)
43echo "ip: $IP"
44sh "$DIR/provision-host.sh" "$IP" "$NAME" ubuntu