This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"EC2" : { | |
"Type": "AWS::EC2::Instance", | |
"Metadata": { | |
"AWS::CloudFormation::Init": { | |
"configSets": { | |
"config": [ | |
"monitoring", | |
"setup", | |
"rename", | |
"install", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$EC2SettingsFile="C:\Program Files\Amazon\Ec2ConfigService\Settings\Config.xml" | |
$xml = [xml](get-content $EC2SettingsFile) | |
$xmlElement = $xml.get_DocumentElement() | |
$xmlElementToModify = $xmlElement.Plugins | |
foreach ($element in $xmlElementToModify.Plugin) | |
{ | |
if ($element.name -eq "AWS.EC2.Windows.CloudWatch.PlugIn") | |
{ | |
$element.State="Enabled" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"EngineConfiguration": { | |
"PollInterval": "00:00:15", | |
"Components": [ | |
{ | |
"Id": "ApplicationEventLog", | |
"FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch", | |
"Parameters": { | |
"LogName": "Application", | |
"Levels": "7" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"logs:CreateLogGroup", | |
"logs:CreateLogStream", | |
"logs:DescribeLogGroups", | |
"logs:DescribeLogStreams", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Id": "ApplicationEventLog", | |
"FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch", | |
"Parameters": { | |
"LogName": "Application", | |
"Levels": "7" | |
} | |
}, | |
{ | |
"Id": "SystemEventLog", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Id": "cfninitLog", | |
"FullName": "AWS.EC2.Windows.CloudWatch.CustomLog.CustomLogInputComponent,AWS.EC2.Windows.CloudWatch", | |
"Parameters": { | |
"LogDirectoryPath": "C:\\cfn\\log", | |
"TimestampFormat": "yyyy-MM-dd HH:mm:ss,fff", | |
"Encoding": "UTF-8", | |
"Filter": "cfn-init.log", | |
"CultureName": "en-US", | |
"TimeZoneKind": "Local" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Id": "CloudWatchEventLogs", | |
"FullName": "AWS.EC2.Windows.CloudWatch.CloudWatchLogsOutput,AWS.EC2.Windows.CloudWatch", | |
"Parameters": { | |
"AccessKey": "", | |
"SecretKey": "", | |
"Region": "ap-southeast-2", | |
"LogGroup": "Event-Log-Group", | |
"LogStream": "{instance_id}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Flows": { | |
"Flows": [ | |
"(ApplicationEventLog,SystemEventLog,DSCLog),CloudWatchEventLogs", | |
"EC2ConfigLog,EC2ConfigLogs", | |
"cfninitLog,cfninitLogs" | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Set my hostname based on my internal IP address | |
$instanceName = (((Invoke-WebRequest -UseBasicParsing -Uri http://169.254.169.254/latest/meta-data/hostname).Content).split(".")[0]).replace("ip-172-31","TCG") | |
#Change the hostname in the unattend.xml file | |
$filePath = "C:\Windows\Panther\Unattend.xml" | |
$AnswerFile = [xml](Get-Content -Path $filePath) | |
$ns = New-Object System.Xml.XmlNamespaceManager($answerFile.NameTable) | |
$ns.AddNamespace("ns", $AnswerFile.DocumentElement.NamespaceURI) | |
$ComputerName = $AnswerFile.SelectSingleNode('/ns:unattend/ns:settings[@pass="specialize"]/ns:component[@name="Microsoft-Windows-Shell-Setup"]/ns:ComputerName', $ns) | |
$ComputerName.InnerText = $InstanceName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Finally, perform sysprep. | |
# Start sysprep but quit instead of shutdown | |
Start-Process -FilePath $sysprepPath -ArgumentList ("/oobe /quit /generalize `"/unattend:{0}`"" -f $answerFilePath) -Wait -NoNewWindow | |
# Replace windeploy.exe with the custom PowerShell startup script | |
Set-ItemProperty -Path HKLM:\System\setup -Name CmdLine -Value "powershell.exe -command c:\Scripts\startup.ps1" | |
# Delete the existing route to query instance metadata | |
route delete 169.254.169.254 |
OlderNewer