Skip to content

Terraform module to get the public IP of the terraform caller

Notifications You must be signed in to change notification settings

touilleio/terraform-public-ip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Public IP Modiule

Terraform module which compute the public IP address from host where terraform is running

Very useful to allow restricted SSH inbound traffic to a small subnet, if not a /32.

Usage example

module "myip" {
  source = "github.com/touilleio/terraform-public-ip"
  # Optional set a netmask, default to 32
  netmask = 24
}

resource "aws_security_group" "ssh_ingress" {
  name        = "ssh-from-myip"
  description = "ssh access from myip"
  vpc_id      = module.vpc.vpc_id
  ingress {
    from_port   = 22
    to_port     = 22
    protocol    = "tcp"
    cidr_blocks = [module.myip.cidr]
  }
}

Testing

cd ./test
terraform init
terraform plan
terraform apply

About

Terraform module to get the public IP of the terraform caller

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages