Coder Social home page Coder Social logo

terraform-azure-quickstarts-samples's Introduction

Terraform - Azure Quickstarts

Overview

Reference Azure Terraform templates for the most common Azure deployment patterns.

Azure Authentication

The following arguments are required to authenticate against the AzureRM Provider:

  • subscription_id - The subscription ID to use. It can also be sourced from the ARM_SUBSCRIPTION_ID environment variable.
  • client_id - The client ID to use. It can also be sourced from the ARM_CLIENT_ID environment variable.
  • client_secret - The client secret to use. It can also be sourced from the ARM_CLIENT_SECRET environment variable.
  • tenant_id - The tenant ID to use. It can also be sourced from the ARM_TENANT_ID environment variable.
  • environment - (Optional) The cloud environment to use. It can also be sourced from the ARM_ENVIRONMENT environment variable. Supported values are:
    • public (default)
    • usgovernment
    • german
    • china

Obtaining the Azure Authentication details

Authenticate using the Azure CLI.

> az login

If you have multiple Azure Subscriptions, their details will be returned by the az login command. Set the SUBSCRIPTION_ID environment variable to hold the value of the returned id field from the Subscription you want to use.

Set the Subscription that you want to use for this session.

> az account set --subscription="${SUBSCRIPTION_ID}"

Subscription and Tenant Details

Query the account to get the Subscription Id and Tenant Id values.

> az account show --query "{subscriptionId:id, tenantId:tenantId}"

Create Azure Credentials

It is advisable to create separate credentials for Terraform. These can be created as follows:

az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/${SUBSCRIPTION_ID}"

This will output your client_id, client_secret (password), sp_name, and tenant. Take note of the client_id and client_secret.

You can confirm your credentials (service principal) by opening a new shell and run the following commands substituting in the returned values for sp_name, client_secret, and tenant:

> az login --service-principal -u SP_NAME -p CLIENT_SECRET --tenant TENANT
> az vm list-sizes --location westus

Environment Variables

Set the following environment variables from the values you have obtained:

  • ARM_SUBSCRIPTION_ID
  • ARM_CLIENT_ID
  • ARM_CLIENT_SECRET
  • ARM_TENANT_ID

terraform-azure-quickstarts-samples's People

Contributors

paulbouwer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.