🖊️
Today I Learned
  • Home(ish) for Things I've Learned
  • 🦄General
    • Agile Development
      • Tips for dealing with Humans
      • Definition of Done (DOD)
      • Inclusiveness
      • OKRs
      • Roles
      • 12 Principles of Agile
      • Zettel
      • Cognitive Bias
        • Present Bias
        • Sunk cost fallac
        • Ikea Effect
    • Architecture Development
      • Architectural-"ilities"
      • Architectual Considerations
    • Devops
      • Check The Status of All Services
      • Running Out Of inode Space
      • SSL Certificates Can Cover Multiple Domains
    • Documentation
      • 🧜Mermaid
        • 🧜Mermaid-Flowchart
        • 🧜‍♀️Mermaid-Sequence
        • 🧜‍♂️Mermaid-Gnatt
      • ⬇️Markdown
      • MediaWiki
    • Networking
      • Applications
        • NMAP
        • Scappy
        • TCP Dump
        • Wireshark
      • Common Ports
      • Cabling
      • Protocols
        • BGP
        • EIGRP
        • First Hop Redundancy
        • IEEE 802.1X
        • IEEE 802.11 WLAN
        • IP Security
        • IPv4 Multi-cast
        • IPv4 Subnetting
        • IPv6
        • IS-IS
        • OSPF
        • Point to Point
        • RIP
        • Spanning Tree
      • Technologies
        • Frame Mode MPLS
        • IOS (Cisco)
        • Network Address Translation
        • Quality of Service
        • VLANs
        • VOIP Basics
      • Resolve The Public IP Of A URL
      • Path Of The Packets
      • Determine The IP Address Of A Domain
      • Allow HTTPS Through Your UFW Firewall
      • Allow Cross-Origin Requests To Include Cookies
    • Virtualization
      • Ubuntu
        • Ubuntu Quick Install
        • Hyper-V - Setup an Ubuntu 20.04 vm
        • Virtual Box - Setup an Ubuntu 20.04 vm
        • Virtual Box - Setup an Ubuntu 22.04 vm
      • RedHat
        • Setup RHEL 9.2 Linux vm
      • Fedora
        • Setup Fedora 38 Linux vm
      • Transfer files from Windows to Linux VM
    • Security/Hacking
      • Reference
        • Big Data Security
        • Cryptography
        • Code Reviews
        • Forensic Challenges
        • PenTesting Challenges
        • PKI
        • VOIP
        • Virus Classification
        • VMs and Live CDs
        • Worm Classification
      • Forensics
      • Tests
        • Browser Plugins
        • Infrastructure tests
        • Security Tests
        • Securing Home Computers
        • Web Application Security Test
        • VPN
        • Wireless Network Review
      • Tools
        • Metasploit - 4.5
  • 💻os
    • 🐧linux
      • Reference
      • ubuntu-specific
        • Upgrading Ubuntu
        • Check Ubuntu Version
        • Config ubuntu 20.04 vm for rdp
      • alias
        • Ignore The Alias When Running A Command
      • crypto
        • Generate A SAML Key And Certificate Pair
      • datetime
        • Figure Out The Week Of The Year From The Terminal
        • Show Current System Time And Settings
        • Configure Your Server Timezone
        • Get The Unix Timestamp
        • Touch Access And Modify Times Individually
        • Format And Print The Current Date And Time
      • disk
        • Display Free Disk Space
        • Show Disk Usage For The Current Directory
      • directory
        • Change To That New Directory
        • Check The Current Working Directory
        • Configure cd To Behave Like pushd In Zsh
        • Display The Contents Of A Directory As A Tree
        • Copying Nested Directories With Ditto
        • Globbing For Filenames In Zsh
        • Globbing For All Directories In Zsh
        • Use fzf To Change Directories
        • Show The Size Of Everything In A Directory
        • List The Stack Of Remembered Directories
      • file
        • Copying File Contents To System Paste Buffer
        • Do Not Overwrite Existing Files
        • File Type Info With File
        • Find Files With fd
        • Find Newer Files
        • Get Matching Filenames As Output From Grep
        • Hexdump A Compiled File
        • List Files Ordered By Modification Date
        • List Names Of Files With Matches
        • List Stats For A File
        • Create A File Descriptor with Process Substitution
        • Print Out Files In Reverse
        • Securely Remove Files
        • Print A Range Of Lines For A File With Bat
      • http
        • Curl With Cookies
        • Curling For Headers
        • Curling With Basic Auth Credentials
      • history
        • Jump To The Ends Of Your Shell History
        • Last Argument Of The Last Command
        • Global Substitution On The Previous Command
        • Search History
      • java
        • List The Available JDKs
      • networking
        • Check If A Port Is In Use
        • Kill Everything Running On A Certain Port
        • Map A Domain To localhost
        • List Of Sessions To A Machine
      • package management
        • Get Repo's
        • Hold package version - do not upgrade
        • Install a Specific Version of Package
        • Switch Versions of a Brew Formula
        • Switch between Local & remote packages
      • process
        • PID Of The Current Shell
        • Open The Current Command In An Editor
        • List Parent pid With ps
        • Check If Command Is Executable Before Using
        • Exclude Certain Files From An rsync Run
        • List The Statuses Of All Upstart Jobs
        • Do A Dry Run Of An rsync
        • Where Are The Binaries?
        • Watch This Run Repeatedly
      • shells
        • Change Default Shell For A User
      • terminal
        • Clear The Screen
        • Cat Files With Color Using Bat
        • Display All The Terminal Colors
        • Cat A File With Line Numbers
        • Less With Style
        • View A Web Page In The Terminal
        • Undo Some Command Line Editing
        • Command Line Length Limitations
        • Saying Yes
        • Watch The Difference
      • string
        • Repeat Yourself
      • ssh
        • Killing A Frozen SSH Session
        • Forward Multiple Ports Over SSH
        • SSH Escape Sequences
        • Specify The Language For A File With Bat
        • SSH With Port Forwarding
      • search/query
        • Count The Number Of Matches In A Grep
        • Enable Multi-Select Of Results With fzf
        • Exclude A Directory With Find
        • Find A File Installed By Brew
        • Grep For Files With Multiple Matches
        • Grep For Multiple Patterns
        • Grep For Files Without A Match
        • Partial String Matching In Bash Scripts
        • Only Show The Matches
        • Search Files Specific To A Language
        • Search Man Page Descriptions
        • Show A File Preview When Searching With FZF
        • Use Regex Pattern Matching With Grep
        • Skip Paging If Output Fits On Screen With Less
        • Sort In Numerical Order
      • user
        • List All Users
      • variables
        • All The Environment Variables
        • Compare Two Variables In A Bash Script
        • Provide A Fallback Value For Unset Parameter
        • Check If The First Argument Is Given
    • 🍎mac
      • Access All Screen And Video Capture Options
      • Access System Information On OS X
      • Access Unsupported Screen Resolutions With RDM
      • Clean Up Old Homebrew Files
      • Convert An HEIC Image File To JPG
      • Default Screenshot Location
      • Disable Swipe Navigation For A Specific App
      • Display A Message With Alfred
      • Find The Process Using A Specific Port
      • Gesture For Viewing All Windows Of Current App
      • Insert A Non-Breaking Space Character
      • List All The Say Voices
      • Quickly Type En Dashes And Em Dashes
      • Require Additional JS Libraries In Postman
      • Resize App Windows With AppleScript
      • Resizing Both Corners Of A Window
      • Run A Hardware Check
      • Run AppleScript Commands Inline In The Terminal
      • Set A Window To Its Default Zoom Level
      • Specify App When Opening From Command Line
      • Use Default Screenshot Shortcuts With CleanShot X
      • View All Windows Of The Current App
    • 🪟win
      • Windows Reference
      • powershell
        • Formatting
        • Base64
        • Environment Variables
        • Modules
          • Pwsh Profile
          • Logging.psm1
        • Setup console with posh-git
    • 🚇wsl
      • Install Jupyter in WSL
  • 👩‍💻programmy
    • azure
      • Setup Azure VM Ubuntu Server to be Desktop
      • Azure Cli
        • Azure Repos Export
        • Azure Keyvault
        • Azure Functions
        • Azure Networking
          • Setup VPN Certificates
        • Azure Subscriptions
        • Azure Roles
          • Azure Storage Ac
    • aad
      • AzureAD.Get-Devices
      • Desktop Joining/Trust
    • databases
      • mysql
        • Display Output In A Vertical Format
        • Doing Date Math
        • Dump A Database To A File
        • List Databases And Tables
        • Show Create Statement For A Table
        • Show Tables That Match A Pattern
        • Show Indexes For A Table
      • mongodb
        • Determine The Database Version
        • Dump A Remote Database
        • Get Size Stats For A Collection
        • List Size Stats For All Collections
      • mssql
      • postgres
        • commands
          • Triggers
          • Use A psqlrc File For Common Settings
          • Switch The Running Postgres Server Version
          • Track psql History Separately Per Database
          • Toggling The Pager In PSQL
          • Temporarily Disable Triggers
          • Sets With The Values Command
          • Set A Statement Timeout Threshold For A Session
          • Send A Command To psql
          • Sleeping
          • Set Inclusion With hstore
          • Prepare, Execute, And Deallocate Statements
    • linux
      • Limit Execution Time Of Statements
      • Install Postgres With uuid-ossp Using asdf
      • Find The Location Of Postgres Config Files
      • Find The Data Directory
      • Create hstore From Two Arrays
      • Insert Just The Defaults
      • Stop a Service
      • Is App Installed?
        • Change The Current Directory For psql
        • Check If The Local Server Is Running
        • connections
          • Connect To An RDS PostgreSQL Database
          • Terminating A Connection
          • List Connections To A Database
          • Force SSL When Making A psql Connection
        • Crypto
          • Salt And Hash A Password With pgcrypto
          • Set A Seed For The Random Number Generator
          • Generating UUIDs With pgcrypto
          • Compute The md5 Hash Of A String
          • Compute Hashes With pgcrypto
        • Database Operations
          • List Database Objects With Disk Usage
          • List All The Databases
          • Get The Size Of A Database
          • Dump All Databases To A SQL File
          • Duplicate A Local Database
          • Dump And Restore A Database
          • Create Database Uses Template1
        • DateTime Operations
          • Timestamp Functions
          • Using Intervals To Offset Time
          • Turning Timing On
          • Intervals Of Time By Week
          • Convert A String To A Timestamp
          • Day Of Week For A Date
          • Determining The Age Of Things
          • Day Of Week By Name For A Date
          • Constructing A Range Of Dates
          • Configure The Timezone
        • Functions
          • List All Versions Of A Function
          • Group By The Result Of A Function Call
          • Edit Existing Functions
        • File Operations
          • Extracting Nested JSON Data
          • Export Query Results To A CSV
        • IDE/Display
          • Auto Expanded Display
          • Clear The Screen In psql
          • Clear The Screen In psql (2)
        • Indexing
          • Use Argument Indexes
          • Using Expressions In Indexes
          • Adding Composite Uniqueness Constraints
          • Add Foreign Key Constraint Without A Full Lock
          • Create A Composite Primary Key
          • Create An Index Without Locking The Table
          • Add ON DELETE CASCADE To Foreign Key Constraint
        • Math Operations
          • Two Ways To Compute Factorial
          • Integers In Postgres
          • Generate Series Of Numbers
          • Count The Number Of Trues In An Aggregate Query
          • Count Records By Type
          • Count How Many Records There Are Of Each Type
          • Assumed Radius Of The Earth
          • Compute The Levenshtein Distance Of Two Strings
        • Queries
          • Write A Query Result To File
          • Union All Rows Including Duplicates
          • Truncate All Rows
          • Use Not Valid To Immediately Enforce A Constraint
          • Storing Emails With citext
          • Print The Query Buffer In psql
          • Prevent A Query From Running Too Long
          • Insert A Bunch Of Records With Generate Series
          • Find Records That Have Multiple Associated Records
          • Find Records That Contain Duplicate Values
          • Between Symmetric
          • Difference Between Explain And Explain Analyze
          • Creating Conditional Constraints
          • Aggregate A Column Into An Array
        • Schema
          • pg Prefix Is Reserved For System Schemas
          • List All Columns Of A Specific Type
          • Default Schema
        • Sequence
          • Restart A Sequence
          • Renaming A Sequence
          • List Available Schemas
        • String Operations
          • Two Ways To Escape A Quote In A String
          • Word Count for a Column
          • String Contains Another String
          • Pretty Printing JSONB Rows
          • Pretty Print Data Sizes
          • Escaping String Literals With Dollar Quoting
          • Escaping A Quote In A String
          • Capitalize All The Words
          • A Better Null Display Character
        • Table Operations
          • Restarting Sequences When Truncating Tables
          • Temporary Tables
          • Renaming A Table
          • Truncate Tables With Dependents
          • List All Rows In A Table
          • Get The Size Of A Table
          • Get A Quick Approximate Count Of A Table
          • Fizzbuzz With Common Table Expressions
          • Find Duplicate Records In Table Without Unique Id
          • Create Table Adds A Data Type
          • Check Table For Any Oprhaned Records
        • Types & Operators
          • Special Math Operators
          • The nullif Function
          • Types By Category
          • Shorthand Absolute Value Operator
          • Show All Versions Of An Operator
          • Switch Non-Castable Column Type With Using Clause
          • Remove Not Null Constraint From A Column
          • List Various Kinds Of Objects
          • Max Identifier Length Is 63 Bytes
          • Lower Is Faster Than ilike
          • Is It Null Or Not Null?
          • Getting A Slice Of An Array
          • Get The Size Of An Index
          • Generate A UUID
          • Generate Random UUIDs Without An Extension
          • Determine Types Of JSONB Records
          • Defining Arrays
          • Creating Custom Types
          • Checking The Type Of A Value
          • Checking Inequality
        • User Operations
          • Who Is The Current User
          • List Database Users
      • pgbouncer
        • Backup Databse
        • pgbouncer
    • c#
    • chrome
      • Access A Value Logged To The Console
      • Chrome Supports Many Unix Keyboard Shortcuts
      • Copy Some Data From The Console
      • Duplicate The Current Tab
      • Easier Access To Network Throttling Controls
      • Pretty Print Tabular Data
      • Reference The Selected Node
      • Selecting DOM Elements Faster Than Ever
      • Simulating Various Connection Speeds
      • Toggle Device Mode
      • Toggle Open The Console Drawer
      • View Network Traffic For New Tabs
    • clojure
      • Aggregation Using merge-with
      • Argument Requirements For A Function
      • Combinations Of Items From A Sequence
      • Define Something Only Once
      • Evaluate One Liners With lein-exec
      • Expanding Macros
      • Get The Value Of An Environment Variable
      • List Functions For A Namespace
      • Load A File Into The REPL
      • Mapping With An Index
      • Open JavaDocs
      • Pretty Print The Last Thing
      • Quick Clojure Docs
      • Reductions
      • Set Max Heap Size
      • Specify the Directory of a Shell Command
      • Splitting On Whitespace
      • Swap Two Items in a Vector
      • Try A Clojure Project In The REPL
      • Type of Anything
      • When Overflow Is Desired
    • css
      • Add Fab Icons To Your Site With FontAwesome 5
      • Animate Smoothly Between Two Background Colors
      • Apply Multiple Box Shadows To Single Element
      • Apply Styles Based On Dark-Mode Preferences
      • Apply Styles To The Last Child Of A Specific Type
      • Change The Orientation Of An Image
      • Circular Icons With A Massive Border Radius
      • Clean Up Repetition With :is() Pseudo-Class
      • Conditional Styling For Unsupported CSS Features
      • Create A Pulsing Background With CSS Animation
      • Define CSS Custom Properties With CSS Variables
      • Define HSL Colors With Alpha Values
      • Display Responsive iframe Maintaining Aspect Ratio
      • Dry Up SCSS With Mixins
      • Give Elements The Same Width With Flexbox
      • Let Pointer Events Pass Through An Element
      • Lighten And Darken With CSS Brightness Filter
      • Lighten And Darken With SCSS
      • Make A Block Of Text Respect New Lines
      • Parameterized SCSS Mixins
      • :root Has Higher Specificity Than html
      • Style A Background With A Linear Gradient
      • Using Maps In SCSS
    • elixir
      • All Values For A Key In A Keyword List
      • Append To A Keyword List
      • Assert An Exception Is Raised
      • Binary Representation Of A String
      • Check For A Substring Match
      • Check List Membership
      • Comparing DateTime Structs
      • Compute Intermediate Values In A With Construct
      • Compute md5 Digest Of A String
      • Counting Records With Ecto
      • Create A Date With The Date Sigil
      • Create A List Of Atoms
      • Creating A PID
      • Creating Indexes With Ecto
      • Defining Multiple Clauses In An Anonymous Function
      • Determine The Latest Release Of A Hex Package
      • Do You Have The Time?
      • Do You Have The Time? - Part 2
      • Documentation Lookup With Vim And Alchemist
      • Dynamically Generating Atoms
      • Execute Raw SQL In An Ecto Migration
      • Expose Internal Representation
      • Include Captures With String.split
      • Inspecting The Process Message Queue
      • List Functions For A Module
      • Listing Files In IEx
      • Match On A Map In A With Construct
      • Passing Around And Using Modules
      • Pattern Matching In Anonymous Functions
      • Pipe Into A Case Statement
      • Quitting IEx
      • Range Into List Using Comprehensions
      • Refer To A Module Within Itself
      • Referencing Values In IEx's History
      • Remove One List From Another
      • Replace Duplicates In A Keyword List
      • Requiring Keys For Structs
      • Reversing A List
      • Reversing A List - Part 2
      • Root Directory Of A Project
      • Round Floats To Integers
      • Run ExUnit Tests In A Deterministic Order
      • Run The Test At A Specific Line Number
      • Same Functions Should Be Grouped Together
      • Skip A Specific Test
      • String Interpolation With Just About Anything
      • Unique Indexes With Ecto
      • Updating Values In A Map
      • Using When Clauses In A With Construct
      • Virtual Fields With Ecto Schemas
      • When Things Don't Match The With Statements
      • Word Lists For Atoms
    • go
      • Access Go Docs Offline
      • Build For A Specific OS And Architecture
      • Not So Random
      • Replace The Current Process With An External Command
      • Sleep For A Duration
      • Upgrading From An Older Version On Mac
    • heroku
      • Wipe A Heroku Postgres Database
      • Push Non-master Branch To Heroku
    • html
      • Adding Alt Text To An Image
      • Disable Auto-Completion For A Form Input
      • Prevent Search Engines From Indexing A Page
      • Render Text As Superscript
      • Submit A Form With A Button Outside The Form
    • javascript
      • Accessing Arguments To A Function
      • Basic Date Formatting Without A Library
      • Character Codes from Keyboard Listeners
      • Check Classes On A DOM Element
      • Check If Something Is An Array
      • Check The Password Confirmation With Yup
      • Compare The Equality Of Two Date Objects
      • Computed Property Names In ES6
      • Conditionally Include Pairs In An Object
      • Configure Jest To Run A Test Setup File
      • Create A Cancelable Promise With PCancelable
      • Create An Array Containing 1 To N
      • Create An Object With No Properties
      • Create Bootstrapped Apps With Yarn
      • Create Future And Past Dates From Today
      • Custom Type Checking Error Messages With Yup
      • Default And Named Exports From The Same Module
      • Define A Custom Jest Matcher
      • Destructure With Access To Nested Value And Parent Value
      • Destructuring The Rest Of An Array
      • Enable ES7 Transforms With react-rails
      • Ensure Shell Can Find Global npm Binaries
      • Easy Date Comparison With DayJS
      • Expand Emojis With The Spread Operator
      • Fill An Input With A Ton Of Text
      • Find Where Yarn Is Installing Binaries
      • for...in Iterates Over Object Properties
      • Formatting Values With Units For Display
      • Freeze An Object, Sorta
      • Generate Random Integers
      • Get The Location And Size Of An Element
      • Get The Response Status From An Axios Error
      • Get The Time Zone Of The Client Computer
      • Globally Install A Package With Yarn
      • Immutable Remove With The Spread Operator
      • Initialize A New JavaScript Project With Yarn
      • Install The Latest Version Of Node With Nvm
      • Interpolate A String Into A Regex
      • ISO-8601 Formatted Dates Are Interpreted As UTC
      • Link A JavaScript Package Locally
      • List Top-Level NPM Dependencies
      • Make The Browser Editable With Design Mode
      • Matching A Computed Property In Function Args
      • Matching Multiple Values In A Switch Statement
      • Mock A Function With Return Values Using Jest
      • New Dates Can Take Out Of Bounds Values
      • Numbers Are Empty
      • Object Initialization With Shorthand Property Names
      • Obtain Undefined Value With The Void Operator
      • Parse A Date From A Timestamp
      • Random Cannot Be Seeded
      • Reach Into An Object For Nested Data With Get
      • Render An Array Of Elements With React 16
      • Resolve And Pass Multiple Values From A Then
      • Running ES6 Specs With Mocha
      • Scoping Variables With A Block Statement
      • Sleep For A Bit In Async Code
      • Sorting Arrays Of Objects With Lodash
      • Splat Arguments To A Function
      • Spread The Rest With ES6
      • Start Node Process In Specific Timezone
      • String Interpolation With Template Literals
      • Support Nested Matching In Custom Jest Matchers
      • Tell Prettier To Not Format A Statement
      • Test Coverage Stats With Jest
      • Test Timing-Based Code With Jest Fake Timers
      • The Comma Operator
      • Throttling A Function Call
      • Timing Processes
      • Transforming ES6 and JSX With Babel 6
      • Truthiness of Integer Arrays
      • Turn An HTMLCollection Into An Array
      • Turn Off Console Error Messages In A Test
      • Waiting On Multiple Promises
      • Who Am I: NPM Edition
      • Yarn Commands Without The Emojis
      • Yup Schemas Are Validated Asynchronously
    • ml
      • reasonML
        • Break Out Of A While Loop
        • Compile Reason To Native With Dune
        • Compile Reason With An OCaml Package Using Dune
        • Create A Map Of Strings
        • Create A Stream From An Array
        • Creating A 2D Array
        • Data Structures With Self-Referential Types
        • Defining Variants With Constructor Arguments
        • Dynamically Create A Printf String Format
        • Exhaustive Pattern Matching Of List Variants
        • Format The Current File Within Vim
        • Generate A Native ReasonML Project With Pesy
        • Generate Starter Reason Projects
        • Helping The Compiler Help Us With Variants
        • Inline Component Styles With Reason React
        • Is This A Directory Or A File?
        • Making Things Mutable
        • Modifying A String With blit_string
        • Multi-Argument Functions As Syntactic Sugar
        • Pattern Match On Exceptions
        • Quickly Bootstrap A React App Using Reason
        • Seeding And Generating Random Integers
        • Stream A File Line By Line
        • String Interpolation With Integers And Sprintf
        • String Interpolation With Quoted Strings
        • Trying Out ReasonML In CodeSandbox
        • Two Ways To Find An Item In A List
        • Using Optional Labeled Function Arguments
        • Wrapping A Component For Use In JavaScript
    • node
      • asdf
        • Fix Unlinked Node Binaries With asdf
        • Interactively Browse Available Node Versions
        • Set The asdf Package Version For A Single Shell
        • Update Package Versions Known By asdf Plugin
    • php
    • python
      • Access Instance Variables
      • Create A Dummy DataFrame In Pandas
      • Test A Function With Pytest
    • rails
      • Add A Check Constraint To A Table
      • Add A Foreign Key Reference To A Table
      • Add A Reference Column With An Index
      • Add ActiveRecord Error Not Tied To Any Attribute
      • Add React With Webpacker To A New Rails App
      • Add timestamptz Columns With The Migration DSL
      • Access Secrets In A Rails 5.2 App
      • ActiveRecord Query For This Or That
      • Advance The Date
      • Allow List Params Anywhere With Strong Params
      • All or Nothing Database Transactions
      • Assert Two Arrays Have The Same Items With RSpec
      • Attach A File With Capybara
      • Attribute Getter without the Recursion
      • Attribute Was
      • Autosave False On ActiveRecord Associations
      • Bind Parameters To ActiveRecord SQL Query
      • Build A Hash Of Model Attributes
      • Capture Development Emails With Mailhog
      • Capybara Page Status Code
      • Cast Common Boolean-Like Values To Booleans
      • Change The Nullability Of A Column
      • Change The Time Zone Offset Of A DateTime Object
      • Check If ActiveRecord Update Fails
      • Check If Any Records Have A Null Value
      • Check Specific Attributes On ActiveRecord Array
      • Code Statistics For An Application
      • Columns With Default Values Are Nil On Create
      • Comparing DateTimes Down To Second Precision
      • Conditional Class Selectors in Haml
      • Convert A Symbol To A Constant
      • Count The Number Of Records By Attribute
      • Create A Custom Named References Column
      • Create A Join Table With The Migration DSL
      • Creating Records of Has_One Associations
      • Custom Validation Message
      • Customize Paths And Helpers For Devise Routes
      • Customize The Path Of A Resource Route
      • Delete Paranoid Records
      • Demodulize A Class Name
      • Different Ways To Add A Foreign Key Reference
      • Disambiguate Where In A Joined Relation
      • Ensure Migrations Use The Latest Schema
      • Find Or Create A Record With FactoryBot
      • Force All Users To Sign Out
      • Generating And Executing SQL
      • Get An Array Of Values From The Database
      • Get An Empty ActiveRecord Relation
      • Get The Column Names For A Model
      • Get The Current Time
      • Grab A Random Record From The Database
      • Handle Named Arguments In A Rake Task
      • Hash Slicing
      • Ignore Poltergeist JavaScript Errors
      • Include Devise Helpers In Your Controller Tests
      • Inspect Previous Changes To ActiveRecord Object
      • Link To The Current Page With Query Params
      • List All Installable Rails Versions
      • List The Enqueued Jobs
      • Load Records In Batches With find_each
      • Log SQL Queries Executed By ActiveRecord
      • Mark A Migration As Irreversible
      • Make ActionMailer Synchronous In Test
      • Manually Run A Migration From Rails Console
      • Mark For Destruction
      • Mask An ActiveRecord Attribute
      • Merge A Scope Into An ActiveRecord Query
      • Migrating Up Down Up
      • Order Matters For rescue_from Blocks
      • Params Includes Submission Button Info
      • Parse Query Params From A URL
      • Perform SQL Explain With ActiveRecord
      • Polymorphic Path Helpers
      • Pretend Generations
      • Prevent Writes With A Sandboxed Rails Console
      • Query A Single Value From The Database
      • Read In Environment-Specific Config Values
      • Read-Only Models
      • Remove The Default Value On A Column
      • Render An Alternative ActionMailer Template
      • Render The Response Body In Controller Specs
      • Replace An Index With A Unique Index
      • Rescue From
      • Rescue From With A Separate Method
      • Retrieve An Object If It Exists
      • Rollback A Specific Migration Out Of Order
      • Rounding Numbers With Precision
      • Schedule Sidekiq Jobs Out Into The Future
      • Secure Passwords With Rails And Bcrypt
      • Select A Select By Selector
      • Select Value For SQL Counts
      • Serialize With fast_jsonapi In A Rails App
      • Set A Timestamp Field To The Current Time
      • Set default_url_options For Entire Application
      • Set Schema Search Path
      • Set Statement Timeout For All Postgres Connections
      • Set The Default Development Port
      • Show Pending Migrations
      • Show Rails Models With Pry
      • Show Rails Routes With Pry
      • Skip Validations When Creating A Record
      • Specify New Attributes For #find_or_create_by
      • Temporarily Disable strong_params
      • Test If An Instance Variable Was Assigned
      • Test If deliver_later Is Called For A Mailer
      • Truncate Almost All Tables
      • Update Column Versus Update Attribute
      • Upgrading Your Manifest For Sprocket's 4
      • Verify And Read A Signed Cookie Value
      • Where Am I In The Partial Iteration?
      • Wipe Out All Precompiled Assets
      • Write Reversible Migration To Set Default
      • Write Safer Where Clauses With Placeholders
    • react
      • A Component Is Just A Bag Of Data
      • Access The Latest Lifecycle Methods In An Old App
      • Accessing Env Vars In create-react-app
      • Accessing Location Within @reach/router
      • Allow md As An Extension With gatsby-mdx
      • Alter The Display Name Of A Component
      • Building A React App In The Browser
      • Check The Type Of A Child Component
      • Conditionally Including Event Handler Functions
      • Create A Snowpack-Bundled React App
      • Create Dynamically Named Custom React Components
      • create-react-app Comes With Lodash
      • create-react-app Has A Default Test Setup File
      • CSS !important Is Not Supported By Inline Styles
      • Debug Jest Tests In create-react-app
      • Defining State In A Simple Class Component
      • Destructure Variables As Props To A Component
      • Details Tags Are A Controllable Component
      • Dispatch Anywhere With Redux
      • Dynamically Add Props To A Child Component
      • Dynamically Create HTML Elements
      • Enforce Specific Values With PropTypes
      • Focus An Input With useRef Hook
      • Force A Component To Only Have One Child
      • Forcing A Child Remount With The Key Prop
      • Formik Connected Components
      • Formik's Validation Schema As A Function
      • Inactive And Active Component Styles With Radium
      • Inline Style Attributes Should Be Camel Cased
      • Manage State In A Functional Component
      • Mapping Over One Or Many Children
      • Mock A Function That A Component Imports
      • Navigate With State Via @reach/router
      • Pairing A Callback With A useState Hook
      • Pass A Function To A useState Updater
      • Passing Props Down To React-Router Route
      • Prevent reach/router Redirect Error Screen In Dev
      • Proxy To An API Server In Development With CRA
      • Quickly Search For A Component With React DevTools
      • @reach/router Renders To A Div
      • Read Only Input Elements
      • Rendering Multiple Nodes With Fragments
      • Set The Type For A useState Hook
      • Specifying Dependencies Of A useEffect Hook
      • Spelunking Through Components With Enzyme's Dive
      • Sync Your react-router State With Redux
      • Test Files In create-react-app
      • Test That Element Does Not Render In The Component
      • Trigger Effect Only When The Component Mounts
      • Update Formik Initial Values When Props Change
      • Upgrading To The Latest React In CodeSandbox
      • Use A Ref To Autofocus An Input
      • Use React 16 With Gatsby
      • Use withRouter To Pass Down React-Router History
      • Visually Select A React Element For Inspection
      • Who Is Your Favorite Child?
      • Wrap The Root Of A Gatsby App In A Component
    • react native
      • Avoid The Notch With SafeAreaView
    • react testing library
      • Check That A Component Renders As Null
      • findBy* Queries Have Async Built In
      • Pretty Print Some DOM To Debug A Test
      • Test A Component That Uses React Portals
    • regEx
    • ruby
      • A Basic Case Statement
      • A Shorthand For Rerunning Failed Tests With RSpec
      • Add Comments To Regex With Free-Spacing
      • Add Linux As A Bundler Platform
      • Are They All True?
      • Assert About An Object's Attributes With RSpec
      • Assoc For Hashes
      • Block Comments
      • Build HTTP And HTTPS URLs
      • Chaining Multiple RSpec Change Matchers
      • Check Return Status Of Running A Shell Command
      • Click On Text With Capybara
      • Colorful Output With MiniTest
      • Comparing Class Hierarchy Relationships
      • Comparing Arrays In RSpec
      • Construct A Constant From A String
      • Create an Array of Stringed Numbers
      • Create a CSV::Table Object
      • Create A Hash From An Array Of Arrays
      • Create Listing Of All Middleman Pages
      • Create Named Structs With Struct.new
      • Create Thumbnail Image For A PDF
      • Defaulting To Frozen String Literals
      • Define A Custom RSpec Matcher
      • Define A Method On A Struct
      • Destructure The First Item From An Array
      • Destructuring Arrays In Blocks
      • Disassemble Some Codes
      • Double Splat To Merge Hashes
      • Edit Previous Parts Of The Pry Buffer History
      • Editing Code In Pry
      • Encode A String As URL-Safe Base64
      • Enumerate A Pairing Of Every Two Sequential Items
      • Evaluating One-Off Commands
      • Exclude Values From An Array
      • Expect A Method To Be Called And Actually Call It
      • FactoryGirl Sequences
      • Fail
      • Find The Min And Max With A Single Call
      • Finding The Source of Ruby Methods
      • Generate A Signed JWT Token
      • Generate Ruby Version And Gemset Files With RVM
      • Get Info About Your RubyGems Environment
      • Identify Outdated Gems
      • If You Detect None
      • Iterate With An Offset Index
      • Include Extra Context In A Honeybadger Notify
      • Ins And Outs Of Pry
      • Invoking Rake Tasks Multiple Times
      • IRB Has Built-In Benchmarking With Ruby 3
      • Jump Out Of A Nested Context With Throw/Catch
      • Last Raised Exception In The Call Stack
      • Limit Split
      • List The Running Ruby Version
      • Listing Local Variables
      • Map With Index Over An Array
      • Mock Method Chain Calls With RSpec
      • Mocking Requests With Partial URIs Using Regex
      • Named Regex Captures Are Assigned To Variables
      • Navigate Back In The Browser With Capybara
      • Next And Previous Floats
      • Or Operator Precedence
      • Override The Initial Sequence Value
      • Parallel Bundle Install
      • Parse JSON Into An OpenStruct
      • Parsing A CSV With Quotes In The Data
      • Pass A Block To Count
      • Passing Arbitrary Methods As Blocks
      • Passing Arguments To A Rake Task
      • Pattern Match Values From A Hash
      • Percent Notation
      • Question Mark Operator
      • Rake Only Lists Tasks With Descriptions
      • Read The First Line From A File
      • Rendering ERB
      • Replace The Current Process With An External Command
      • Require Entire Gemfile In Pry Session
      • Rerun Only Failures With RSpec
      • Retry A Block After An Exception
      • Returning With Sequel
      • rexml Is A Bundled Gem As Of Ruby 3.0.0
      • Run An Older Version Of Bundler
      • Running A Single MiniTest Example
      • Safe Navigation Operator
      • Scripting With RVM
      • Scroll To Top Of Page With Capybara
      • Set RVM Default Ruby
      • Show Public Methods With Pry
      • Silence The Output Of A Ruby Statement In Pry
      • Single And Double Quoted String Notation
      • Squeeze Out The Extra Space
      • String Interpolation With Instance Variables
      • Summing Collections
      • Turn Key And Value Arrays Into A Hash
      • Turning Any Class Into An Enumerator
      • Turning Things Into Hashes
      • Uncaught Exceptions In Pry
      • undef_method And The Inheritance Hierarchy
      • Uninstall Specific Version Of A Ruby Gem
      • Unpacking Strings Into Binary
      • Up And Down With Integers
      • Update The Gemfile Bundled With Version
      • Use A Case Statement As A Cond Statement
      • Use dotenv In A Non-Rails Project
      • Use Tap For Better Test Data Setup
      • Using BCrypt To Create And Check Hashed Passwords
      • What To Do When You Don't Rescue
      • Who Are My Ancestors?
      • Wrap Things In An Array, Even Hashes
      • Zero Padding
    • typescript
      • Add Types To An Object Destructuring
      • Compiler Checks For Unused Params And Variables
      • Re-Export An Imported Type
      • Type Narrowing With Similarly Shaped Objects
      • Use An Array Check For Type Narrowing
      • Zero-Config Environments For Trying Out Types
  • 🛠️Tools
    • ack
      • ack --bar
      • Case-Insensitive Search
      • List Available File Types
    • ansible
      • Getting started with Ansible
      • Setup Ansible on WSL1
      • aliasing-an-ansible-host
    • docker
      • Docker Cheat Sheet
      • SSH Into A Docker Container
      • Pulling & Publishing Images
    • git
      • Accessing a Lost Commit
      • Amend Author Of Previous Commit
      • Auto-Squash Those Fixup Commits
      • Caching Credentials
      • Change The Start Point Of A Branch
      • Checking Commit Ancestry
      • Checkout Old Version Of A File
      • Checkout Previous Branch
      • Cherry Pick A Range Of Commits
      • Clean Out All Local Branches
      • Clean Out Working Copy With Patched Restore
      • Clean Up Old Remote Tracking References
      • Clone A Repo Just For The Files, Without History
      • Clone A Repo Locally From .git
      • Configure Global gitignore File
      • Configuring The Pager
      • Copy A File From Another Branch
      • Create A New Branch With Git Switch
      • Delete All Untracked Files
      • Determine The Hash Id For A Blob
      • Diffing With Patience
      • Dropping Commits With Git Rebase
      • Dry Runs in Git
      • Exclude A File From A Diff Output
      • Excluding Files Locally
      • Find The Date That A File Was Added To The Repo
      • Find The Initial Commit
      • Get The Name Of The Current Branch
      • Get The Short Version Of The Latest Commit
      • Grab A Single File From A Stash
      • Grep For A Pattern On Another Branch
      • Grep Over Commit Messages
      • Ignore Changes To A Tracked File
      • Ignore Files Specific To Your Workflow
      • Include A Message With Your Stashed Changes
      • Include Or Exclude Remaining Patch Changes
      • Include Some Stats In Your Git Log
      • Intent To Add
      • Interactively Unstage Changes
      • Last Commit A File Appeared In
      • List All Files Changed Between Two Branches
      • List Branches That Contain A Commit
      • List Commits On A Branch
      • List Different Commits Between Two Branches
      • List Filenames Without The Diffs
      • List Just The Files Involved In A Commit
      • List Most Git Commands
      • List Untracked Files
      • List Untracked Files For Scripting
      • Move The Latest Commit To A New Branch
      • Pick Specific Changes To Stash
      • Pulling In Changes During An Interactive Rebase
      • Push To A Branch On Another Remote
      • Quicker Commit Fixes With The Fixup Flag
      • Rebase Commits With An Arbitrary Command
      • Reference A Commit Via Commit Message Pattern Matching
      • Rename A Remote
      • Renaming A Branch
      • Resetting A Reset
      • Resolve A Merge Conflict From Stash Pop
      • Run A Git Command From Outside The Repo
      • Set A Custom Pager For A Specific Command
      • Show All Commits For A File Beyond Renaming
      • Show Changes For Files That Match A Pattern
      • Show Changes In The Compose Commit Message View
      • Show File Diffs When Viewing Git Log
      • Show List Of Most Recently Committed Branches
      • Show Only Commits That Touch Specific Lines
      • Show The diffstat Summary Of A Commit
      • Show The Good And The Bad With Git Bisect
      • Show What Is In A Stash
      • Single Key Presses in Interactive Mode
      • Skip A Bad Commit When Bisecting
      • Skip Pre-Commit Hooks
      • Staging Changes Within Vim
      • Staging Stashes Interactively
      • Stash A Single Untracked File
      • Stash Everything
      • Stashing Only Unstaged Changes
      • Stashing Untracked Files
      • Switch To A Recent Branch With FZF
      • Turn Off The Output Pager For One Command
      • Two Kinds Of Dotted Range Notation
      • Unstage Changes Wih Git Restore
      • Untrack A Directory Of Files Without Deleting
      • Untrack A File Without Deleting It
      • Update The URL Of A Remote
      • Using Commands With A Relative Date Format
      • Verbose Commit Message
      • Viewing A File On Another Branch
      • What Changed?
      • What Is The Current Branch?
      • Whitespace Warnings
      • Import A Github Project Into CodeSandbox
      • View The PR For The Current GitHub Branch
    • github actions
      • Capture An Output Value For Use In A Later Step
      • Reference An Encrypted Secret In An Action
    • hashicorp vault/consul
      • Vault
        • Export Vault Store
        • Vault CLI Basics
        • Vault HA Configuration
        • Vault Unseal
      • Consul
        • Export Consul Store
        • Consul CLI Basics
      • Install Vault/Consul
        • Setups Azure Hosted Consul
        • Setup Consul
        • Setup Vault
      • Intro to Hashi
    • hashicorp terraform
    • jq
      • Extract A List Of Values
    • kubernetes
      • K8S Cheat Sheet
      • Loading Credentials
      • Lets Encrypt
      • Configure Ingress
      • Get all Images running in cluster
      • Benefits of K8S
    • nginx
      • Check The Syntax Of nginx Files
      • Reload The nginx Configuration
    • openssl
      • Generate a new CSR
    • rspec
      • Check Specific Arguments To Received Method
    • sed
      • Apply Multiple Substitutions To The Input
      • Equivalence Classes Of Repetition MetaChars
      • Extract Value From Command Output With Sed
      • Grab All The Method Names Defined In A Ruby File
      • Grab The First Line Of A File
      • OSX sed Does Regex A Bit Different
      • Output Only Lines Involved In A Substitution
      • Reference A Capture In The Regex
      • Use An Alternative Delimiter In A Substitution
    • seq
      • Create A Sequence Of Values With A Step
    • slack
      • Set Recurring Reminders In Slack
      • Open Slack's Keyboard Shortcuts Reference Panel
    • statsd
    • vercel
      • Add Web Server Layer Redirects
      • Deploy An App Without Pushing An Empty Commit
      • Naming Of The Vercel Config File
      • Share Development Environment Variables Via CLI
    • vim
      • Change/Commit
        • Aborting Git Commits And Rebases
        • Amend Commits With Fugitive
        • Beginning And End Of Previous Change
      • File
        • Add A File Without Loading It
        • Alternate Files With vim-rails
      • Line
        • Almost The End Of The Line
        • Absolute And Relative Line Numbers
        • Wrap With Some Room
        • Whole Line Auto-Completion
      • What Is On The Runtime Path?
      • Add Custom Dictionary Words
      • All The Ways To Write And Quit In Vim
      • Allow Neovim To Copy/Paste With System Clipboard
      • Always Keep The Gutter Open
      • Backspace Options
      • The Black Hole Register
      • Blank Lines Above And Below
      • Breaking The Undo Sequence
      • Buffer Time Travel
      • Build And Install A Go Program
      • Case-Aware Substitution With vim-abolish
      • Case-Insensitive Substitution
      • Center The Cursor
      • Check For An Executable
      • Check Your Current Color Scheme
      • Clear Out The Jump List
      • Close All Other Splits
      • Close All Other Windows
      • Close the Current Buffer
      • Coerce The Current Filetype
      • Coercing Casing With vim-abolish
      • Configure FZF To Use fd For File Finding
      • Count the Number of Matches
      • Create A New Directory In netrw
      • Create A New File In A New Directory
      • Creating Non-Existent Directories
      • Default netrw To Tree Liststyle
      • Delete Every Other Line
      • Delete Lines That Match A Pattern
      • Delete To The End Of The Line
      • Deleting Buffers In BufExplorer
      • Deleting Directories Of Files From netrw
      • Detect If You Are On A Mac
      • Difference Between :wq and :x
      • Display Word Count Stats
      • Edges Of The Selection
      • Edit A File At A Specific Line Number
      • Edit A File Starting On The Last Line
      • End Of The Word
      • Escaping Terminal-Mode In An Nvim Terminal
      • Filter Lines Through An External Program
      • Fix The Spelling Of A Word
      • Fold A Visual Selection And Expand It Back
      • For When That Escape Key Is Hard To Reach
      • Format Long Lines To Text Width
      • From Ruby Variables To JavaScript Variables
      • Generate and Edit Rails Migration
      • Get The pid Of The Session
      • Go Back To The Previous Window
      • Go To File With Line Number
      • Grepping Through The Vim Help Files
      • Head of File Name
      • Help For Non-Normal Mode Features
      • Highlighting Search Matches
      • Horizontal to Vertical and Back Again
      • Increment All The Numbers
      • Incremental Searching
      • Interact With The Alternate File
      • Interactive Buffer List
      • Joining Lines Together
      • Jump Back To The Latest Jump Position
      • Jump Between And Stage Git Hunks With Fugitive
      • Jump To Matching Pair
      • Jump To The Next Misspelling
      • List All Buffers
      • List Of Plugins
      • Load A Directory Of Files Into The Buffer List
      • Make Directories For The Current File
      • Marks Across Vim Sessions
      • Match The Beginning And End Of Words
      • Moving To A Specific Line
      • Navigate To The Nth Column On A Line
      • Navigating By Blank Lines
      • NETRW Listing Styles
      • Next Modified Buffer
      • Normal Node Binding To Just Quit
      • Open A Tag In A Split Window
      • Open an Unnamed Buffer
      • Open FZF Result In A Split
      • Open Routes File With vim-rails
      • Open The Directory Of The Current File
      • Open The Fugitive Git Summary Window
      • Open The Gemfile
      • Open The Latest Rails Migration
      • Open The Selected Lines In GitHub With Gbrowse
      • Open Vim To A Tag Definition
      • Opening a URL
      • Opening Man Pages In Vim
      • Paste A Register From Insert Mode
      • Preventing Typos with Abbreviations
      • Previous Buffer
      • Previous Visual Selection
      • Print The Relative Path Of The Current File
      • Print Version Information
      • Quick File Info
      • Quick Man Pages
      • Quick Quickfix List Navigation
      • Quickly Fix A Misspelled Word
      • Quickly Switch To A Buffer By Number
      • Quit When There Is An Argument List
      • Re-indenting Your Code
      • Read In The Contents Of A Rails File
      • Rename A File Through netrw
      • Rename Current File
      • Repeat The Previous Change
      • Repeating Characters
      • Replace A Character
      • Reset Target tslime Pane
      • Reverse A Group Of Lines
      • Rotate Everything By 13 Letters
      • Rotate The Orientation Of Split Windows
      • Running Bundle With vim-bundler
      • Scrolling Relative to the Cursor
      • Search Backward Through A File
      • Searching For Hex Digits
      • Select Several Results From An FZF Search
      • Set End Of Line Markers
      • Set Your Color Scheme
      • Set Up Vim-Plug With Neovim
      • Setting Filetype With Modelines
      • Show All Syntax Highlighting Rules
      • Show Matching Entries For Help
      • Specify The Line Height Of The Quick Fix Window
      • Split Different
      • Split The Current Window
      • Splitting For New Files
      • Source Original vimrc When Using Neovim
      • Swap Occurrences Of Two Words
      • Swapping Split Windows
      • Tabs To Spaces
      • The Vim Info File
      • Toggle Absolute And Relative Paths In BufExplorer
      • Toggling Syntax Highlighting
      • Turning Off Search Highlighting
      • Unloading A Buffer
      • Use Active Window With BufExplorer
      • Use The Terminal Inside A Vim Session
      • Using vim-surround With A Visual Selection
      • Verbose Commits With Fugitive
      • View Commit History of a File
      • Viewing Man Pages with man.vim
      • Vim Without The Extras
    • vscode
      • Add The VSCode CLI To Your Path
      • Advance Through Search Results
      • Enable Breadcrumbs For Version 1.26 Release
      • Open An Integrated Terminal Window
      • Toggle Between Terminals
    • webpack
      • Use A Specific Config File
      • Better Module Imports With Aliases
      • Debugging With Full Source Maps
      • Run ESLint As A Preloader
      • Specify Port Of CRA's Webpack Dev Server
    • workflow
      • Update asdf Plugins With Latest Package Versions
      • Toggle Between Stories In Storybook
      • Rotate An Image To Be Oriented Upright
      • Prune The Excess From node_modules
      • Get Your Public IP Address
      • Forward Stripe Events To Local Server
      • Enable Dev Tools For Safari
      • Create A Public URL For A Local Server
      • Convert An ePub Document To PDF On Mac
      • Change Window Name In iTerm
      • Interactively Kill A Process With fkill
    • yaml
      • Create Multi-Line Strings Without The Line Breaks
      • YAML Is A Superset Of JSON
    • xstate
      • Use An XState Machine With React
      • Start A Machine In A Specific State
      • Simple States And Composite States
      • Make Immediate And Delayed Transitions
      • Inline Actions vs Actions In Machine Options
      • Events Stop Propagating Once Handled
      • Define Event That Does Internal Self Transition
      • Custom Jest Matcher For XState Machine States
      • Always Use Inline Functions With Assign
