Skip to content

Instantly share code, notes, and snippets.

@rybons
rybons / az-cli-helpers.sh
Created March 10, 2022 20:28
Azure CLI Helpers
az_list(){
az account list --output table
}
az_sub(){
if [ "$1" = "" ]
then
echo "Usage: az_sub <subscription-id>"
return 1
fi
@rybons
rybons / choco-myfile.ps1
Created May 13, 2019 08:47
install chocolatey and create myfile
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
C:/ProgramData/chocolatey/choco install git -y
# Create myfile:
${var1} | Set-Content 'myfile.txt'
@rybons
rybons / user-data.tf
Last active March 15, 2024 23:03
user data terraform example
data "template_file" "windows_script" {
template = "${file("${path.module}/templates/windows_script.ps1")}"
vars {
var1 = "${var.var1}"
}
}
resource "aws_instance" "myinstance" {
connection {
type = "winrm"
@rybons
rybons / windows_script.ps1
Created May 13, 2019 08:31
install chocolatey through powershell
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
C:/ProgramData/chocolatey/choco install git -y
@rybons
rybons / windows_script.ps1
Last active March 15, 2024 23:04
remote winrm script example
$ips = $args[0]
Foreach ($ip in $ips) {
$Username = '{0}\Administrator' -f $ip
$Password = '${password}'
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
Set-Item wsman:\localhost\client\trustedhosts $ip -Confirm:$false -Force
Invoke-Command -ComputerName $ip -ScriptBlock { Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) } -credential $Cred
@rybons
rybons / null-connection.tf
Last active March 15, 2024 23:05
null_resource bastion example
data "template_file" "windows_script" {
template = "${file("${path.module}/templates/windows_script.ps1")}"
vars {
password = "${var.windows_password}"
}
}
resource "aws_instance" "myinstance" {}
resource "null_resource" "provision" {
@rybons
rybons / lnx-connection.tf
Last active March 15, 2024 23:05
Sample of Linux connection with bastion info
data "template_file" "lnx_script" {
template = "${file("${path.module}/templates/lnx_script.sh")}"
vars {
var1 = "${var.var1}"
}
}
resource "aws_instance" "myinstance" {
connection {
type = "ssh"
@rybons
rybons / win-connection.tf
Last active March 15, 2024 23:06
Sample Terraform winrm connection block
data "template_file" "windows_script" {
template = "${file("${path.module}/templates/windows_script.ps1")}"
vars {
var1 = "${var.var1}"
}
}
resource "aws_instance" "myinstance" {
connection {
type = "winrm"
@rybons
rybons / gist:7ed7db867d4638170121c7979c371ef9
Created May 13, 2019 06:39
Sample Terraform connection block
resource "aws_instance" "myinstance" {
connection {
user = "${var.user}"
private_key = "${file("${var.key_pair_file}")}"
bastion_host = "${var.bastion_host}"
bastion_user = "${var.bastion_user}"
bastion_private_key = "${file("${var.bastion_key_pair_file}")}"
}