LoginSignup
3
0

More than 1 year has passed since last update.

「コンテナの中に入って確かめて」と言われたら。。

Last updated at Posted at 2022-03-01

とりあえずコンテナの中に入りたい。

ドキュメント

ドキュメント読んでもわからないよ...。

下準備

  • Session Manager plugin のインストール

  • ログイン情報を保存しておく(aws configureに認証情報を保存する)
    ↓↓↓↓

ログイン情報設定・確認のコマンドまとめ

全ての認証情報を確認

 % vim ~/.aws/credentials

Cursor_と_nagaikanae_—vim____aws_credentials—_207×26.png

sampleという認証情報の作成

% aws configure --profile=sample

Cursor_と_nagaikanae_—-zsh—_207×26.png
もう一度叩くと正しく設定されたかを確認することができる

Cursor_と_nagaikanae_—aws_configure--profile_sample_—_207×26.png

現在の認証情報の確認

% aws configure list

defaultが呼ばれているみたい。
Cursor_と_nagaikanae_—-zsh—_207×30.png

使いたい認証情報の設定

管理の方法は複数あるが自分は環境変数で設定している。

% export AWS_PROFILE=sample

現在の認証情報がsampleになったか確認

% aws configure list

Cursor_と_nagaikanae_—-zsh—_207×30.png

コンテナの中に入る

クラスター名:sample-php
タスクid:xxxxxxxxxxxxxxxxxx0
コンテナ名: web
% aws ecs execute-command --cluster sample-php \
    --task xxxxxxxxxxxxxxxxxx0 \
    --container web \
    --interactive --profile=sample\
    --command "/bin/sh"

コンテナの中に入る時は、オプションでprofileを指定できるが、環境変数ごと変更しておくことでECRにpushするときの思わぬエラーなどを防ぐことができる。aws cliを使うときは、profileを変更しておいた方が吉だと思う。

どうしてもExecできないとき↓↓↓

3
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
3
0