{CloudFormation}S3作成

https://dev.classmethod.jp/articles/cloudformation-s3bucket-type/

-- 1. コマンド等のインストール

-- 1.1 aws cli version 2 インストール

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
aws --version

-- 1.2 jqインストール
sudo yum -y install jq

-- 2. スタック作成

vim a.yaml

AWSTemplateFormatVersion: "2010-09-09"
Description: Provision S3

Resources:

  S3Bucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: bucket123

 

aws cloudformation validate-template \
--template-body file://a.yaml


aws cloudformation create-stack \
--stack-name stack01 \
--template-body file://a.yaml

 


-- 3. スタック一覧

aws cloudformation list-stacks

aws cloudformation describe-stacks \
--stack-name stack01

-- 4. スタックリソース一覧

aws cloudformation describe-stack-resources \
--stack-name stack01

 

-- 5. クリーンアップ

-- スタック削除
aws cloudformation delete-stack \
--stack-name stack01

aws s3 ls