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>"
}

deploy a ec2 and join into domain with terraform的更多相关文章

  1. Join to domain powershell script

    Join to domain powershell script $username = "domain\admin" $Password = "xxxxxxxx&quo ...

  2. How to join a Ubuntu to Windows Domain

    My testing environment: Windows Server 2012 R2 Essentials: With AD and standalone DC in one single b ...

  3. [CENTOS7] 加入Windows域

    This following article is a snapshot from: https://www.rootusers.com/how-to-join-centos-linux-to-an- ...

  4. python getopt.getopt 不能精确匹配的问题

    代码:opts,argv = getopt.getopt(sys.argv[1:],('u:'),['ad','join','passwd=','domain=','dip=','test','ip= ...

  5. git泄漏原理

    之前做过git的加固 但是这东西还是没办法避免的 之前看了乌云的提交的git泄漏,但是都没有详细的原理,去了lijiejie的博客(字太难打了,大师傅别打我 哈哈) 如果一个网站存在git泄漏,git ...

  6. IIS Shared Configuration

    Introduction The Internet changes the ways in which companies handle their day-to-day business and h ...

  7. 【转载】Shared Configuration

    Introduction The Internet changes the ways in which companies handle their day-to-day business and h ...

  8. Enabling Active Directory Authentication for VMWare Server running on Linux《转载》

    Enabling Active Directory Authentication for VMWare Server running on Linux Version 0.2 - Adam Breid ...

  9. .net程序实现给机器加域,添加域账号到本地管理员

    以下.net代码中共有两个方法. AddComputerToDomain实现给把本计算机添加到某个域中 AddDomainUserToLocalAdminGroup实现把域中某用户添加到本地管理员 请 ...

随机推荐

  1. 使用 MySQL 存储 Hue 元数据

    1.在 MySQL 中增加数据库 hue 2.编辑 hue.ini 文件 [[database]] # Database engine is typically one of: # postgresq ...

  2. WCF入门三[WCF宿主]

    一.概述 WCF程序必须在宿主上运行,也就是WCF服务必须寄宿在某一个windows的进程中,可以是IIS.控制台程序.窗体程序.WAS以及所有.net程序等程序进程中.在我用VS2013创建WCF服 ...

  3. vi编辑图

    vi使用方法

  4. [网站日志]今天早上遭遇的CPU 100%情况

    今天早上9:06左右,Windows性能监视器监测到主站的Web服务器出现了CPU 100%的情况,伴随着Requests/Sec的上升,详见下图. 上图中红色线条表示的是%Processor Tim ...

  5. Java测试工具和框架

    个人目前只接触过JUnit以及Powermock,后续会关注更多有关测试这方面的东西 8个超实用的Java测试工具和框架_开发/数据库_IT专家网 http://database.ctocio.com ...

  6. 「日常训练」Our Tanya is Crying Out Loud (CFR466D2B)

    题意(Codeforces 940B) 对一个数字$x$,你有两个决策:花费$A$减一.或花费$B$除以$k$(但必须可以除尽).问使之到$1$的最少花费. 分析 贼鸡儿简单,但我花式犯蠢……如果除不 ...

  7. PowerDesigner 使用记录

    使用PowerDesigner 16.5 设计数据库表结构的操作过程: 第一步:打开PowerDesigner工具 第二步:创建一个新的数据模型,选择 File -> New Model -&g ...

  8. Linux-Shell脚本编程-学习-7-总结前面开启后面的学习

    国庆前期后国庆回来也都比较忙,把书一放下,在那起来,就难了,发现好多都开始忘记了,今天好不容易硬着头片看来两章,算是马马虎虎的把前面的基础性质的只是看完了吧. 后面讲开始学习Shell编程的高级阶段, ...

  9. C#下16进制和BCD码转换代码

        private static Byte[] ConvertFrom(string strTemp) { try { if (Convert.ToBoolean(strTemp.Length & ...

  10. 梳理 Opengl ES 3.0 (一)宏观着眼

    Opengl ES 可以理解为是在嵌入式设备上工作的一层用于处理图形显示的软件,是Opengl 的缩水版本. 下图是它的工作流程示意图: 注意图中手机左边的EGL Layer Opengl ES是跨平 ...