Giter Club home page Giter Club logo

terraspace_plugin_azurerm's Introduction

Terraspace Azurerm Plugin

BoltOps Badge

Gem Version

Azurerm support for terraspace.

Installation

Add this line to your application's Gemfile:

gem 'terraspace_plugin_azurerm'

Configure

Optionally configure the plugin. Here's an example azurerm.rb for your terraspace project.

config/plugins/azurerm.rb

TerraspacePluginAzurerm.configure do |config|
  config.auto_create = true # set false to disable auto creation

  config.storage_account.sku.name = "Standard_LRS"
  config.storage_account.sku.tier = "Standard"

  config.tags = {env: Terraspace.env, terraspace: true}
end

By default, this plugin will automatically create the:

The settings generally only apply if the resource does not yet exist yet and is created for the first time.

Environment Variables

To create the Azure resources like resource group, storage account, and storage container these environment variables are required:

ARM_CLIENT_ID
ARM_CLIENT_SECRET

Other env variables can be optionally set:

ARM_TENANT_ID
ARM_SUBSCRIPTION_ID

When not set, their values are inferred from the az cli settings. For those interested, this is done with the boltops-tools/azure_info library.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/boltops-tools/terraspace_plugin_azurerm.

terraspace_plugin_azurerm's People

Contributors

mikolajzajac avatar tongueroo avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

terraspace_plugin_azurerm's Issues

Azure Secrets

Testing the use of azure key vault secrets and running into a few issues. These are the scenarios I am testing:

  1. KeyVault not found
  2. Secret disabled
  3. Secret not found
  4. Secret deleted
  5. Secret present but not active (activation start > date)
  6. Secret expired (date > expiration date)

I have all my kv values in base.tfvars and refrence them in variables.tf

fwCommonUserName = "<%= azure_secret("fwCommonUserName") %>"

variable "fwCommonUserName" {
description = "The common firewall username."
}

It appears that the plugin is putting the message in the value when there is a problem. It would be more helpful to return the value as null so that one can use tf input variable validation to determine if one should go on without the secret.

My results:

  1. when doing ts up I get the message "WARN: Vault not found " on stdout and tf tries to replace the resource

module.spokeNetwork["sharedServices"].module.spokeNetworkInstance["web"].azurerm_windows_virtual_machine.vm_spoke_instance must be replaced

-/+ resource "azurerm_windows_virtual_machine" "vm_spoke_instance" {
~ admin_password = (sensitive value)
~ admin_username = "vmadmin" -> "WARN: Vault not found " # forces replacement

  1. similar to 1. but the message is "WARN: Operation get is not allowed on a disabled secret." and it tries to replace the resource

module.fwPaloAltoTransitCommon01.azurerm_linux_virtual_machine.vm_firewall must be replaced

-/+ resource "azurerm_linux_virtual_machine" "vm_firewall" {
~ admin_username = "vmadmin" -> "Operation get is not allowed on a disabled secret." # forces replacement

  1. similar to 1. and 2. but the message is "WARN: A secret with (name/id) fwCommonUserNames was not found in this key vault. If you recently deleted this secret you may be able to recover it using the correct recovery command. For help resolving this issue, please see https://go.microsoft.com/fwlink/?linkid=2125182" and it tries to replace the resource

module.fwPaloAltoTransitCommon01.azurerm_linux_virtual_machine.vm_firewall must be replaced

-/+ resource "azurerm_linux_virtual_machine" "vm_firewall" {
~ admin_username = "vmadmin" -> "A secret with (name/id) fwCommonUserNames was not found in this key vault. If you recently deleted this secret you may be able to recover it using the correct recovery command. For help resolving this issue, please see https://go.microsoft.com/fwlink/?linkid=2125182" # forces replacement

  1. same message as 3. and it tries to replace the resource
    5 and 6. the start and expiration dates are ignored. the resource gets created/modified as usual.

resource creation in wrong subscription

I am trying to solve the same problem that is answered in this post with Terraspace.

My .env file has both ARM_SUBSCRIPTION_ID set for the subscription that is supposed to hold the resources and ARM_BACKEND_SUBSCRIPTION_ID for the subscription where we are storing our terraform state.

My backend config looks like this:

terraform {
  backend "azurerm" {
    resource_group_name  = "<Name>"
    storage_account_name = "<%= expansion('<NAME>:ENV') %>"
    container_name       = "terraform-state"
    key                  = "<%= expansion(':PROJECT/:LOCATION/:APP/:ROLE/:ENV/:BUILD_DIR/terraform.tfstate') %>"
    subscription_id      = "<%= expansion(':ARM_BACKEND_SUBSCRIPTION_ID') %>"
  }
}

Yet the builder tries to find and create the resource group and storage account in the subscription set in ARM_SUBSCRIPTION_ID. I don't know Ruby but from scanning the code in here it seems that the subscription parameter from the backend block is not read anywhere.

Feature request: Network ACL support for Azure Storage Account backend plugin

I would like to request a feature in form of configuration options to enable Network ACL support for TerraspacePluginAzurerm auto-creation of the backend Storage Account.

Current implementation of the plugin creates the storage account backend with no Network ACLs, so the container can be accessed from anywhere.

The configuration could be:

  • Specify the default action to the Network Access ("Allow" or "Deny") for the storage account
  • Specify one or more network rules if the default action is "Deny":
  • The rules would contain CIDR and Action parameters

Security would be greatly improved if network access policies could be specified for the backend configuration.
Also, if security policies require an ACL to be present, the auto-creation of the storage account would fail.

Enable support for soft-delete for Azure backend storage account container and blobs

Summary

Add support for soft-delete for containers and blobs in Azure for the backend storage account.

Motivation

When the creation of the storage account for the backend is managed by Terraspace, soft-delete for containers and blobs is not enabled by default. It would be useful to have this enabled by default to restore a previous state file in case something went horribly wrong. Without this feature we have to enable these storage account settings manually and this might be forgotten.

Guide-level explanation

Reference-level explanation

Drawbacks

Unresolved Questions

feat: Azure MSI authentication support

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.