
1. What's Security Groups
▶ Security Groups are the fundamental of network security.
▶ They control how traffic is allowed into or out of our EC2 Instances.
⭐ Security groups only contain allow rules
- 허용규칙만 포함되므로 무엇이 들어가고 나가는 지 알 수 있다.
⭐ Security groups rules can reference by IP or by security group or other security groups
- 보안 그룹은 IP주소를 기준으로 규칙을 생성한다.
- 또는 다른 보안 그룹을 참조하여 설정할 수 있다. (보안그룹은 서로 참조 가능)
[Example]
We are using computer on the public Internet and trying to access to EC2 Instance
- Whether EC2 Instance can perform Inbound traffic andOut bound traffic.


2. Security Groups
▶ Security groups are acting as a "firewall" on EC2 instances.
▶ Regulate
- Access to Ports
- Authorised IP ranges - IPv4 and IPv6
- Control of inbound network (from other to the instance)
- Control of outbound network (from the instance to other)
3. Security Groups Diagram (How firewall works)

▶ Here's EC2 Instance which has one inbound rule and outbound rule in single security group attached to it.
Inbound
▶ case1_My computer is authorized on port 22 -> traffic can go thru EC2 Instance
▶ case2_Someone else's computer that is not using my IP address -> traffic can't go thru EC2 Instance
by Firewall, and It will be TimeOut
Outbound
▶ case3_ by default allowing any traffic going out of EC2 Instance
- So if EC2 Instance is trying to access any web site and initiate connection it's allowed by the Security group.
4. Security Groups - Details
▶ Can be attached to multiple instances.
- There's not a one-to-one relationship between security groups.
▶ An Instance can have multiple secutiry groups.
▶ Locked down to a region / VPC combination
- 따라서 다른 지역으로 전환하거나, 다른 VPC 생성하면 보안 그룹을 다시 생성해야 한다.
▶ Does Exist "OUTSIDE" of the EC2 - if traffic is blocked the EC2 instance won't see it.
- 트래픽이 차단되면 EC2 인스턴스는 트래픽을 볼 수가 없다.
- EC2 에서 실행되는 애플리케이션과는 다르며 실제로는 일종의 EC2 외부의 방화벽이다.
▶ If your application is not accessible (time out), then i t's a security group issue.
- 만약에 임의의 포트에 연결하려고 하는데 컴퓨터가 정지하고 대기하고 있다면 아마도 보안그룹 문제일 가능성이 높음다.
▶ If your application gives a "connection refused" error, it's an application error or i t's not launched
- 하지만 연결 거부 오류가 발생하면 실제로 연결이 거부되었다는 응답을 받게 된다.
- 실제로는 보안 그룹이 작동하고 트래픽이 통과했지만 애플리케이션이 오류가 나거나 실행되지 않은 것이다.
⭐ SEPERATE security group for SSH access
- SSH 액세스를 위해서만 별도의 보안 그룹을 하나 유지하는 것이 좋다.
⭐ All inbound traffic is blocekd and All outbound traffic is authorised by default
- 기본적으로 모든 인바운드 트래픽은 차단되고 모든 아웃바운드 트래픽은 승인된다.
5. How to reference Security Group from other Security groups
▶ 로드 밸런서를 사용하기 시작했다면 정말 좋은 기능

▶ Here's EC2 Instance and Secutiry Group1 attached to it.
▶ Security Group 1 has two rules allowing Authrising Security Group1 and Group2
- by doing so basically you can connect other EC2 Instance to EC2 Instance with Security Group 1 directly by Port
- Regardless of Instance's IP of EC2 Instances, because they have the right security group attached to them,
- they're able to communicate to straight thru to other Instances.
6. Classic Ports
알아야 할 포트들
Port Number | For | Explanation | |
22 | SSH | Secure Shell | log into a Linux |
21 | FTP | File Transfer Protocol | |
22 | SFTP | Secure File Transfer Protocol | |
80 | HTTP | access unsecured website | |
443 | HTTPS | 표준 보안 웹사이트 | access secured website |
3389 | RDP | Remote Desktop Protocol | log into a Windows instance |
7. 실습
[EC2 Dashboard] > (Side Menu) [▼Network & Security] > [Security Groups]


