Skip to content

Instantly share code, notes, and snippets.

View jhanley-com's full-sized avatar

John J. Hanley jhanley-com

View GitHub Profile
@jhanley-com
jhanley-com / recommender_example.py
Created June 14, 2021 23:59
Python example demonstrating the Google Cloud Compute Recommender list recommendations api
# pip install google-cloud-recommender
from google.cloud import recommender
import os
# Enter values for your Project ID and Zone
PROJECT=
LOCATION=
RECOMMENDER = 'google.compute.instance.MachineTypeRecommender'
# This script is used in my article about Terraform, Google Cloud DNS and Cloud IAM.
# https://www.jhanley.com/terraform-experiments-with-google-cloud-dns-and-iam/
######################################################################
# Terraform
######################################################################
terraform {
required_version = ">= 0.14.7"
}
@jhanley-com
jhanley-com / tclean.bat
Created March 7, 2021 22:49
Windows batch script to cleanup a Terraform project
IF exist .terraform (rd /s /q .terraform)
IF exist terraform.tfstate.d (rd /s /q terraform.tfstate.d)
IF exist .terraform.lock.hcl (del .terraform.lock.hcl)
IF exist terraform.tfstate (del terraform.tfstate)
IF exist terraform.tfstate.backup (del terraform.tfstate.backup)
@jhanley-com
jhanley-com / main.tf
Last active January 6, 2021 02:56
Terraform Azure Service Principal - Part 2
# Test code for the question: https://stackoverflow.com/q/65525116/8016720
# Provides configuration details for Terraform
terraform {
required_version = ">= 0.14.3, < 0.15.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>2.41"
@jhanley-com
jhanley-com / main.tf
Last active December 15, 2021 16:45
Terraform Azure Service Principal - Part 1
# Test code for the question: https://stackoverflow.com/q/65525116/8016720
# Provides configuration details for the Azure Terraform provider
provider "azurerm" {
# !!! Must include features even if empty
features {}
}
variable "appName" { default = "testAppName" }
variable "subscriptionId" { default = "" }
APIKEY='your_cloud_api_key'
URI='https://clients.hostwinds.com/cloud/api.php'
FILENAME='instances.json'
if [ -f $FILENAME ];
then
rm $FILENAME
fi
curl $URI \
@set APIKEY=your_cloud_api_key
@set URI=https://clients.hostwinds.com/cloud/api.php
@set FILENAME=instances.json
@if exist %FILENAME% del %FILENAME%
@curl %URI% ^
-sS ^
-X POST ^
-d "action=get_instances&API=%APIKEY%" > %FILENAME%