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>"
}
deploy a ec2 and join into domain with terraform的更多相关文章
- Join to domain powershell script
Join to domain powershell script $username = "domain\admin" $Password = "xxxxxxxx&quo ...
- 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 ...
- [CENTOS7] 加入Windows域
This following article is a snapshot from: https://www.rootusers.com/how-to-join-centos-linux-to-an- ...
- python getopt.getopt 不能精确匹配的问题
代码:opts,argv = getopt.getopt(sys.argv[1:],('u:'),['ad','join','passwd=','domain=','dip=','test','ip= ...
- git泄漏原理
之前做过git的加固 但是这东西还是没办法避免的 之前看了乌云的提交的git泄漏,但是都没有详细的原理,去了lijiejie的博客(字太难打了,大师傅别打我 哈哈) 如果一个网站存在git泄漏,git ...
- IIS Shared Configuration
Introduction The Internet changes the ways in which companies handle their day-to-day business and h ...
- 【转载】Shared Configuration
Introduction The Internet changes the ways in which companies handle their day-to-day business and h ...
- 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 ...
- .net程序实现给机器加域,添加域账号到本地管理员
以下.net代码中共有两个方法. AddComputerToDomain实现给把本计算机添加到某个域中 AddDomainUserToLocalAdminGroup实现把域中某用户添加到本地管理员 请 ...
随机推荐
- CentOS(Linux)安装KETTLE教程 并配置执行定时任务
1,首先是安装jdk,并设置环境变量 采用yum安装可不设置环境变量 2,下载kettle https://sourceforge.net/projects/pentaho/files/Data%20 ...
- 当安装mongodb客户端出现了Failed to load list of databases
在装mongodb最新版(4.1.5开发版)服务后,我用robo3t打开它的时候遇到了这个问题. 最直接的解决办法就是换一个mongodb版本,https://github.com/Studio3T/ ...
- Lambda表达式详解【转】
前言 1.天真热,程序员活着不易,星期天,也要顶着火辣辣的太阳,总结这些东西. 2.夸夸lambda吧:简化了匿名委托的使用,让你让代码更加简洁,优雅.据说它是微软自c#1.0后新增的最重要的功能之一 ...
- 初步学习pg_control文件之十一
接前文 初步学习pg_control文件之十,再看这个 XLogRecPtr prevCheckPoint; /* previous check point record ptr */ 发生了che ...
- java基础 -- Collections.sort的两种用法
/** * @author * @version * 类说明 */ package com.jabberchina.test; import java.util.ArrayList; import j ...
- Hackerrank - The Grid Search
https://www.hackerrank.com/challenges/the-grid-search/forum 今天碰见这题,看见难度是Moderate,觉得应该能半小时内搞定. 读完题目发现 ...
- Django笔记 —— 表单(form)
最近在学习Django,打算玩玩网页后台方面的东西,因为一直很好奇但却没怎么接触过.Django对我来说是一个全新的内容,思路想来也是全新的,或许并不能写得很明白,所以大家就凑合着看吧- 本篇笔记(其 ...
- FJOI 2019 游记
(FJOI 2019 滚粗记) Day 0 早上刷了一些水题,然后就上路了. (画图3D好好玩) 来得晚只有十几分钟时间看考场,于是连试机题都没有Ak. Day 1 果然我还是太菜了 走过来的时候再讨 ...
- 自动化测试--封装JDBCUnit
在进行测试的时候,经常需要对数据库进行操作.我们知道,通过代码与数据库交互,需要以下几步: 1.加载驱动 之前有盆友问我,为什么Selenium操作浏览器的时候,非要下载浏览器驱动?为啥对数据库进行操 ...
- 用JAVA写一个多线程程序,写四个线程,其中二个对一个变量加1,另外二个对一个变量减1
package com.ljn.base; /** * @author lijinnan * @date:2013-9-12 上午9:55:32 */ public class IncDecThrea ...