▶ Security Group: default
▶ Security group for E2C Instance: launch-wizard-1
- 여기에 있는 launch-wizard-1을 다른 EC2 인스턴스에 첨부할 수도 있다.
- 원하는 개수의 보안 그룹을 첨부할 수 있다.
- 여러 EC2 인스턴스를 하나의 보안 그룹에 할당할 수도 있다.
▶ Inbound rules: 외부에서 EC2 인스턴스로 연결할 수 있게 해주는 규칙

▶ Edit inbound rules

- 첫 번째는 22번 포트의 SSH 로서 어디서나 접속할 수 있다. 즉, 0.0.0.0/0 = Anywhere
- 두 번째는 80번 포트의 HTTP 로 마찬가지로 어디서에서나 접속 가능한 인바운드 규칙
- 만약 Delete 버튼으로 HTTP rule 를 삭제하고 E2C 인스턴스를 구동하면 무한로딩이 되면서 웹서버에 접속할 수 없게 됨.
⭐⭐ TIME OUT 해결법
E2C 인스턴스에 대해 SSH나 HTTP 쿼리로 접속을 시도하고 있지만 성공하지 못하고 결국은 실패하는 경우에 타임아웃을 보게 되면 그건 100% EC2 보안 그룹(Security Group) 때문이다.
따라서 반드시 Security Group 탭으로 가서 그것들이 정확한 지 확인해야 한다.
⭐ Add rule
HTTP Rule 추가 하는 법
[Add rule] > Type: HTTP > Source : Anywhere IPv4 > Save rules
▶ outbound rules
- 모든 곳으로 가는 IPv4의 모든 트래픽을 허용(full internet connection to anywhere)

'AWS' 카테고리의 다른 글
[AWS] Solutions Architect Associate 실습 10일차 - EC2 Instance connect (14) | 2025.01.26 |
---|---|
[AWS] Solutions Architect Associate 실습 9일차 - SSH (9) | 2025.01.25 |
[AWS] Solutions Architect Associate 실습7일차 - AWS EC2 (12) | 2025.01.22 |
[AWS] 실습6일차 - AWS 예산 관리 Billing and Cost Managetment (setting Budget) (9) | 2025.01.22 |
[AWS] 실습5일차 - IAM & IAM CLI 문제 / 정리 (21) | 2025.01.21 |

1. What's Security Groups
▶ Security Groups are the fundamental of network security.
▶ They control how traffic is allowed into or out of our EC2 Instances.
⭐ Security groups only contain allow rules
- 허용규칙만 포함되므로 무엇이 들어가고 나가는 지 알 수 있다.
⭐ Security groups rules can reference by IP or by security group or other security groups
- 보안 그룹은 IP주소를 기준으로 규칙을 생성한다.
- 또는 다른 보안 그룹을 참조하여 설정할 수 있다. (보안그룹은 서로 참조 가능)
[Example]
We are using computer on the public Internet and trying to access to EC2 Instance
- Whether EC2 Instance can perform Inbound traffic andOut bound traffic.


2. Security Groups
▶ Security groups are acting as a "firewall" on EC2 instances.
▶ Regulate
- Access to Ports
- Authorised IP ranges - IPv4 and IPv6
- Control of inbound network (from other to the instance)
- Control of outbound network (from the instance to other)
3. Security Groups Diagram (How firewall works)

▶ Here's EC2 Instance which has one inbound rule and outbound rule in single security group attached to it.
Inbound
▶ case1_My computer is authorized on port 22 -> traffic can go thru EC2 Instance
▶ case2_Someone else's computer that is not using my IP address -> traffic can't go thru EC2 Instance
by Firewall, and It will be TimeOut
Outbound
▶ case3_ by default allowing any traffic going out of EC2 Instance
- So if EC2 Instance is trying to access any web site and initiate connection it's allowed by the Security group.
4. Security Groups - Details
▶ Can be attached to multiple instances.
- There's not a one-to-one relationship between security groups.
▶ An Instance can have multiple secutiry groups.
▶ Locked down to a region / VPC combination
- 따라서 다른 지역으로 전환하거나, 다른 VPC 생성하면 보안 그룹을 다시 생성해야 한다.
▶ Does Exist "OUTSIDE" of the EC2 - if traffic is blocked the EC2 instance won't see it.
- 트래픽이 차단되면 EC2 인스턴스는 트래픽을 볼 수가 없다.
- EC2 에서 실행되는 애플리케이션과는 다르며 실제로는 일종의 EC2 외부의 방화벽이다.
▶ If your application is not accessible (time out), then i t's a security group issue.
- 만약에 임의의 포트에 연결하려고 하는데 컴퓨터가 정지하고 대기하고 있다면 아마도 보안그룹 문제일 가능성이 높음다.
▶ If your application gives a "connection refused" error, it's an application error or i t's not launched
- 하지만 연결 거부 오류가 발생하면 실제로 연결이 거부되었다는 응답을 받게 된다.
- 실제로는 보안 그룹이 작동하고 트래픽이 통과했지만 애플리케이션이 오류가 나거나 실행되지 않은 것이다.
⭐ SEPERATE security group for SSH access
- SSH 액세스를 위해서만 별도의 보안 그룹을 하나 유지하는 것이 좋다.
⭐ All inbound traffic is blocekd and All outbound traffic is authorised by default
- 기본적으로 모든 인바운드 트래픽은 차단되고 모든 아웃바운드 트래픽은 승인된다.
5. How to reference Security Group from other Security groups
▶ 로드 밸런서를 사용하기 시작했다면 정말 좋은 기능

