Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in AWS by (5.6k points)

I want to create AWS security group rule resource "aws_security_group_rule", and then want to attach it to AWS EC2 Windows instance and be able to RDP into it from anywhere.

sg.tf

resource "aws_security_group" "My_VPC_Security_Group" {

  vpc_id       = aws_vpc.My_VPC.id

  name         = "My VPC Security Group"

  description  = "My VPC Security Group"

Can anyone help me with this?

1 Answer

0 votes
by (12.4k points)

You need to use the following where "3389" will be the default RDP port:

resource "aws_security_group" "My_VPC_Security_Group" {

  vpc_id       = aws_vpc.My_VPC.id

  name         = "My VPC Security Group"

  description  = "My VPC Security Group"

  ingress {

    from_port   = 3389

    to_port     = 3389

    protocol    = "tcp"

    cidr_blocks = ["0.0.0.0/0"]

  }  

  egress {

    from_port   = 0

    to_port     = 0

    protocol    = "-1"

    cidr_blocks = ["0.0.0.0/0"]

}

Do you want to learn more about AWS? Checkout AWS developer associate certification by Intellipaat! 

You can even checkout the below video tutorial to learn more about Terraform.

Related questions

0 votes
1 answer

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
0 votes
1 answer

Browse Categories

...