使用私有ip构建Packer



我正在使用Packer来烘烤一个AMI。通过分配公共ip和临时安全组,它可以很好地工作,但我不想将公共ip分配给临时实例,是否有办法防止它分配公共ip?

data "amazon-ami" "ami_id" {
filters = {
virtualization-type = "hvm"
name                = "APP-Linux-Centos-*"
root-device-type    = "ebs"
}
owners      = ["11223321"]
most_recent = true
region      = "us-east-1"
}
source "amazon-ebs" "instance" {
region      = "us-east-1"
ssh_username  = "ec2-user"
ami_name      = "test12-${uuidv4()}"
source_ami    = "ami-0#####06"
instance_type = "t2.micro"
vpc_id = "vpc-q#####f "
subnet_id = "subnet-q######d"
associate_public_ip_address = false
security_group_ids =["sg-3#####6","sg-f####f"]
}
build {
sources = ["amazon-ebs.instance"]
}

这里我使用

associate_public_ip_address = false

但我仍然看到公共IP被附加,而运行packer构建是否有一种方法来防止实例被分配与公共IP ?

如果您正在使用非默认VPC,那么associate_public_ip_address是不够的(默认情况下它是false)。要在私有ip上构建,还需要使用:

ssh_interface = "private_ip"

相关内容

  • 没有找到相关文章

最新更新