Wednesday, May 20, 2020

What does the timeouts in terraform do ?

timeouts {
    create = "25m"
} 

This function inside the main terraform script sets the configurable timeout value.

If we set it to 5m then following will be the output

timeouts {
    create  =  "5m"
} 


As the instances were not provisioned in 5min, the terraform apply terminated.
oci_core_instance.TFInstance: Still creating... [4m40s elapsed]
oci_core_instance.TFInstance: Still creating... [4m50s elapsed]
oci_core_instance.TFInstance: Still creating... [5m0s elapsed]

Error: timeout while waiting for state to become 'RUNNING' (last state: 'PROVISIONING', timeout: 5m0s)

  on instance.tf line 16, in resource "oci_core_instance" "TFInstance":
  16: resource "oci_core_instance" "TFInstance"{



Base recovery requirements - RPO and RTO



What is Recovery Point Objective (RPO)
- Tolerance for data loss
- How frequently should backups be taken ?

What is Recovery Time objective (RTO)
- Tolerance for downtime
- Downtime = Problem Identification + recovery planning + systems recovery
- Tiered RTO per level of granularity ( database, tablespace, table, row )
- Determine backup retention policy for on-site, off-site, and long-term backups.
- Retention policy can be configured based upon recovery window or Redundancy.

What is the criteria to assess the recovery requirements properly?
- You should first determine how critical a database is to the business when lost or unavailable?
- How much will the company loose per hour of downtime ?
- How much will be lost in productivity and labor costs if the database is down ?

How to classify databases according to criticality of availability (RTO)
- A large data warehouse can tolerate 12 hours worth of lost data, because batch loads can be re-run.
- An OLTP system cannot tolerate a downtime of even few minutes, as it results in the loss of $100,000 per hour of revenue. You will need to consider Data Guard here.

How to classify databases based upon how much data loss is acceptable (RPO)
- Are there databases that require more frequent backups ?
- Is there an adequate disk space available for archived logs ?

How to classify databases based on RTO?
- Is it minutes or hours ?
- Do you have a combined disk and tape backup strategy ? Based on this assess the retention period for backups. 

Friday, May 1, 2020

Powershell mention a simple if else statement



$x = "$InstallationFolder/file.dat"

if($x -eq $x) {
   Write-Host "file.dat file exists"
}else {
   Write-Host "file.dat does not file exists"
}

Friday, March 27, 2020

powershell cmdlet Copy-Item overwrites the existing files


Tested successfully
In Powershell, the cmdlet
Copy-Item overwrites the existing files

Copy-Item "C:\test\test.conf" -Destination "C:\conf\test.conf"

The above command will overwrite C:\conf\test.conf file with C:\test\test.conf

Monday, March 9, 2020

AWS Windows Image - Automating the install of Corretto

C:\installer\corretto.msi - Location of the MSI file
C:\corretto - Installation Directory

Start-Process "msiexec.exe" -ArgumentList "/i C:\installer\corretto.msi INSTALLDIR=""C:\corretto"" /qb!" -NoNewWindow -Wait

Friday, February 28, 2020

Add timestamp to your Cloud instance in Packer

You can declare a variable as below and use it builders.

"myvar2": "Packer-Image-{{isotime \"2006-01-02 03-04-05\"}}",


I have tried it on OCI Instance and worked fine.

We will obtain a Custom Image with timestamp set to UTC.

Thursday, February 27, 2020

Powershell script before you start download of objects from OCI Object Storage in a Windows Image



add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
    public bool CheckValidationResult(
        ServicePoint srvPoint, X509Certificate certificate,
        WebRequest request, int certificateProblem) {
        return true;
    }
}
"@
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy


Below notes will help you understand what these commands does

The System.Net namespace provides a simple programming interface for many of the protocols used on networks today.
The WebRequest and WebResponse classes form the basis of what are called pluggable protocols, an implementation of network services that enables you to develop applications that use Internet resources without worrying about the specific details of the individual protocols.

The System.Security.Cryptography.X509Certificates namespace contains the common language runtime implementation of the Authenticode X.509 v.3 certificate. This certificate is signed with a private key that uniquely and positively identifies the holder of the certificate.