zoukankan      html  css  js  c++  java
  • deploy a ec2 and join into domain with terraform

    Below is the example to convert the ps script into userdata for terraform to create instance and auto join domain.  But to make it work, we need to create a new DHCP options set for related VPC and have the domain-name= domain.com and domain-name-servers =  IP-of-the-domain-controllers .  so default DNS servers for new instance in that VPC will be domain controllers.  

    resource "aws_instance" "example" {
      ami           = "${lookup(var.amis, var.region)}"
      instance_type = "t2.micro"
      subnet_id     = "subnet-fe179a00"
      vpc_security_group_ids      = ["sg-b93c9100"]
      key_name       = "newkey"
      provisioner "local-exec" {
        command = "echo ${aws_instance.example.public_ip} > ip_address.txt"
      }
      user_data = "<powershell>$Domain = 'domain.com'; $Username = 'domain\admin' ; $Password = 'xxxxxxxx' ; $pwd = $Password | ConvertTo-SecureString -asPlainText -Force ;  $credential = New-Object System.Management.Automation.PSCredential($UserName,$pwd) ;Add-Computer -DomainName $Domain -Credential $credential -Restart</powershell>"
    }
  • 相关阅读:
    spring中的Filter使用
    跨站脚本(XSS)攻击
    RepeatSubmitInterceptor extends HandlerInterceptorAdapter
    理解TCP
    Github(第一次尝试)
    MVC(实战二:网址映射)
    MVC(实战一)
    MVC(基础二)
    WinFrom和WebFrom的区别
    MVC(基础一)
  • 原文地址:https://www.cnblogs.com/oskb/p/9369895.html
Copyright © 2011-2022 走看看