GithubHelp home page GithubHelp logo

azure / keyvault-secrets-rotation-template-powershell Goto Github PK

View Code? Open in Web Editor NEW
8.0 4.0 10.0 62 KB

Template to create Azure Function for secrets rotation in PowerShell

License: MIT License

PowerShell 100.00%

keyvault-secrets-rotation-template-powershell's Introduction

###THIS IS TEMPLATE PROJECT FOR SECRET ROTATION FUNCTIONS. FOLLOW THIS STEPS TO CREATE NEW SECRETS ROTATION FUNCTION PROJECT REPOSITORY###.

KeyVault-Secrets-Rotation-[ServiceType]-PowerShell

Functions regenerate individual key (alternating between two keys) in [ServiceType] and add regenerated key to Key Vault as new version of the same secret.

Features

This project framework provides the following features:

  • Rotation function for [ServiceType] key triggered by Event Grid (AKV[ServiceType]Rotation)

  • Rotation function for [ServiceType] key triggered by HTTP call (AKV[ServiceType]RotationHttp)

  • ARM template for function deployment with secret deployment (optional)

  • ARM template for adding [ServiceType] key to existing function with secret deployment (optional)

Getting Started

Functions require following information stored in secret as tags:

  • $secret.Tags["ValidityPeriodDays"] - number of days, it defines expiration date for new secret
  • $secret.Tags["CredentialId"] - [ServiceType] credential id
  • $secret.Tags["ProviderAddress"] - [ServiceType] Resource Id

You can create new secret with above tags and [ServiceType] key as value or add those tags to existing secret with [ServiceType] key. For automated rotation expiry date will also be required - key vault triggers 'SecretNearExpiry' event 30 days before expiry.

There are two available functions performing same rotation:

  • AKV[ServiceType]Rotation - event triggered function, performs [ServiceType] key rotation triggered by Key Vault events. In this setup Near Expiry event is used which is published 30 days before expiration
  • AKV[ServiceType]RotationHttp - on-demand function with KeyVaultName and Secret name as parameters

Functions are using Function App identity to access Key Vault and existing secret "CredentialId" tag with [ServiceType] key id (key1/key2) and "ProviderAddress" with [ServiceType] Resource Id.

Installation

ARM templates available:

Demo

You can find example for Storage Account rotation in tutorial below: Automate the rotation of a secret for resources that have two sets of authentication credentials

Youtube: https://youtu.be/qcdVbXJ7e-4

Project template information:

This project was generated using this template. You can find instructions here

keyvault-secrets-rotation-template-powershell's People

Contributors

jlichwa avatar microsoft-github-operations[bot] avatar microsoft-github-policy-service[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

keyvault-secrets-rotation-template-powershell's Issues

Guidance on Rotation

Hi Jack (@jlichwa ),
I am new to exploring Key Vault (kva) stuffs, currently I deployed few key vaults and I managed to encrypt some VMs using Customer Managed keys. Our new requirement is to use HSM keys instead of RSA. We deploy all resources using Terraform and deployed via Az DevOps, but my challenge is -rotating RSA/HSM keys while the key generation happens in Terraform.

  1. Can I achieve the same using terraform to create Resources required to rotate kva keys?
  2. For rotation in addition to source kva, only Az function & event grid is required?
  3. What exactly needs to be coded in function app?
  4. I couldn't find any Az CLI syntax to generate new version of keys, any URL of MS documentation?
  5. How is the triggering of event upon key/secret expiry set up in a kva?
  6. The apply of latest version is automatic, right? Especially to the encrypted disks?

Your time and response would be a great help ๐Ÿ˜„ If am not mistake, I think in coming days, this topic would be a hot requirement!

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.