Powered by GitBook
On this page
  • 1: Ensure we install all the pre-reqs on your station.
  • 2: Setup your environment variables:
  • 3: Generate a ssh key to be used for securing the deployment:
  • ​4: Setup your Workspace
  • 5: Setting up Remote State for Terrafrom
  • 6: Run the initial Terraform deploy of shared stuffs:
  • 7. Run the Terraform DB Schema
  • 8: Export the k8s credentials:
  • 9: Generate Secrets used for ingress
  • 10: Deploy the API
  • 11. Initialize the Hashi Vault in a VM
  • 12: Install default values into Vault

Was this helpful?

Edit on GitHub
  1. Tools

hashicorp terraform

This document calls out getting started with Terraform

PreviousIntro to HashiNextjq

Last updated 3 years ago

Was this helpful?

1: Ensure we install all the pre-reqs on your station.

Pre-Reqs

  • Terraform

  • Azure CLI

  • psql

  • Kubectl

  • helm

  • consul

  • vault

  • openssl

Installation of Terraform & Azure CLI

Make sure you install terraform from here: .

On Windows

I like , so you can install using:

# install choco
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

# Powershell
choco install pwsh -y

# Aspnetcore
choco install dotnetcore-windowshosting -y
choco install dotnetcore -y
choco install dotnetcore-2.0-sdk -y
choco install dotnetcore-2.1-sdk -y
choco install dotnetcore-2.2-sdk -y
choco install dotnetcore-3.0-sdk -y
choco install dotnetcore-3.1-sdk -y
choco install dotnetcore3-desktop-runtime -y
choco install dotnetcore-3.1-runtime -y
choco install dotnet-5.0-runtime -y
choco install dotnet-5.0-sdk -y
choco install netfx-4.8 -y
choco install dotnetfx -y

