Skip to content

Instantly share code, notes, and snippets.

@himlohiya
Last active November 30, 2018 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save himlohiya/4e94a61f08a710da84a914760c15d9dc to your computer and use it in GitHub Desktop.
Save himlohiya/4e94a61f08a710da84a914760c15d9dc to your computer and use it in GitHub Desktop.
data "aws_ip_ranges" "european_ec2" {
regions = [
"eu-west-1",
"eu-central-1"
]
services = [
"ec2"
]
}
resource "aws_security_group" "allow-ssh" {
vpc_id = "${aws_vpc.main.id}"
name = "allow-ssh"
description = "security group that allows ssh and all egress traffic"
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = [
"0.0.0.0/0",
"${data.aws_ip_ranges.european_ec2.cidr_blocks}"
]
}
tags {
Name = "allow-ssh",
CreateDate = "${data.aws_ip_ranges.european_ec2.create_date}",
SyncToken = "${data.aws_ip_ranges.european_ec2.sync_token}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment