Skip to content

Instantly share code, notes, and snippets.

View straubt1's full-sized avatar
💭
Terraform All The Things

Tom Straub straubt1

💭
Terraform All The Things
View GitHub Profile
variable "data_disks" {
default = [
{
lun = 0
size = 32
},
{
lun = 1
size = 128
},
resource "azurerm_virtual_machine" "myvm" {
name = "myvm0"
resource_group_name = "my-rg"
vm_size = "Standard_A2_v2"
location = "centralus"
network_interface_ids = ["${azurerm_network_interface.myvm.id}"]
storage_image_reference {
publisher = "MicrosoftWindowsServer"
offer = "WindowsServer"
data "azurerm_subscription" "primary" {}
resource "random_string" "password" {
length = 32
special = true
}
locals {
spn_name = "tfexample"
spn_expire = "2020-01-01T00:00:00Z"
@straubt1
straubt1 / locks-existingterraform.tf
Created August 20, 2018 17:04
Terraform Azure Management Locks
resource "azurerm_resource_group" "main" {
name = "cardinal-rg"
location = "centralus"
}
resource "azurerm_management_lock" "resource-group-level" {
name = "resource-group-level"
scope = "${azurerm_resource_group.main.id}"
lock_level = "ReadOnly"
notes = "This Resource Group is Read-Only"
@straubt1
straubt1 / main-assignment-multiple.tf
Last active October 11, 2020 04:32
Terraform Azure Policy & Assignment
data "template_file" "requiredTag_policy_rule" {
template = <<POLICY_RULE
{
"if": {
"field": "[concat('tags[', parameters('tagName'), ']')]",
"exists": "false"
},
"then": {
"effect": "audit"
}
@straubt1
straubt1 / debug.log
Created March 17, 2018 21:56
terraform-provider-azurerm:azurerm_function_app
2018/03/17 16:34:20 [INFO] Terraform version: 0.11.4 7878d66b386e5474102b5047722c2de2b3237278
2018/03/17 16:34:20 [INFO] Go runtime version: go1.10
2018/03/17 16:34:20 [INFO] CLI args: []string{"/usr/local/Cellar/tfenv/0.6.0/versions/0.11.4/terraform", "apply", "--auto-approve"}
2018/03/17 16:34:20 [DEBUG] Attempting to open CLI config file: /Users/REDACTED/.terraformrc
2018/03/17 16:34:20 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2018/03/17 16:34:20 [INFO] CLI command args: []string{"apply", "--auto-approve"}
2018/03/17 16:34:20 [INFO] command: empty terraform config, returning nil
2018/03/17 16:34:20 [DEBUG] command: no data state file found for backend config
2018/03/17 16:34:20 [DEBUG] New state was assigned lineage "a2f5e219-9ab1-393f-192e-0e4c8efe354d"
2018/03/17 16:34:20 [INFO] command: backend initialized: <nil>
@straubt1
straubt1 / DataInstaller.cs
Created August 21, 2015 12:48
AOPinIoC_DataInstaller
public class DataInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
var isProd = ConfigurationManager.AppSettings["IsProduction"] == "True";
container.Register(Component.For<ExceptionAspect>());
container.Register(Component.For<TimingAspect>());
var iProjData = Component.For<IProjectData>().ImplementedBy<ProjectDataLocal>();
iProjData.Interceptors(typeof(ExceptionAspect));
@straubt1
straubt1 / ProjectDataLocal_GetAllItems.cs
Created August 21, 2015 12:38
AOPinIoC_DataInstaller_GetAllItems
[ExceptionAspect]
[TimingAspect]
public List<ProjectItem> GetAllItems()
{
return _masterList;
}
@straubt1
straubt1 / DataInstaller.cs
Created August 21, 2015 12:36
AOPinIoC_DataInstaller
public class DataInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(Component.For<ExceptionAspect>());
container.Register(Component.For<TimingAspect>());
container.Register(Component.For<IProjectData>()
.ImplementedBy<ProjectDataLocal>()
.Interceptors(
@straubt1
straubt1 / TimingAspect.cs
Created August 21, 2015 12:34
AOPinIoC_TimingAspect
public class TimingAspect : Aspect
{
public override void ProcessInvocation(IInvocation invocation)
{
var sw = Stopwatch.StartNew();
invocation.Proceed();
sw.Stop();
Console.WriteLine("({0})Elapsed: {1}", invocation.MethodInvocationTarget.Name, sw.Elapsed);
}
}