最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

amazon web services - Update Default Gateway, DNS in AWS EC2 Instance - Terraform - Stack Overflow

programmeradmin0浏览0评论

I am creating ec2 Instance using Terraform and I wanted to update gateway, dns_server in the ec2. I use the following user_data in aws_instance resource of Terraform Code.

user_data = <<-EOT
  #cloud-config
  write_files:
    - path: /etc/cloud.json
      owner: root:root
      permissions: '0644'
      content: |
        {
          "IPaddress": "172.5.134.231",
          "netmask": "255.255.255.0",
          "gateway": "12.5.134.2",
          "dns_servers": ["12.5.134.20"],
          "fqdn": "test.sequence",
          "ntp": ["ntp.test.sequence"],
          "password": "${var.catalyst_center}"
        }
EOT

also I tried the following user_data

user_data = base64encode(templatefile("${path.module}/templates/catalyst_center_user_data.tpl", {
    PASSWORD   = var.catalyst_center
    IP_ADDRESS = "172.5.134.231"
    SUBNET     = "255.255.255.0"
    GATEWAY    = "12.5.134.2"
    DNS_SERVER = "12.5.134.20"
    HOSTNAME   = "test.sequence"
  })
    )
}

where the tpl file contains

{
 "IPaddress": "${IP_ADDRESS}", 
 "netmask": "${SUBNET}",
 "gateway": "${GATEWAY}",
 "dns_servers": ["${DNS_SERVER}"],
 "fqdn" : "${HOSTNAME}",
 "ntp": ["ntp.test.sequence"],
 "password" : "${PASSWORD}"
}

In both the ways, EC2 is getting created but when I perform the command sudo maglev-config update Gateway and DNS Server values are still empty.

发布评论

评论列表(0)

  1. 暂无评论