# install Azure CLI via choco
choco install azure-cli -y
az extension add --name azure-cli-iot-ext

# PSQL:
choco install postgresql12 -y

# Hashi Consul/Vault/Terraform
choco install consul -y
choco install choco install vault -y
choco install terraform -y

# docker/Kubernetes/helm
choco install docker-desktop -y
choco install kubernetes-cli -y
choco install kubernetes-helm -y

# Python
choco install python -y

# node
choco install nodejs -y

On Ubuntu

sudo apt update && apt upgrade -y

# install Terraform
wget https://releases.hashicorp.com/terraform/0.14.6/terraform_0.14.6_linux_amd64.zip
sudo apt-get install zip -y
unzip terraform*.zip
sudo mv terraform /usr/local/bin
terraform version

# Install AZ Cli & extensions
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
az extension add --name azure-cli-iot-ext
az extension add --name azure-iot

# install psql
sudo apt-get update
sudo apt-get install postgresql-client

# Install Kubectl
sudo apt-get update && sudo apt-get install -y apt-transport-https gnupg2
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl

# Install Helm
curl https://baltocdn.com/helm/signing.asc | sudo apt-key add -
sudo apt-get install apt-transport-https --yes
echo "deb https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update
sudo apt-get install helm

# Or install using scripts:
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh

# Install Vault
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install vault


wget https://releases.hashicorp.com/vault/1.5.0/vault_1.5.0_linux_amd64.zip
unzip vault_1.5.0_linux_amd64.zip
sudo mv vault /usr/bin
vault


# Install Consul
wget https://releases.hashicorp.com/consul/1.8.2/consul_1.8.2_linux_amd64.zip
unzip consul_1.8.2_linux_amd64.zip
sudo mv consul /usr/bin
consul

# install ansible
sudo apt update
sudo apt install software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt install ansible

# install Pip
sudo apt install python3-pip
pip3 install 'ansible[azure]'

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py --user

# python dependencies
sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev \
    libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev

sudo apt install python3.9

# Install SDK
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

Setup your Env Variables with SPN for Azure

In order to use terraform in a secure way, the spn id/secrets should not be stored in source code, so each time you want to setup an env, you'll want to change your env variables to the necessary accounts that have access. Here is an example way of using powershell to create the evn settings

Windows

$env:ARM_CLIENT_ID  = "SOME_ID"
$env:ARM_CLIENT_SECRET    = "SOME_PASSWORD"
$env:ARM_SUBSCRIPTION_ID  = "SOME_SUBSCRIPTION"
$env:ARM_TENANT_ID        = "SOME_AAD_CLIENT"

