feat: add security rules to aws EC2

This commit is contained in:
Pierre Mavro
2022-04-22 19:58:06 +02:00
parent 0f193fbde5
commit d18d8e745a
3 changed files with 17 additions and 8 deletions

View File

@@ -13,15 +13,22 @@ resource "aws_security_group" "ec2_cluster" {
tags = local.tags_ec2
}
# OPTIONAL: Allow inbound traffic from your local workstation external IP
# to the Kubernetes. You will need to replace A.B.C.D below with
# your real IP. Services like icanhazip.com can help you find this.
resource "aws_security_group_rule" "cluster_ingress_workstation_https" {
cidr_blocks = var.ec2_access_cidr_blocks
description = "Allow workstation to communicate with the cluster API Server"
resource "aws_security_group_rule" "https" {
cidr_blocks = "0.0.0.0/0"
description = "HTTPS connectivity"
from_port = 443
protocol = "tcp"
security_group_id = aws_security_group.ec2_cluster.id
to_port = 443
type = "ingress"
}
resource "aws_security_group_rule" "ssh" {
cidr_blocks = "0.0.0.0/0"
description = "SSH remote access"
from_port = 22
protocol = "tcp"
security_group_id = aws_security_group.ec2_cluster.id
to_port = 22
type = "ssh"
}

View File

@@ -31,7 +31,9 @@ resource "aws_instance" "web" {
associate_public_ip_address = true
# security
#vpc_security_group_ids = [aws_vpc.ec2.*.id]
vpc_security_group_ids = [aws_vpc.ec2.id]
subnet_id = aws_subnet.ec2_zone_a.id
security_groups = [aws_security_group.ec2_cluster.id]
user_data = local.bootstrap

View File

@@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.66.0"
version = "~> 4.11.0"
}
external = {
source = "hashicorp/external"