Skip to content
This repository was archived by the owner on Jul 20, 2024. It is now read-only.

Commit 4052699

Browse files
authored
Do not open ssh by default (#4)
1 parent 7466a62 commit 4052699

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,31 @@ module "nat" {
4040
```
4141

4242

43+
### Extra configuration
44+
45+
You can open SSH port to the NAT instance.
46+
47+
```tf
48+
resource "aws_security_group_rule" "nat_ssh" {
49+
security_group_id = module.nat.sg_id
50+
type = "ingress"
51+
cidr_blocks = ["0.0.0.0/0"]
52+
from_port = 22
53+
to_port = 22
54+
protocol = "tcp"
55+
}
56+
```
57+
58+
You can attach an extra policy to the IAM role of the NAT instance.
59+
60+
```tf
61+
resource "aws_iam_role_policy_attachment" "nat_iam_example" {
62+
policy_arn = "arn:aws:iam::aws:policy/SOME_POLICY_NAME"
63+
role = module.nat.iam_role_name
64+
}
65+
```
66+
67+
4368
## How it works
4469

4570
This module will create the following resources:

main.tf

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ resource "aws_security_group_rule" "ingress" {
2525
protocol = "tcp"
2626
}
2727

28-
resource "aws_security_group_rule" "ssh" {
29-
count = var.key_name == "" ? 0 : 1
30-
security_group_id = aws_security_group.this.id
31-
type = "ingress"
32-
cidr_blocks = ["0.0.0.0/0"]
33-
from_port = 22
34-
to_port = 22
35-
protocol = "tcp"
36-
}
37-
3828
resource "aws_network_interface" "this" {
3929
security_groups = [aws_security_group.this.id]
4030
subnet_id = var.public_subnet

0 commit comments

Comments
 (0)