Ubunut

export ARM_CLIENT_ID="SOME_ID"
export ARM_CLIENT_SECRET="SOME_PASSWORD"
export ARM_SUBSCRIPTION_ID="SOME_SUBSCRIPTION"
export ARM_TENANT_ID="SOME_AAD_CLIENT"

Install openssl

choco install openssl -y

2: Setup your environment variables:

In order to use terraform in a secure way, the spn id/secrets should not be stored in source code, so each time you want to setup an env, you'll want to change your env variables to the necessary accounts that have access. Here is an example way of using powershell to create the evn settings

Windows

  $env:ARM_CLIENT_ID = "SOME_ID"
  $env:ARM_CLIENT_SECRET = "SOME_PASSWORD"
  $env:ARM_SUBSCRIPTION_ID  = "SOME_SUBSCRIPTION"
  $env:ARM_TENANT_ID  = "SOME_AAD_TENANT"

Ubuntu

  export ARM_CLIENT_ID="SOME_ID"
  export ARM_CLIENT_SECRET="SOME_PASSWORD"
  export ARM_SUBSCRIPTION_ID="SOME_SUBSCRIPTION"
  export ARM_TENANT_ID="SOME_AAD_TENANT""

3: Generate a ssh key to be used for securing the deployment:

# If windows:
Set-location ~ 
mkdir ~/.ssh

