How do I set in the security group section my public_ip? Like curl ifconfig.me?
I just want to allow SSH from my IP.
Do you have any idea how can I accomplished that?
In you aws_security_group resource, you can specify allowed IPs using cidr_block. For example:
resource"aws_security_group""ubuntu"{name="ubuntu-security-group"description="Allow SSH only for 1.1.1.1"ingress{description="SSH"from_port=22to_port=22protocol="tcp"cidr_blocks=["1.1.1.1/32"]}}
I was thinking in somehow my .tf files execute and save the value of a command to accomplish that, I'd to replace the ["1.1.1.1/32"] to 'curl ifconfig.me'.
data"external""script"{program=["bash","./get_ip.sh"]// get_ip.sh is your script name}resource"aws_security_group""ubuntu"{name="ubuntu-security-group"description="Allow SSH only for 1.1.1.1"ingress{description="SSH"from_port=22to_port=22protocol="tcp"cidr_blocks=["${data.external.script.result}/32"]}}
How do I set in the security group section my public_ip? Like curl ifconfig.me?
I just want to allow SSH from my IP.
Do you have any idea how can I accomplished that?
In you
aws_security_group
resource, you can specify allowed IPs usingcidr_block
. For example:I was thinking in somehow my .tf files execute and save the value of a command to accomplish that, I'd to replace the ["1.1.1.1/32"] to 'curl ifconfig.me'.
i see. i have not tested it, but theoretically you can do something like that:
WOW - That's nice, I'm going try it! Thank you!!!