Skip to content

Commit

Permalink
Add example for Microsoft.Cache_redis_accessPolicyAssignments@2023-04-01
Browse files Browse the repository at this point in the history
  • Loading branch information
neil-yechenwei committed Feb 10, 2025
1 parent ea43948 commit e409304
Showing 1 changed file with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
terraform {
required_providers {
azapi = {
source = "Azure/azapi"
}
}
}

provider "azurerm" {
features {}
}

provider "azapi" {
skip_provider_registration = false
}

data "azurerm_client_config" "test" {
}

variable "resource_name" {
type = string
default = "acctest0001"
}

variable "location" {
type = string
default = "eastus"
}

resource "azapi_resource" "resourceGroup" {
type = "Microsoft.Resources/resourceGroups@2020-06-01"
name = var.resource_name
location = var.location
}

resource "azapi_resource" "redis" {
type = "Microsoft.Cache/redis@2023-04-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
body = {
properties = {
sku = {
capacity = 2
family = "C"
name = "Standard"
}
enableNonSslPort = true
minimumTlsVersion = "1.2"
}
}
schema_validation_enabled = false
response_export_values = ["*"]
}

resource "azapi_resource" "addUser" {
type = "Microsoft.Cache/redis/accessPolicyAssignments@2024-03-01"
name = var.resource_name
parent_id = azapi_resource.redis.id
body = {
properties = {
accessPolicyName = "Data Contributor"
objectId = data.azurerm_client_config.test.object_id
objectIdAlias = "ServicePrincipal"
}
}
}

0 comments on commit e409304

Please sign in to comment.