티스토리 뷰

AWS

AWS 클라우드 보안 운영 (1일차)

넷오빠 2025. 9. 22. 16:40

#AWS

강사 : 이한기 강사
이메일 : itssp0405@gmail.com

교육 1일차

1. 퍼블릭 클라우드 보안 이해

1) 1교시

과금관리

  • 온디멘드
  • 가장 보편적인 종량제 방식 (짧은 기간 사용) 요금이 가장 비쌈 약정 없음
  • 예약 인스턴스
  • 긴 워크로드 약정 할인 개념 요금 할인이 되나 해약시 위약금 발생 중간에 유형변경 불가
  • 가변 예약 인스턴스

중간에 인스턴스 자원을 스케일 업/다운 가능
비용 할인율이 예약 인스턴스보다 적음



- 스케쥴 예약 인스턴스

워크로드 사용 요일 or 시간 설정 가능
특정 시간 고가/고성능의 워크로드 운영가능
할인율이 적음


- 스팟 인스턴스

짧은 워크로드
비용이 가장 효율적인 과금제
경매 입찰 방식으로 인스턴스 할당 사용
비동기식 서비스에 적합(DB 서버는 비추)


- 전용 호스트

전체 물리서버 제공
가장 비싼 요금





#### 2. 클라우드 보안 공동책임 모델 이해

#### 3. 프리티어 계정 및 가상머신 서비스 요금 관리

#### 4. 가상 네트워크 보안 구축 및 피어링 설정


> 리전

ap-northeast-2 서울 리전 (VPC; 172.31.0.0/16)
ap-northeast-2a 일산 가용 영역 (AZ; IDC - subnet; 172.31.0.0/20)
ap-northeast-2b 목동
ap-northeast-2c 수원
ap-northeast-2d 안양


- AWS 에서의 방화벽
  • NACL : 서브넷 단위
  • SG : 인스턴스 단위


> main route table
- 명시적 연결(association)
pub-rtb - pub-sub

- attatch
ig 와 vpc 연결

* AZ : availability Zone (리전 격리 영역)

- 송신용 연결
priv-rtb - priv-sub


- vpc 생성 및 서브넷 설정

my-pvc
my-pub-2a 10.0.0/0/20
my-pub-2b 10.0.16.0/20
my-pub-2c 10.0.32.0/20
my-pub-2d 10.0.48.0/20



-igw 생성
my-igw


- cloudshell 사용법

key-fair 생성하기

aws ec2 create-key-pair --key-name my-key --query 'KeyMaterial' --output text > my-key.pem ##교환키생성

chmod 400 my-key.pem ## 키값 권한변경

ssh -i my-key.pem ec2-user@54.180.229.2 ## ssh 접속

sudo timedatectl set-timezone Asia/Seoul ##시간변경

sudo dnf install -y httpd ## 웹서비스 설치

sudo systemctl enable --now httpd ## 웹활성화

curl ipconfig.io ## ip확인


- VPC 피어링 연결 

서로 다른 세그먼트(다른 IP대역)어야 가능
PCX 연결은 무료지만 Gbyte 당 data transfer 비용 발생(outboud만 해당)

작업순서

  1. 한쪽 리전에서 연결요청
  2. 반대편 리전에서 수락
  3. 연결성립
  4. 라우팅 테이블 설정
  5. 피어링 연결

VPC 피어링 연결 요청 수락
정보

이 VPC 피어링 연결 요청(pcx-01854e0a20693f0fb)을 수락하시겠습니까?

요청자 VPC
vpc-0b6df592ed7a1ee73
수락자 CIDR

요청자 소유자 ID
422619739319(현재 계정)
수락자 VPC
vpc-0b74ea93da3d680fc
요청자 리전
서울 (ap-northeast-2)
수락자 소유자 ID
422619739319(현재 계정)








#### 5. 자동화 도구를 활용한 클라우드 보안 인프라 구축

- CloudFormation (CF) : 자동화 도구

오픈스택(heat)과 동일

자동화 생성 프롬프트

  1. 이름 태그 new-vpc, 전체 주소 범위 192.168.0.0/16로 vpc 생성하고 DNS 호스트 이름 활성화.
  2. 이름 태그 new-pub-2a, 2b, 2c, 2d, 서브넷 주소 범위는 20bit로 subnet 생성하고 new-pub-2a, 2b, 2c, 2d는 퍼블릭 IPv4 주소 자동 할당 활성화.
  3. 이름 태그 new-igw, internet gateway 생성하고 new-vpc와 연결.
  4. 이름 태그 new-pub-rtb, route table 생성하고 0.0.0.0/0을 목적지로 인터넷 게이트웨이를 대상으로 설정, new-pub-2a, 2b, 2c, 2d와 명시적 연결.

ex)
curl ec2-57-180-24-109.ap-northeast-1.compute.amazonaws.com

