Skip to content

Instantly share code, notes, and snippets.

@calum-github
calum-github / JavaEssentials.pkg
Created January 16, 2015 01:36
Java 2014-001 scripts
These are the scripts from the JavaEssentials.pkg
## Allow incoming access to our instance via
## port 22, from the IAP servers
resource "google_compute_firewall" "inbound-ip-ssh" {
name = "allow-incoming-access-from-iap"
project = var.project_id
network = "default"
direction = "INGRESS"
allow {
protocol = "tcp"
# Define the required roles to access the VM
locals {
compute_roles = [
"roles/compute.viewer",
"roles/compute.osLogin",
]
}
# Apply the roles to a user account
resource "google_project_iam_member" "assign-roles" {
# Create a conditional IAM rule that grants access to establish an IAP tunnel
# IF the user is connecting from an authorised network defined in the access
# list
resource "google_iap_tunnel_iam_member" "allow-remote-access-to-iap" {
project = "<your-project-id>"
role = "roles/iap.tunnelResourceAccessor"
member = "user:calum.hunter@the.cloud"
condition {
title = "allow_remote_access_to_iap"
# Creates an Access Level
# This access level will be used in
# a conditional IAM policy to restrict access
# to authorised users coming from authorised networks
resource "google_access_context_manager_access_level" "access-level" {
parent = "accessPolicies/<access-policy-id>"
name = "accessPolicies/<access-policy-id>/accessLevels/<my_access_level_name>"
title = "secure-iap-access-level"
description = "This access level lists the authorised network addresses"
## Allow incoming access to our instance via
## port 22, from the IAP servers
resource "google_compute_firewall" "inbound-ip-ssh" {
name = "allow-incoming-ssh-from-iap"
project = var.project_id
network = "default"
direction = "INGRESS"
allow {
protocol = "tcp"
# Create an instance
resource "google_compute_instance" "my-instance" {
project = var.project_id
name = "my-instance-01"
machine_type = "e2-standard-2"
zone = var.zone
boot_disk {
initialize_params {
image = "debian-cloud/debian-9"
@calum-github
calum-github / format_hd.sh
Last active August 10, 2020 21:20
Disk formatter
#!/bin/bash
########################################################################
# Author: Calum Hunter #
# Date: 21/12/2016 #
# Version: 0.7 #
# Purpose: Fusion Drive Detection and general HD formatting before #
# imaging tasks. #
# #
########################################################################
@calum-github
calum-github / convert.sh
Last active July 23, 2020 23:35
AD Plugin UID calculation from ObjectGUID
#!/bin/bash
#
# Author: Calum Hunter
# Date: 28/11/2016
# Version: 1.0
# Purpose: To generate a Mac UID from the objectGUID attribute
# (GeneratedUID) in AD.
# This uses the same method that the Apple
# AD Plugin uses
@calum-github
calum-github / gist:6ea1c80d31568dcd114367e864c3f3f1
Created February 28, 2019 23:26
Route53 Terraform example
// Manage DNS
// Create a private route53 zone
resource "aws_route53_zone" "this" {
name = "${var.dns_zone_name}"
vpc_id = "${var.vpc_id}"
}
// Create a dns record for the jenkins master private ip
resource "aws_route53_record" "master" {
zone_id = "${aws_route53_zone.this.id}"