Using Azure Storage for Terraform State - Best Practices

Ғылым және технология

The azurerm backend is one of many options for storing Terraform state data remotely. It leverages an Azure storage account and container to store the JSON data as a blob. Since state data is critical to the proper operation of Terraform and it can contain potentially sensitive information, how should you go about configuring your storage accounts to ensure proper access, encryption, and network access? And how do you ensure your state data is durable, highly available, and protected? That's what we'll cover in today's Terraform Tuesday.
In the video we'll cover the following:
🌮 Storage account authentication and authorization
🌮 Network access and encryption options
🌮 Best practices and decision points
Check out my Terraform certification guide here: leanpub.com/terraform-certified
And the Day Two Cloud podcast here: packetpushers.net/podcast/day...
Thank you so much for watching! Subscribe if you think I’ve earned it. Hit the bell as well if you’re feeling swell.❤️&🌮
✅🔔 Subscribe ► nedinthecloud.com/SubscribeYT
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
🌮 Other videos to check out:
📽️ Terraform Basics - Modules: • Terraform Basics: Modules
📽️ Managing Multiple Environments with Terraform: • Managing Multiple Envi...
📽️ Workload Identity with Terraform Cloud: • Using Workload Identit...
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
🌮 Timestamps:
⌚ 0:00 Intro
⌚ 1:51 AzureRM Backend
⌚ 2:52 Design Decisions
⌚ 3:58 Authentication Options
⌚ 7:13 Encryption Options
⌚ 8:56 Network Access
⌚ 10:33 Access Permissions
⌚ 12:21 Example Configuration
⌚ 19:59 Testing the Configuration
⌚ 23:09 Final Thoughts
⌚ 24:19 Thank You!
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
#terraform #hashicorp #devops #cloudengineer
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
⭐ CONNECT WITH ME 🏃🦖
🌐 Day Two Cloud: daytwocloud.io
🌐 Chaos Lever: chaoslever.com
🌐 Visit my Website ► nedinthecloud.com
🗳 Pluralsight ► app.pluralsight.com/profile/a...
🐙 Find the code at GitHub► github.com/ned1313
🐧 Twitter ► / ned1313
👨‍💼 LinkedIn► / ned-bellavance
For collaboration or any queries: ned@nedinthecloud.com
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
🌮 About Me 🌮
Ned is a curious human with a knack for creating entertaining and informative content. With over 20 years in the industry, Ned brings real-world experience to all his creative endeavours, whether that's pontificating on a podcast, delivering live instruction, writing certification guides, or producing technical training videos. He has been a helpdesk operator, systems administrator, cloud architect, and product manager. In his newest incarnation, Ned is the Founder of Ned in the Cloud LLC. As a one-man-tech juggernaut, he develops courses for Pluralsight, runs two podcasts (Day Two Cloud and Chaos Lever, and creates original content for technology vendors.
Ned has been a Microsoft MVP since 2017 and a HashiCorp Ambassador since 2020, and he holds a bunch of industry certifications that have no bearing on anything beyond his exceptional ability to take exams and pass them. When not in front of the camera, keyboard, and microphone, you can find Ned running the scenic trails of Pennsylvania or rocking out to live music in his hometown of Philadelphia. Ned has three guiding principles: Embrace discomfort, Fail often, and Be kind.

Пікірлер: 16

  • @Tech-ub8dd
    @Tech-ub8dd6 ай бұрын

    You gave better explanation of storage account settings then some of azure content creators. Thank you for the video.

  • @matt-ffffff
    @matt-ffffff6 ай бұрын

    Great vid, as usual :) I recommend using user-assigned managed identities, rather than Entra SPNs. Reasons are twofold: Firstly, it's an ARM resource so much easier to manage admin access and RBAC (the Entra permissions model is horrible). Secondly, UMIs work with both cloud-based ci/cd (using federation & OIDC) AND they work with self-hosted ci/cd as they can be assigned to the resource as a managed identity 😀

  • @cybrsrce
    @cybrsrce5 ай бұрын

    Thanks for this, you've given me a good path. I'm not an Azure guy and I'm trying to secure state access while using Azure DevOps. Currently using the storage key as a secret but I would rather use another method with private endpoints.

  • @judededude
    @judededude5 ай бұрын

    Do you have a video on using Azure Storage for TFstate and running a pipeline using Azure DevOps, but using App Registration for running the pipeline - would love to know your recommendations for best practices

  • @NedintheCloud

    @NedintheCloud

    5 ай бұрын

    Not yet, but I like the idea!

  • @lolorolande
    @lolorolande5 ай бұрын

    Very good explanation on how to store and secure a tfstate on an azurerm. I even learnt the access conditions which is very powerful. I never came across a real use-case. One feedback on the GRS replication. With GRS the tfstate will be replicated to the pair region, but you will rely on the microsoft support team to failover the master nodes of the storage accounts before you can access the tfstate on the other region. Most of the time this is to respond to a datacenter or availability zone failure. and it could take some hours in some circumstances. To mitigate that I would recommend RAGZRS when possible (or RAGRS) (1- ZRS means your state got replicated in all availability zones in the region, meaning you can mitigate an AZ failure, 2- G replicate to the pair region, 3- RA will keep the replica on the paired region readable, meaning you don't have to wait to access the tfstate if needed.)

  • @dus10dnd
    @dus10dnd6 ай бұрын

    Do that OIDC! Oh, also... instead of Entra ID service principals... Managed Identities... no need to talk with the Graph API with the AzureAD provider... one provider, one API, good practices!

  • @NicholasDavitashvili
    @NicholasDavitashvili5 ай бұрын

    Banger of a vid as usual, Ned! Question: Wouldn’t service endpoint be a better choice for Azure-hosted worker nodes? Privatelink is expensive. Service endpoint is free.

  • @NedintheCloud

    @NedintheCloud

    5 ай бұрын

    Depends on your requirements. Private link keeps the traffic off the public network side. Service endpoint still uses the public endpoint of the storage account, but restricts traffic.

  • @aminniktash9006
    @aminniktash90066 ай бұрын

    Great content as always, please explain a scenario that covers the provision of blob behind a private endpoint along with a Linux VM agent for Azure DevOps that has access to the blob, the agent will be used for running the terraform pipeline while having access to the backend for state file. I did set the agent with an extension for vm but wondering if there is a clear terraform solution for the ADO self-host agents? Thanks again Ned.

  • @valp8198
    @valp81985 ай бұрын

    I absolutely love these videos. There's always something new I can use to make my TF code better. Do you think you can make a video on how to have a VM join an on-premise domain (not Azure AD) with TF code? I haven't found a way to do that yet.

  • @NedintheCloud

    @NedintheCloud

    3 ай бұрын

    Depends on the platform you are deploying to. You can use a provisioner, but it's better to use a startup script of some kind.

  • @valp8198

    @valp8198

    3 ай бұрын

    @NedintheCloud thanks. I found that using an extension works best for my windows VMs. For Linux that's been another issue though.

  • @diegopauletto
    @diegopauletto2 ай бұрын

    Good one! How do you handle the backend code repository? I mean do you create a repository just for the storage account?

  • @NedintheCloud

    @NedintheCloud

    2 ай бұрын

    That's a super tough one. I've seen three basic approaches: 1. Use a managed service that provides a state backend for you 2. Create the azure storage account in the same config and then update the backend block to use the storage account you just created (aka inception) 3. Have a dedicated repository and workspace that provisions storage accounts for other deployments

  • @ttf5782
    @ttf57825 ай бұрын

    Generate sas token. My wish list.

Келесі