Ssh-keygen.exe


#      Generating public/private rsa key pair.
#      Enter file in which to save the key (/c/Users/joetest/.
#       ssh/id_rsa): /c/Users/joetest/.ssh/
#      Enter passphrase (empty for no passphrase):
#      Enter same passphrase again:
#      Your identification has been saved in /c/Users/joetest/
#      .ssh/
#      Your public key has been saved in /c/Users/joetest/.ssh/
#      The key fingerprint is:
#      #SHA256:jieniOIn20935n0awtn04n002HqEIOnTIOnevHzaI5nak
#      joetest@periwinkle
#      The key's randomart image is:

#      +---[RSA 2048]----+
#      |*o =.            |
#      |O*=*=.B       +-3|
#      |+* +             |
#      |    +   #$^  4   |
#      |             +.  |
#      | .o.ooo* o       |
#      |  .+o .          |
#      |   .=.           |
#      |   Eo      +*oo  |
#      +----[SHA256]-----+

#      $ dir .ssh
#      id_rsa  id_rsa.pub

$pub_key = get-content ~/.ssh/id_rsa.pub

‌Once this is done, then add the public key‌

Convert root cert token for API gateway to base64

Note: This only needs to be done once, adn then update vnet_gw_vpn_cert_name & vnet_gw_vpn_cert_data in the /terraform/base-env-setup/main.tf

