본문 바로가기
카테고리 없음

AWS) CloudFormation

by 빈스터디 2023. 3. 17.

프로비저닝

코드로 만들어 놓은 다음에 필요할 때 다시 만들어주는 것

 

CloudFormation > 스택생성 

 

-> 다양한 서비스들을 만들 수도 있고, 한 번에 삭제할 수도 있다.

 

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/GettingStarted.Walkthrough.html

 

Get started - AWS CloudFormation

Get started With the right template, you can deploy at once all the AWS resources you need for an application. In this section, you'll examine a template that declares the resources for a WordPress blog, creates a WordPress blog as a stack, monitors the st

docs.aws.amazon.com

이거 읽어보기

 

JSON(데이터를 주고 받을 때)과 YAML(속성파일을 설정할 때) 파일로 만들 수 있다.

YAML 파일에서 들여쓰기를 할 때는 띄어쓰기를 2번 해준다.

 

YAML 파일 최상단에 템플릿의 버전이 들어가야한다.

실질적으로 들어가는 내용은 Resources안에 들어간다.

보안그룹의 VPC와 생성하는 EC2의 VPC를 맞춰줘야한다.

AWSTemplateFormatVersion: "2010-09-09"
Description:
  Create EC2

Parameters:
  KeyName:
    Type: 'AWS::EC2::KeyPair::KeyName'
  InstanceType:
    Type: String
    Default: t2.micro
    AllowedValues:
      - t1.micro
      - t2.micro
      - m1.large

Resources:
  TestServer:
    Type: 'AWS::EC2::Instance'
    Properties:
      KeyName: !Ref KeyName
      ImageId: [AMI]
      InstanceType: !Ref InstanceType
      SecurityGroupIds:
        - [Security Group]