Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Terraform AWS How use Security Group's port another that 22 for SSH

I want using another SG’s port for SSH, not 22, but i get error.
For example:

resource "aws_security_group" "ws_sg" {
    name = "WS SG"
    vpc_id = "${aws_vpc.ws_net.id}"
    tags = {
      "Name" = "WS SG"
    }
}

resource "aws_security_group_rule" "inbound_ssh" {
    from_port = 28
    protocol = "TCP"
    security_group_id = aws_security_group.ws_sg.id
    to_port = 22
    type = "ingress"
    cidr_blocks = [ "0.0.0.0/0" ]
}

resource "aws_security_group_rule" "egress" {
    from_port = 0
    protocol = "all"
    security_group_id = aws_security_group.ws_sg.id
    to_port = 0
    type = "egress"
    cidr_blocks = [ "0.0.0.0/0" ]
}

How fix it?

P.S. Maybee, this happing because i have free account?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You mixed up your ports. Instead of

   from_port = 28
   to_port = 22

it should be:

   from_port = 22
   to_port = 28
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading