【问题标题】:Elastic IP for autoscaling group terraform用于自动缩放组 terraform 的弹性 IP
【发布时间】:2019-12-17 17:58:31
【问题描述】:

在不使用负载平衡器的情况下,在自动缩放组上使用相同 ip 的最佳方法是什么? 我需要使用 route53 子域路由到自动缩放组上的实例。

现在我尝试将弹性 ip 关联到网络接口

我有这个:

resource "aws_eip" "one_vault" {
  vpc                       = true
  network_interface         = "${aws_network_interface.same.id}"
  associate_with_private_ip = "10.0.1.232"
}

resource "aws_network_interface" "same_ip" {
  subnet_id   = "subnet-567uhbnmkiu"
  private_ips = ["10.0.1.16"]
}

resource "aws_launch_configuration" "launch_config" {
  image_id = "${var.ami}"
  key_name = "${var.keyname}"


}

【问题讨论】:

  • 问题不清楚。请尝试使用您使用aws_eip resource的代码添加更多信息。

标签: amazon-web-services amazon-ec2 terraform


【解决方案1】:

Terraform 不支持此功能,因为自动缩放组由 AWS 等云提供商管理,而不是由它管理。 更多细节: https://github.com/hashicorp/terraform/issues/7060

【讨论】:

    【解决方案2】:

    您必须在您的用户数据中执行此操作。 https://forums.aws.amazon.com/thread.jspa?threadID=52601

    #!/bin/bash
     
    # configure AWS
    aws configure set aws_access_key_id {MY_ACCESS_KEY}
    aws configure set aws_secret_access_key {MY_SECRET_KEY}
    aws configure set region {MY_REGION}
     
    # associate Elastic IP
    INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
    ALLOCATION_ID={MY_EIP_ALLOC_ID}
    aws ec2 associate-address --instance-id $INSTANCE_ID --allocation-id $ALLOCATION_ID --allow-reassociation
    

    【讨论】:

      猜你喜欢
      • 2019-01-05
      • 2019-05-14
      • 2017-10-20
      • 2021-10-26
      • 2021-04-12
      • 2021-08-22
      • 2018-02-10
      • 2017-04-17
      • 2021-09-07
      相关资源
      最近更新 更多