$path = "./certs/appdz1-root-public.cer"$file = [System.Text.Encoding]::UTF8.GetBytes((get-content ($path)))$certText = [Convert]::ToBase64String($file)

​4: Setup your Workspace

Your terraform workspace is important, as it tells the terraform which variables to use for an associated environment, as well as maintaining the state for what is deployed. For the most part, the default settings can be the same across all environments - but you'll want to differentiate the name/location of the resources that are deployed. This is accomplished using the Terraform Workspace.

# Initialize your new workspace
terraform workspace new delta

    Created and switched to workspace "delta"!

    You're now on a new, empty workspace. Workspaces isolate their state,
    so if you run "terraform plan" Terraform will not see any existing state
    for this configuration.
  • Dev

  • Alpha

  • Bravo

  • Charlie

// Note Truncated for brevity
   dev = {

      ssl_certificate_name          = "dev.domain.com"
      ssl_certificate_data          = "MI..0A=="
      ssl_certificate_password      = "SOMEPASSWORD"
    }

    alpha = {

      ssl_certificate_name          = "dev.domain.com"
      ssl_certificate_data          = "MI..0A=="
      ssl_certificate_password      = "SOMEPASSWORD"
    }

    bravo = {

      ssl_certificate_name          = "dev.domain.com"
      ssl_certificate_data          = "MI..0A=="
      ssl_certificate_password      = "SOMEPASSWORD"
    }

    charlie = {

      ssl_certificate_name          = "dev.domain.com"
      ssl_certificate_data          = "MI..0A=="
      ssl_certificate_password      = "SOMEPASSWORD"
    }

    // insert new env here

Setup your workspace

To ensure you connect to the right state store in the blob, make sure you are configured to the proper env

# to see what workspaces exist on your station:
terraform workspace list

# to create a new workspace:
terraform workspace new dev

# if you have existing workspaces, and want to set to a specific one:
terraform workspace select dev

5: Setting up Remote State for Terrafrom

In order to save state to a remote storage location (azure blob), we'll need to setup a storage account and some containers. You'll do that by executing the terraform script under /terraform/1-tf-remotestate.

NOTE: If this has already been executed, you don't need to re-run this 1-tf-remotestate. This exists for the new appdz1 env!

# Put yourself in the root of the terraform folder (not the module level - the root l evel)
set-location "./terraform/1-tf-remotestate"

# Type terraform validate to validate the config
terraform validate

#Output
Success! The configuration is valid.

6: Run the initial Terraform deploy of shared stuffs:

  $basepath = "c:/vso"
  set-location $basepath/app.Deploy/terraform/base-env-setup

  # Verify that you'vev downloaded all the terraform provider
  terraform init

  # Verify that everything builds
  terraform validate

  # Make it so!
  terraform apply

By now, we should have the following deployed:

  • Shared Module:

    • Core RG

    • Vnet & subnets

    • AKS Cluster

    • App Gateway & PIP

    • Traffic Manager (For DNS name)

    • Log Analytics

Another Example output:

set-location "./terraform/1-tf-remotestate"

# see what would happen without actually deploying
terraform plan

# apply the configuration
terraform apply

...

# Example output
module.api.azurerm_postgresql_virtual_network_rule.pgsql: Refreshing state... [id=/subscriptions/SOME_SUB_ID/resourceGroups/SOME_RG_1/providers/Microsoft.DBforPostgreSQL/servers/SOME_SVC-sql/virtualNetworkRules/env-openshift]
module.api.azurerm_resource_group.resource_group: Refreshing state... [id=/subscriptions/SOME_SUB_ID/resourceGroups/SOME_RG_1]
module.api.azurerm_postgresql_server.pgsql: Refreshing state... [id=/subscriptions/SOME_SUB_ID/resourceGroups/SOME_RG_1/providers/Microsoft.DBforPostgreSQL/servers/SOME_SVC-sql]
module.api.azurerm_postgresql_database.db: Refreshing state... [id=/subscriptions/SOME_SUB_ID/resourceGroups/SOME_RG_1/providers/Microsoft.DBforPostgreSQL/servers/SOME_SVC-sql/databases/SOME_SVC-db]

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create
  - destroy

Terraform will perform the following actions:

  # module.api.azurerm_postgresql_virtual_network_rule.pgsql will be destroyed
  - resource "azurerm_postgresql_virtual_network_rule" "pgsql" {
      - id                                   = "/subscriptions/SOME_SUB_ID/resourceGroups/SOME_RG_1/providers/Microsoft.DBforPostgreSQL/servers/SOME_SVC-sql/virtualNetworkRules/env-openshift" -> null
      - ignore_missing_vnet_service_endpoint = true -> null
      - name                                 = "env-openshift" -> null
      - resource_group_name                  = "SOME_RG_1" -> null 
      - server_name                          = "SOME_SVC-sql" -> null
      - subnet_id                            = "/subscriptions/SOME_SUB_ID/resourceGroups/env-msdn-vnet-rg/providers/Microsoft.Network/virtualNetworks/env-msdn-vnet/subnets/env-openshift-subnet" -> null
    }

  # module.api.azurerm_postgresql_virtual_network_rule.pgsql_rule1 will be created
  + resource "azurerm_postgresql_virtual_network_rule" "pgsql_rule1" {
      + id                                   = (known after apply)
      + ignore_missing_vnet_service_endpoint = true
      + name                                 = "env-openshift"  
      + resource_group_name                  = "SOME_RG_1"
      + server_name                          = "SOME_SVC-sql"
      + subnet_id                            = "/subscriptions/SOME_SUB_ID/resourceGroups/env-msdn-vnet-rg/providers/Microsoft.Network/virtualNetworks/env-msdn-vnet/subnets/env-openshift-subnet"
    }

  # module.api.azurerm_postgresql_virtual_network_rule.pgsql_rule2 will be created
  + resource "azurerm_postgresql_virtual_network_rule" "pgsql_rule2" {
      + id                                   = (known after apply)    
      + ignore_missing_vnet_service_endpoint = true
      + name                                 = "devqa-VPN-vnet"
      + resource_group_name                  = "SOME_RG_1"
      + server_name                          = "SOME_SVC-sql"
      + subnet_id                            = "/subscriptions/MGMT_SUBSCRIPTION/resourceGroups/mgmt-devqa-vpn-vnet-rg/providers/Microsoft.Network/virtualNetworks/mgmt-devqa-vpn-vnet/subnets/vpn-subnet"
    }

Plan: 2 to add, 0 to change, 1 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

#type yes if you are good with the config
  Enter a value: yes

module.api.azurerm_postgresql_virtual_network_rule.pgsql: Destroying... [id=/subscriptions/SOME_SUB_ID/resourceGroups/SOME_RG_1/providers/Microsoft.DBforPostgreSQL/servers/SOME_SVC-sql/virtualNetworkRules/env-openshift]
module.api.azurerm_postgresql_virtual_network_rule.pgsql_rule1: Creating...
module.api.azurerm_postgresql_virtual_network_rule.pgsql_rule2: Creating...
module.api.azurerm_postgresql_virtual_network_rule.pgsql: Destruction complete after 2s
module.api.azurerm_postgresql_virtual_network_rule.pgsql_rule2: Still creating... [20s elapsed]
module.api.azurerm_postgresql_virtual_network_rule.pgsql_rule1: Still creating... [30s elapsed]
module.api.azurerm_postgresql_virtual_network_rule.pgsql_rule2: 

# Truncated log

module.api.azurerm_postgresql_virtual_network_rule.pgsql_rule1: Still creating... [2m20s elapsed]
module.api.azurerm_postgresql_virtual_network_rule.pgsql_rule2: Still creating... [2m20s elapsed]
module.api.azurerm_postgresql_virtual_network_rule.pgsql_rule2: Creation complete after 2m23s [id=/subscriptions/SOME_SUB_ID/resourceGroups/SOME_RG_1/providers/Microsoft.DBforPostgreSQL/servers/SOME_SVC-sql/virtualNetworkRules/devqa-VPN-vnet]
module.api.azurerm_postgresql_virtual_network_rule.pgsql_rule1: Still creating... [2m30s elapsed]
module.api.azurerm_postgresql_virtual_network_rule.pgsql_rule1: Still creating... [2m40s elapsed]                                                                           
module.api.azurerm_postgresql_virtual_network_rule.pgsql_rule1: Still creating... [2m50s elapsed]
module.api.azurerm_postgresql_virtual_network_rule.pgsql_rule1: Creation complete after 2m54s [id=/subscriptions/SOME_SUB_ID/resourceGroups/SOME_RG_1/providers/Microsoft.DBforPostgreSQL/servers/SOME_SVC-sql/virtualNetworkRules/env-openshift]
                                                                                                                                                                                  
Apply complete! Resources: 2 added, 0 changed, 1 destroye

7. Run the Terraform DB Schema

Now we will need to manually add the firewall rules to allow the aks cluster to reach the pgsql.

  1. Select the appdz1-core-hyperscale server group

  2. Then select the Networking from the Settings category on the bottom left

  3. There is an item that says "Allow Azure services and resources to access this server group". Change this selection from no to YES

  4. You'll need to also add the public ip of your machine to the firewall rule, otherwise your schema scripts will fail. you can find out your ip address by typing "whats my ip" in google search.

Now that we have configured the access firewalls, we can configure run the schema scripts.

set-location $basepath/terraform/product.db

  # Verify that you'vev downloaded all the terraform provider
  terraform init

  # Verify that everything builds
  terraform validate

  # Make it so!
  terraform apply

8: Export the k8s credentials:

in order to connect to the cluster, you'll need to credentials of what you just deployed. To do that, lets use AKS creds.

Note: Executing this command is using the environment variables we loaded under step 2 as the user ak cli is running under

$rg = "rg"
$aks = "core-aks"
az aks get-credentials --resource-group $rg --name $aks 


$env = "a"
$app = "app"
$zone = "z1"
$rg = "$($app)$($env)$($zone)-core-rg"
$aks = "$($app)$($env)$($zone)-core-aks"
az aks get-credentials --resource-group $rg --name $aks

9: Generate Secrets used for ingress

# Generate new self signed cert to use for TLS within the cluster
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout "./certs/ingress.key" -out "./certs/ingress.pem" -subj "/CN=ingresstls/O=org"

# Insert certs into AKS
$app = "app"
$env = "d"
$namespace = "$($app)-$($env)"

$secretname = "ingresstls"
kubectl create secret tls $secretname `
    --namespace $namespace `
    --key "./certs/ingress.key" `
    --cert "./certs/ingress.pem"

# Insert secrets allowing our service to pull from ACR
$ACR_SHORTNAME = "SOME_REPO_NAME"
$ACR_NAME="SOME_REPO_NAME.azurecr.io"
$ACR_UNAME="$namespace-creds-topull"
$ACR_PASSWD = "SOMEPASSWORD"

kubectl create secret docker-registry $ACR_SHORTNAME `
  --docker-server=$ACR_NAME `
  --docker-username=$ACR_UNAME `
  --docker-password=$ACR_PASSWD `
  --docker-email="SOME_EMAIL"

10: Deploy the API

$ns = "SOME_NS"

# Set the default namespace:
kubectl config set-context --current --namespace=SOME_NS

#Create two new deployments 
kubectl apply -f ..\..\helm\app1.yaml --namespace SOME_NS
kubectl apply -f ..\..\helm\app2.yaml --namespace SOME_NS

# Deploy INGRESS
kubectl apply -f ..\..\helm\internal-ingress.yaml --namespace SOME_NS

helm install nginx-ingress stable/nginx-ingress `
    --namespace SOME_NS `
    -f ..\..\helm\internal-ingress.yaml `
    --set controller.replicaCount=2 `
    --set controller.nodeSelector."beta\.kubernetes\.io/os"=linux `
    --set defaultBackend.nodeSelector."beta\.kubernetes\.io/os"=linux


# Deploy Tests apps, which should show up a default page at url
kubectl apply -f ..\..\helm\app1.yaml --namespace SOME_NS
kubectl apply -f ..\..\helm\app2.yaml --namespace SOME_NS

# Deploy the container for api
kubectl apply -f ..\..\helm\api.yaml --namespace SOME_NS

11. Initialize the Hashi Vault in a VM

The output of the shared terraform script should include the ip address of the pip of the vm.

$pip_ipaddress = "SOME_IP"
ssh azureuser@$pip_ipaddress

# Run vault status command to check current status:
vault status

    Key                      Value
    ---                      -----
    Recovery Seal Type       azurekeyvault
    Initialized              false
    Sealed                   true
    Total Recovery Shares    0
    Threshold                0
    Unseal Progress          0/0
    Unseal Nonce             n/a
    Version                  n/a
    HA Enabled               true
    Notice that Initialized is false.

# Run the vault operator init command to initialize the Vault server so that you can unseal:

$regex = '[A-Za-z0-9+/]{44}|[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}'


$a = vault operator init

    Unseal Key 1: Kd.......................................4MC
    Unseal Key 2: pA.......................................FRN
    Unseal Key 3: YW.......................................eJj
    Unseal Key 4: +l......................................./XG
    Unseal Key 5: XK.......................................ex4

    Initial Root Token: UWN................Gw

    Vault initialized with 5 key shares and a key threshold of
    3. Please securely distribute the key shares printed above.
    When the Vault is re-sealed, restarted, or stopped, you 
    must supply at least 3 of these keys to unseal it before it
    can start servicing requests.

    Vault does not store the generated master key. Without at
    least 3 key to reconstruct the master key, Vault will 
    remain permanently sealed!

    It is possible to generate new unseal keys, provided you
    have a quorum of existing unseal keys shares. See “vault
    operator rekey” for more information


$a = kubectl exec -ti vault-0 -- vault operator init
$a -match $regex

$b = kubectl exec -ti vault-0 -- vault operator init -format "json"

12: Install default values into Vault

For this step, you'll need:

  • The Following settings:

    • The IP Address of the Vault ()

    • The Secret of the Vault ()

    • The json blob of settings

An example json file might look like this:

{
    "app1": {
      "Host": "localhost",
      "Port": 5000,
    },
    "ApplicationInsights": {
      "Disable": false,
    },
    "app2": {
      "Endpoint": "https://SOMEURL",
      "StatusEndpoint": "https://SOMEURL/status"
    }
}

Execute the following commands to upload the settings from a given app

Reference:

Once you have done this, you'll want to ensure that you update the to include new environment variables. The idea is we'll have a few "placeholders" for transient environments such as:

If you wanted to add say "Delta", you'd go to the file and add a new section after Charlie -- ensuring you add whatever customization you need for variables to make your new env unique to you.

Open the , and select that resource group for appdz1-core-rg.

🛠️
https://www.terraform.io/downloads.html
chococately
Terraform Workspaces
terraform/base-env-setup/main.tf
terraform/base-env-setup/main.tf
https://portal.azure.com