インフラエンジニア徒然日記

なんちゃってインフラエンジニアです。てきとーに日々のことを記載します。

AWS利用準備

久々更新してみようかと思います。

 

仕事でAWSを利用することになったので、超簡単にIAMからインスタンス立てるまで

記載してみます。※自分のメモ程度

 

★IAMユーザ作成
※rootユーザは基本的に利用しない。
●MFA設定(2段階認証)
・Andoroid/Iphone
 googleAuthenticator
 https://qiita.com/macoshita/items/06e2a2474bc8eca1a67d
Windows
 WinAuth
 https://dev.classmethod.jp/cloud/aws/winauth/

・IAMグループ
・IAMポリシーをIAMグループに割り当て(管理ポリシーかカスタムポリシーを付与)
・IAMアカウント作成し、IAMグループに割り当て
・IAMロールを作成。(EC2インスタンスに割り当て用)
 →とりあえず「AmazonEC2FullAccess」、「AmazonS3FullAccess」を付与


★AWSCLIをUbuntsu16にインストール。
AMI:Ubuntu Server 16.04 LTS (HVM), SSD Volume Type - ami-0d74386b
使用するKeyPairは事前に作成。
インスタンス起動後、ubuntuユーザ、作成したKeypairでログイン。
※初めてUbuntsuに触るものだから四苦八苦。
参考にしたURL:
https://qiita.com/TatchNicolas/items/ca6b8007d914bdef3662
https://qiita.com/TKYK38/items/2a73696a9d8f1f856f68
https://qiita.com/TKYK38/items/62879bc7e4257ba5a642


$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.4 LTS"

sudo su -
# aws --version
The program 'aws' is currently not installed. You can install it by typing:
apt install awscli

# python -V
The program 'python' can be found in the following packages:
* python-minimal
* python3
Try: apt install <selected package>

# apt install python
$ python --version
Python 2.7.12

# wget https://bootstrap.pypa.io/get-pip.py
# python get-pip.py
# pip --version
# pip install awscli
# aws --version
aws-cli/1.15.6 Python/2.7.12 Linux/4.4.0-1052-aws botocore/1.10.6

# aws configure ※IAMロールで制御するため、Access KeyとSecretAccess Keyは入れない。
AWS Access Key ID [None]:
AWS Secret Access Key [None]:
Default region name [None]: ap-northeast-1
Default output format [None]: json

# aws ec2 describe-instances
インスタンス一覧が表示されること

・jqコマンドをインストール
#apt -y update
#apt -y install jq