0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

EC2に立てたubuntu機を開発用マシンとして使いたいときに便利なEC2のユーザデータ

Posted at
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive

# リポジトリ安定性向上のために追加
sudo apt-get update
sudo apt-get install -y \
    apt-transport-https \
    software-properties-common \
    ca-certificates \
    curl \
    gnupg

# Docker
# Add Docker's official GPG key:
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
  | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
  https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo \"$VERSION_CODENAME\") stable" \
  | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

sudo apt-get install -y \
    docker-ce \
    docker-ce-cli \
    containerd.io \
    docker-buildx-plugin \
    docker-compose-plugin

# Add user to docker group
sudo gpasswd -a ubuntu docker
echo "※ docker グループへの追加後は、ログアウト→再ログイン か 下記コマンドの実行で反映してください:"
echo "    newgrp docker"

# Nodejs
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs

# awscli
sudo apt install -y unzip
pushd /tmp
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
popd
rm -rf /tmp/awscliv2.zip /tmp/aws

# aws-cdk
npm install -g aws-cdk

# pipx
sudo apt install -y pipx

# Other utilities
sudo apt-get install -y \
    bash-completion \
    git \
    postgresql-client \
    tree

# uv (Astral UV) のインストール
sudo -u ubuntu pipx install uv
sudo -u ubuntu /bin/bash -c \
    'uv completions bash >> /home/ubuntu/.bash_completion'

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?