使用私钥创建打包程序后,AWS AMI无法检索密码

时间:2018-08-07 09:22:43

标签: passwords windows-server-2012-r2 private-key ami packer

我正在使用打包程序构建Windows服务器AMI。使用硬编码的密码可以正常工作,但是我尝试创建AMI,以便自动生成密码。我尝试了以下建议,并且打包程序日志看起来不错,它获得了密码。

How to create windows image in packer using the keypair enter image description here

但是,当我从terraform的AMI中创建EC2实例时,与Windows密码的连接丢失并且无法检索。这里缺少什么?

打包json

{  
  "builders": [
    {
      "profile" : "blah",
      "type": "amazon-ebs",
      "region": "eu-west-1",
      "instance_type": "t2.micro",
      "source_ami_filter": {
        "filters": {
          "virtualization-type": "hvm",
          "name": "*Windows_Server-2012-R2*English-64Bit-Base*",
          "root-device-type": "ebs"
        },
        "most_recent": true,
        "owners": "amazon"
      },
      "ssh_keypair_name" : "shared.key",
      "ssh_private_key_file" : "./common/sharedkey.pem",
      "ssh_agent_auth" : "true",
      "ami_name": "test-{{timestamp}}",
      "user_data_file": "./common/bootstrap_win.txt",
      "communicator": "winrm",
      "winrm_username": "Administrator"      
    }
  ]
}

1 个答案:

答案 0 :(得分:1)

最后添加Ec2Config.exe -sysprep可以。

{
      "type": "windows-shell",
      "inline": ["C:\\progra~1\\Amazon\\Ec2ConfigService\\Ec2Config.exe -sysprep"]
}

尽管要注意,在sysprep之后,我的IIS配置似乎无法正常工作。

相关问题