Every instance sits inside a security group: a firewall that decides what may come in. A new security group lets nothing in. Each inbound rule opens one door:
| Part of a rule | Means | For a website |
|---|---|---|
| protocol | how it talks | tcp |
| port | which door | 80, for web pages |
| source | who may come in | 0.0.0.0/0, anyone |
Visitoranyone
tcp, port 80
Security groupis there a rule for it?
yes: let it in
Web serveranswers
Replies go back out on their own; you only write rules for what comes in.
New command
aws ec2 authorize-security-group-ingress
Adds an inbound rule to a security group. Ingress means coming in.
Usageaws ec2 authorize-security-group-ingress --group-id sg-id --protocol tcp --port port --cidr source
Example
aws ec2 authorize-security-group-ingress --group-id sg-0123456789abcdef0 --protocol tcp --port 443 --cidr 0.0.0.0/0
A blocked port doesn't say no: it says nothing. curl -m 5 gives up after 5 seconds instead of waiting for minutes.