Skip to content

Instantly share code, notes, and snippets.

View anthony-c-martin's full-sized avatar
💪

Anthony Martin anthony-c-martin

💪
  • Microsoft
  • Chapel Hill, NC
View GitHub Profile
@anthony-c-martin
anthony-c-martin / .gitconfig
Last active December 15, 2020 18:24
My .gitconfig
[alias]
lg = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) %C(white)%s%C(reset) %C(bold red)%an%C(reset) %C(bold green)%D%C(reset)' --branches
lga = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) %C(white)%s%C(reset) %C(bold red)%an%C(reset) %C(bold green)%D%C(reset)' --all
[core]
autocrlf = true
editor = code --wait
[user]
name = Anthony Martin
@anthony-c-martin
anthony-c-martin / ParentScope_mockups.md
Created February 8, 2021 16:46
Bicep Parent/Scope syntax mockups

Syntax mockups

Existing Syntax

Root resource

resource myVm 'Microsoft.Compute/virtualMachines@2020-01-01' = {
  name: 'myVm'
  ...
}
@anthony-c-martin
anthony-c-martin / main.bicep
Created April 1, 2021 23:08
Bicep Module Example
param inputA string
module mymod './module.bicep' = {
name: 'mymod'
params: {
inputB: inputA
}
}
output outputA string = mymod.outputs.outputB
@anthony-c-martin
anthony-c-martin / spec.md
Last active July 12, 2021 15:20
Bicep Extensibility Investigation - Phase 1

Bicep Extensibility Investigation - Phase 1

This document outlines the changes that are needed to Bicep, ARM Template JSON, and the ARM Deployment engine in order to support the ability to deploy resources outside of the ARM control plane. The Bicep syntax is liable to change, and will go through the normal design process.

Phase 1 relates to enabling a limited number of built-in 1st party providers. Phase 2 will permit the enablement of 3rd party providers.

Purpose / Goals

  • Permit authoring and deploying of custom (non-ARM) resource types through Bicep as part of an ARM Template deployment, with a feature set as full as the features available for ARM resources.
  • Leave the door open for 3rd party extensibility with a design which is compatible.

Non-goals

@anthony-c-martin
anthony-c-martin / imports.md
Last active December 15, 2021 08:00
Imports

Bicep Imports - Cross-Module

Goals

  • It should be unambiguous to the compiler which imports are used in a given module file (for validation purposes).
  • Minimal boilerplate when passing imports from parent -> child module.
  • Transferring information about imports from parent -> child should ideally avoid having to define parameters.
  • Specifics of the scope being targeted should preferably be kept out of the Bicep file itself.

Design

Each import consists of optional 'configuration', which must be specified in the file declaring the import (child module), as well as a 'scope'* which must be satisfied by the caller (parent module).

@anthony-c-martin
anthony-c-martin / spec.md
Last active July 6, 2022 01:02
Idea: First-class 'scope' concept to support Stacks deletion

Idea: First-class 'scope' concept to support Stacks deletion

Concept

Introduce a first-class concept of 'scope' into Bicep for extensible resources, so that Stacks understands ownership, and is able to request deletion of extensible resources that are deployed 'inside' Azure resources.

Why is this necessary?

Stacks currently stores a list of id properties for Azure resources to go and clean up if they are removed from the Stack. Extensible resources generally require authentication with another control plane; details of this are difficult to persist or provide to the Stacks RP in a reusable manner.

Stacks and What-If would probably also benefit from the concept of 'ownership' - e.g. understanding that particular extensible resources are scoped 'within' Azure resources.

@anthony-c-martin
anthony-c-martin / spec.md
Created November 11, 2022 15:06
Stacks + Bicep Extensibility

Stacks + Bicep Extensibility

Problem Statement

Deployment Stacks requires the ability to manage the full lifecycle (including deletion) of all resources defined inside a Stack. Currently this is only possible for Azure resources, not extensible ones, due to lack of an id field, and an authentication mechanism for an extensible control plane.

Goals

  • Provide an id equivalent which Stacks can use to uniquely identify an extensible resource for change tracking.
  • Provide a mechanism to allow Stacks to submit Delete & Get operations against extensible resources.

This spec will be broken down into two parts to cover these separate goals.

@anthony-c-martin
anthony-c-martin / bicepgen.cs
Last active November 3, 2023 14:41
Random C# Samples
using System;
using System.Linq;
using Bicep.Core.Diagnostics;
using Bicep.Core.Parsing;
using Bicep.Core.PrettyPrint;
using Bicep.Core.PrettyPrint.Options;
using Bicep.Core.Syntax;
public class Program
{

Imagine the following Bicep file:

@allowed(['foo'])
param thisMustBeFoo string

param isFooFoo bool

With the following parameters file: