brunch

You can make anything
by writing

C.S.Lewis

by Master Seo Sep 19. 2024

AWS 53탄-8.디폴트에 EC2 1대-클라우드포메이션

1

디폴트 서브넷에 EC2 1대 생성하자



2

디폴트 서브넷 필요



3

ec2 키페어 1개 필요



4

cloudformation 사용




5

WebServer 라고 만들어짐



6

보안그룹 확인

http 허용 , ssh 허용  되어 있음.


7

로그온


웹 데몬 확인



8

CF 파일  내용



Parameters:

  KeyName:

    Description: Name of an existing EC2 KeyPair to enable SSH access to the instances. Linked to AWS Parameter

    Type: AWS::EC2::KeyPair::KeyName

    ConstraintDescription: must be the name of an existing EC2 KeyPair.

Resources:

  MyInstance:

    Type: AWS::EC2::Instance

    Properties:

      ImageId: ami-0094965d55b3bb1ff

      InstanceType: t2.micro

      KeyName: !Ref KeyName

      Tags:

        - Key: Name

          Value: WebServer

      SecurityGroups:

        - !Ref MySG

      UserData:

        Fn::Base64:

          !Sub |

            #!/bin/bash

            yum install httpd -y

            systemctl start httpd

            echo "<h1>Test Web Server</h1>" > /var/www/html/index.html

  MySG:

    Type: AWS::EC2::SecurityGroup

    Properties:

      GroupDescription: Enable HTTP access via port 80 and SSH access via port 22

      SecurityGroupIngress:

      - IpProtocol: tcp

        FromPort: 80

        ToPort: 80

        CidrIp: 0.0.0.0/0

      - IpProtocol: tcp

        FromPort: 22

        ToPort: 22

        CidrIp: 0.0.0.0/0



브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari