Skip to content

Instantly share code, notes, and snippets.

View magodo's full-sized avatar
💭
babysitting😱

magodo magodo

💭
babysitting😱
View GitHub Profile
use std::cmp::max;
use std::collections::{HashMap, HashSet};
use std::env;
use std::fs::read_to_string;
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
struct Point {
x: usize,
y: usize,
}
@magodo
magodo / StorageDataPlaneAccessTSG.md
Created August 17, 2023 08:12
Azure storage data plane access TSG
@magodo
magodo / run.sh
Last active September 16, 2022 05:49
Setup and run aztfy
#!/bin/bash
# This script setup aztfy and run it in batch mode for terrafying a resource group.
# Afterwards, it will download the output files (incl. HCL and state file) to your local fs.
set -e
MYDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
MYNAME="$(basename "${BASH_SOURCE[0]}")"
type Foo struct {
A string `json:"a"`
}
func (foo *Foo) UnmarshalJSON(data []byte) error {
//TODO
}
@magodo
magodo / README.md
Last active March 11, 2022 11:14
Azure policy assginment/definition and mgmt group investigation

This gist is to demonstrate how to reproduce Azure policy related issues when creating definitions within or assigning into a newly created management group.

This can be used to reproduce issue: hashicorp/terraform-provider-azurerm#12478.

The configuration is split to two parts, which should be copied to two TF workspaces and run in sequence.

  • The first one (main1.tf) is to provision a parent mgmt group and create a custom policy definition within it
  • The second one (main2.tf) is to provision a child mgmt group and then assign the inherited policy definition to it

There is one thing worth mentioning in the main2.tf, the custom policy definition is retrieved from a data source, where you can either get it from the parent mgmt group or the child. Actually, each one ends up with the same definition (i.e. the same resource id).

provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "fwpolicy-test"
location = "westeurope"
}
resource "azurerm_public_ip" "test" {
@magodo
magodo / main.tf
Created January 21, 2022 07:17
container group
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-220121144644318289"
location = "West Europe"
}
resource "azurerm_storage_account" "test" {
name = "accsa220121144644318289"
resource_group_name = azurerm_resource_group.test.name
@magodo
magodo / azure-static-web-app.tpl
Last active November 19, 2023 03:08
terraform config to automatically setup an Azure static site
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
@magodo
magodo / 0.go
Last active January 10, 2021 13:05
Go: Source vs AST vs SSA
package main
import "fmt"
func hello(name string) {
if name == "" {
fmt.Print("name?")
name = readString()
}
@magodo
magodo / main.tf
Created August 17, 2020 05:42
terraform-provider-azurerm-8105
provider "azurerm" {
version = "=2.22.0"
features {}
}
variable "vm-size" {
type = string
description = "Preferred VM Size"
default = "Standard_E8_v3"
}