▶ Here's EC2 Instance and Secutiry Group1 attached to it.
▶ Security Group 1 has two rules allowing Authrising Security Group1 and Group2
- by doing so basically you can connect other EC2 Instance to EC2 Instance with Security Group 1 directly by Port
- Regardless of Instance's IP of EC2 Instances, because they have the right security group attached to them,
- they're able to communicate to straight thru to other Instances.
6. Classic Ports
알아야 할 포트들
Port Number | For | Explanation | |
22 | SSH | Secure Shell | log into a Linux |
21 | FTP | File Transfer Protocol | |
22 | SFTP | Secure File Transfer Protocol | |
80 | HTTP | access unsecured website | |
443 | HTTPS | 표준 보안 웹사이트 | access secured website |
3389 | RDP | Remote Desktop Protocol | log into a Windows instance |
7. 실습
[EC2 Dashboard] > (Side Menu) [▼Network & Security] > [Security Groups]


▶ Security Group: default
▶ Security group for E2C Instance: launch-wizard-1
- 여기에 있는 launch-wizard-1을 다른 EC2 인스턴스에 첨부할 수도 있다.
- 원하는 개수의 보안 그룹을 첨부할 수 있다.
- 여러 EC2 인스턴스를 하나의 보안 그룹에 할당할 수도 있다.
▶ Inbound rules: 외부에서 EC2 인스턴스로 연결할 수 있게 해주는 규칙

▶ Edit inbound rules

- 첫 번째는 22번 포트의 SSH 로서 어디서나 접속할 수 있다. 즉, 0.0.0.0/0 = Anywhere
- 두 번째는 80번 포트의 HTTP 로 마찬가지로 어디서에서나 접속 가능한 인바운드 규칙
- 만약 Delete 버튼으로 HTTP rule 를 삭제하고 E2C 인스턴스를 구동하면 무한로딩이 되면서 웹서버에 접속할 수 없게 됨.
⭐⭐ TIME OUT 해결법
E2C 인스턴스에 대해 SSH나 HTTP 쿼리로 접속을 시도하고 있지만 성공하지 못하고 결국은 실패하는 경우에 타임아웃을 보게 되면 그건 100% EC2 보안 그룹(Security Group) 때문이다.
따라서 반드시 Security Group 탭으로 가서 그것들이 정확한 지 확인해야 한다.
⭐ Add rule
HTTP Rule 추가 하는 법
[Add rule] > Type: HTTP > Source : Anywhere IPv4 > Save rules
▶ outbound rules
- 모든 곳으로 가는 IPv4의 모든 트래픽을 허용(full internet connection to anywhere)

'AWS' 카테고리의 다른 글
[AWS] Solutions Architect Associate 실습 10일차 - EC2 Instance connect (14) | 2025.01.26 |
---|---|
[AWS] Solutions Architect Associate 실습 9일차 - SSH (9) | 2025.01.25 |
[AWS] Solutions Architect Associate 실습7일차 - AWS EC2 (12) | 2025.01.22 |
[AWS] 실습6일차 - AWS 예산 관리 Billing and Cost Managetment (setting Budget) (9) | 2025.01.22 |
[AWS] 실습5일차 - IAM & IAM CLI 문제 / 정리 (21) | 2025.01.21 |