LoginSignup
1
1

More than 1 year has passed since last update.

CloudFormationで遊んでみる(EC2編)

Posted at

記事作成にあたって

インフラ環境の開発や運用コスト、保守性を考慮して、最近流行りのIaCを意識している。
今まで触ったやつだと、ServerlessFrameworkやAmplify。
リファレンス読んでてもしっくりこないなぁって思ってたら、上記2つはCloudFormationを使っている。
だkら、CloudFormation理解してないとそれは深い理解につながっていかんなぁという事で、
今回、遊んでみる事にしました。

実装

今回はEC2インスタンスを作って見ます。作って見てから、コードの解説をしていきます!!

ec2.yml
AWSTemplateFormatVersion: '2010-09-09'

Parameters:
  NamePrefix:
    Type: String
    Description: EC2をテンプレートで作成する
    MinLength: 1
    Default: ec2
  InstanceType:
    Type: String
    Description: EC2のインスタンス
    MinLength: 1
    Default: t2.micro

Resources:
  MyInstance:
    Type: 'AWS::EC2::Instance'
    Properties:
      InstanceType: !Ref InstanceType
      ImageId: ami-4af5022c
      Tags:
        - Key: Name
          Value: !Sub "${NamePrefix}-ec2" 

AWSマネジメントコンソールでの操作

スクリーンショット 2021-08-03 14.01.59.png

スクリーンショット 2021-08-03 14.05.36.png

スクリーンショット 2021-08-03 14.07.12.png

スクリーンショット 2021-08-03 14.08.25.png

スクリーンショット 2021-08-03 14.08.34.png

スクリーンショット 2021-08-03 14.10.29.png

1
1
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
1
1