Skip to content

Instantly share code, notes, and snippets.

babakc

Block or report user

Report or block babakc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View SQLMirRds.json
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "",
"Parameters": {
},
"Resources": {
"RDSDBI3N4HT": {
"Type": "AWS::RDS::DBInstance",
"Properties": {
"AllocatedStorage": "200",
View SysprepInstance.ps1
# 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
View startup.ps1
#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
View flows.json
"Flows": {
"Flows": [
"(ApplicationEventLog,SystemEventLog,DSCLog),CloudWatchEventLogs",
"EC2ConfigLog,EC2ConfigLogs",
"cfninitLog,cfninitLogs"
]
}
View loggroups.json
{
"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}"
}
View bootstrap.json
{
"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"
View EventLogs.json
{
"Id": "ApplicationEventLog",
"FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"LogName": "Application",
"Levels": "7"
}
},
{
"Id": "SystemEventLog",
View CWrole.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:DescribeLogGroups",
"logs:DescribeLogStreams",
View AWS.EC2.Windows.CloudWatch.json
{
"EngineConfiguration": {
"PollInterval": "00:00:15",
"Components": [
{
"Id": "ApplicationEventLog",
"FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"LogName": "Application",
"Levels": "7"
View set-cloudwatch.ps1
$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"
You can’t perform that action at this time.