[AWSTemplateFormatVersion: '2010-09-09'

Resources:

1. VPC

NewVPC: # 논리적 ID
Type: AWS::EC2::VPC
Properties:
CidrBlock: 192.168.0.0/16
EnableDnsSupport: true
EnableDnsHostnames: true
Tags:
- Key: Name
Value: new-vpc

2. Internet Gateway

InternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: new-igw

AttachGateway:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref NewVPC
InternetGatewayId: !Ref InternetGateway

3. Public Subnets

PublicSubnet2a:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref NewVPC
CidrBlock: 192.168.0.0/20
AvailabilityZone: ap-northeast-2a
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: new-pub-2a

PublicSubnet2b:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref NewVPC
CidrBlock: 192.168.16.0/20
AvailabilityZone: ap-northeast-2b
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: new-pub-2b

PublicSubnet2c:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref NewVPC
CidrBlock: 192.168.32.0/20
AvailabilityZone: ap-northeast-2c
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: new-pub-2c

PublicSubnet2d:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref NewVPC
CidrBlock: 192.168.48.0/20
AvailabilityZone: ap-northeast-2d
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: new-pub-2d

4. Route Table

PublicRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref NewVPC
Tags:
- Key: Name
Value: new-pub-rtb

5. Default Route to IGW

DefaultRoute:
Type: AWS::EC2::Route
DependsOn: AttachGateway
Properties:
RouteTableId: !Ref PublicRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway

6. Associate Subnets with Route Table

PubSubnet2aRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet2a
RouteTableId: !Ref PublicRouteTable

PubSubnet2bRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet2b
RouteTableId: !Ref PublicRouteTable

PubSubnet2cRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet2c
RouteTableId: !Ref PublicRouteTable

PubSubnet2dRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet2d
RouteTableId: !Ref PublicRouteTable](AWSTemplateFormatVersion: '2010-09-09'

Resources:

1. VPC

NewVPC: # 논리적 ID
Type: AWS::EC2::VPC
Properties:
CidrBlock: 192.168.0.0/16
EnableDnsSupport: true
EnableDnsHostnames: true
Tags:
- Key: Name
Value: new-vpc

2. Internet Gateway

InternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: new-igw

AttachGateway:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref NewVPC
InternetGatewayId: !Ref InternetGateway

3. Public Subnets

PublicSubnet2a:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref NewVPC
CidrBlock: 192.168.0.0/20
AvailabilityZone: ap-northeast-2a
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: new-pub-2a

PublicSubnet2b:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref NewVPC
CidrBlock: 192.168.16.0/20
AvailabilityZone: ap-northeast-2b
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: new-pub-2b

PublicSubnet2c:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref NewVPC
CidrBlock: 192.168.32.0/20
AvailabilityZone: ap-northeast-2c
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: new-pub-2c

PublicSubnet2d:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref NewVPC
CidrBlock: 192.168.48.0/20
AvailabilityZone: ap-northeast-2d
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: new-pub-2d

4. Route Table

PublicRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref NewVPC
Tags:
- Key: Name
Value: new-pub-rtb

5. Default Route to IGW

DefaultRoute:
Type: AWS::EC2::Route
DependsOn: AttachGateway
Properties:
RouteTableId: !Ref PublicRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway

6. Associate Subnets with Route Table

PubSubnet2aRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet2a
RouteTableId: !Ref PublicRouteTable

PubSubnet2bRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet2b
RouteTableId: !Ref PublicRouteTable

PubSubnet2cRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet2c
RouteTableId: !Ref PublicRouteTable

PubSubnet2dRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet2d
RouteTableId: !Ref PublicRouteTable)



- S3 버킷 설정

버킷 확인

aws s3 ls

버킷 이름 생성

이름은 고유값이어야 함

aws s3 mb s3://yblmmen

버킷에 upload

aws s3 cp new-vpc.txt s3://yblmmen/

upload 상태 확인

aws s3 ls s3://yblmmen/new-vpc.txt


- 자동화도구 생성순서

IAC -> yaml -> cloudformation -> ouput - VPC 생성


- 챗GPT 프롬프트

AWS cloudfomation에서 적용할 자동화 스크립트를 작성해줘

  1. 이름 태그 new-vpc, 전체 주소 범위 192.168.0.0/16로 vpc 생성하고 DNS 호스트 이름 활성화.
  2. 이름 태그 new-pub-2a, 2b, 2c, 2d, 서브넷 주소 범위는 20bit로 subnet 생성하고 new-pub-2a, 2b, 2c, 2d는 퍼블릭 IPv4 주소 자동 할당 활성화.
  3. 이름 태그 new-igw, internet gateway 생성하고 new-vpc와 연결.
  4. 이름 태그 new-pub-rtb, route table 생성하고 0.0.0.0/0을 목적지로 인터넷 게이트웨이를 대상으로 설정, new-pub-2a, 2b, 2c, 2d와 명시적 연결.
  • IAM 사용자, 그룹, 역할, 다요소 인증

    # 약자
    Identity(=Authentication, 인증) and Access(=Authorization, 접근권한) Management

Users : ID/PW
Group : user별 등급(ex: dev, ops, user, ...etc)
Role : 일기, 쓰기, 동기, 비동기 권한 설정

적용 예제

'AWS' 카테고리의 다른 글

AWS 클라우드 운영 - 4일차(1)  (0) 2025.09.25
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2026/06   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함