简体   繁体   English

从 ASG 获取私人 IP

[英]Get Private IP from ASG

I need to output private IP from Auto Scaling Group of EC2 instance that configuration by Terraform. How can i get private IP from ASG?我需要 output private IP 来自 EC2 实例的 Auto Scaling Group,该实例由 Terraform 配置。如何从 ASG 获得私有 IP?

 # Launch config for ASG resource "aws_launch_configuration" "asg_conf" { name = "ASG-Conf-${var.env}" image_id = data.aws_ami.ubuntu.id # Get image from data instance_type = var.instance_type # use t2.micro ad default security_groups = [var.sg_app.id, var.sg_alb.id] # SG for APP key_name = var.ssh_key # SSH key for connection to EC2 user_data = file("./modules/ec2/shell/apache.sh") # install apache lifecycle { create_before_destroy = true } } # Auto Scaling Group resource "aws_autoscaling_group" "asg" { count = length(var.private_su.net_id) # count numbers of private su.nets name = "ASG-${var.env}-${count.index + 1}" vpc_zone_identifier = [var.private_su.net_id[count.index]] launch_configuration = aws_launch_configuration.asg_conf.name target_group_arns = [var.alb_target.arn] min_size = 1 # Min size of creating EC2 max_size = 1 # Max size of creating EC2 health_check_grace_period = 120 health_check_type = "ELB" force_delete = true lifecycle { create_before_destroy = true } tag { key = "Name" value = "Webserver-ec2-${count.index + 1}" propagate_at_launch = true } } output { # How can i get this??? value = aws_autoscaling_group.asg.private_ip }

My infrastructure create 1 EC2 instance in 2 private AZ by ASG and i need output IP from this ASG我的基础设施通过 ASG 在 2 个私有 AZ 中创建 1 个 EC2 实例,我需要来自这个 ASG 的 output IP

You need custom data source to get the IPs.您需要自定义数据源来获取 IP。 But this really does not make much sense as instances in ASG can be changed by AWS at any time, thus making your IPs obsolete.但这真的没有多大意义,因为 ASG 中的实例可以随时被 AWS 更改,从而使您的 IP 过时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从 elb 在私人 su.net 中访问 ASG 的问题 - Problem with accessing ASG in private subnet from elb ARM 模板 - 从 a.network interface id 获取私有地址 ip - ARM Template - Get a private ip address from a network interface id Terraform gcp 获取实例的内部私有 ip 并写入文件 - Terraform gcp get internal private ip of instance and write to file Ansible 剧本获取我的 AWS 环境的所有私有 Ip - Ansible playbook to get all private Ip of my AWS environments 无法使用私有 IP 从 ECS 访问 PostgresSQL RDS - Can't access PostgresSQL RDS from ECS using private IP 目标 VPC 服务器 FROM 公共服务器的私有 IP 地址 - Target VPC server FROM the private IP address of a public server 如何使用 Python 和私有 IP 从 GKE 连接到 Cloud SQL - How to connect from GKE to Cloud SQL using Python and Private IP AWS CLI 命令未从 Varaible 中选择 ASG 名称 - AWS CLI commands is not picking the ASG name from Varaible 是否可以基于域或 IP 对私有 S3 文件进行 GET 访问? - Is it possible to have a GET access to private S3 files based on domain or IP? 使用私有 IP 连接到 Postgres - Connecting to Postgres using private IP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM