LoginSignup
2
4

More than 5 years have passed since last update.

AWS CLIからCloudFormationを利用する(個人的なメモ)

Last updated at Posted at 2019-03-15

IAMへCloudFormation実行ユーザーを作成する

  1. AWSコンソールへログインし「サービス」→「セキュリティ、アイデンティティ、コンプライアンス」→「
    IAM」を選択する

  2. 「個々のIAM ユーザーの作成」→「ユーザーの管理」を選択する

  3. 「ユーザーを追加」を選択する

  4. 「ユーザー名」へユーザー名を入力、「アクセスの種類」で「プログラムによるアクセス」へチェックを入れ「次のステップ: アクセス権限」を実行する

  5. CloudFormationフルアクセスポリシーを作成する(自分で作成する必要がある)

file
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "VisualEditor0",
      "Effect": "Allow",
      "Action": "cloudformation:*",
      "Resource": "*"
    }
  ]
}
  1. EC2フルアクセス等必要なポリシーとCloudFormationフルアクセスのポリシーをユーザーに付与する

  2. ユーザーを作成しCredentialsをダウンロードする(もしくはメモする)

AWS CLIの設定を行う

一般ユーザーにて行う方が良いと思われる。また場合によってはCloudFormation実行用ユーザーのプロファイルで設定した方が良いと思われる。

$ aws configure --profile your-profile-name
AWS Access Key ID [None]: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
AWS Secret Access Key [None]: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Default region name [None]: ap-northeast-1
Default output format [None]: json

操作方法

一般ユーザーにて行う方が良いと思われる。また場合によってはCloudFormation実行用ユーザーのプロファイルで設定した方が良いと思われる。

$ #スタックを作成する 
$ aws cloudformation create-stack --stack-name stack-name --template-body file://stack.yml --profile cfn-user
$
$ #スタックを削除する 
$ aws cloudformation delete-stack --stack-name stack-name --profile cfn-user
2
4
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
2
4