This Construct represents a Resource Group in Azure using the AZAPI provider for direct Azure REST API access. It provides immediate access to new Azure features and version-specific implementations.
In Azure, a Resource Group is a container that holds related resources for an Azure solution. It's a logical group for resources deployed on Azure. All the resources in a group should have the same lifecycle and the same permissions, which makes it easier to manage, monitor, and analyze collectively.
You can learn more about Resource Groups in the official Azure documentation.
This Resource Group construct uses the AZAPI provider, which provides:
- Direct Azure REST API Access: No dependency on AzureRM provider limitations
- Immediate Feature Access: Get new Azure features as soon as they're available
- Version-Specific Implementations: Support for multiple API versions
- Enhanced Type Safety: Better IDE support and compile-time validation
- Use a consistent naming convention for your resource groups and other Azure resources
- Group resources that share the same lifecycle and permissions
- Avoid putting too many resources in a single group for easier troubleshooting
- Use resource groups to separate resources managed by different teams
- Apply meaningful tags for organization and cost tracking
This Construct supports the following properties:
location: (Required) The Azure Region where the Resource Group will be deployedname: (Optional) The name of the Azure Resource Group. Defaults torg-{stack-name}tags: (Optional) Key-value pairs for resource tagging and organizationmanagedBy: (Optional) ID of the resource that manages this resource groupignoreChanges: (Optional) Lifecycle rules to ignore changes for specific properties
| API Version | Status | Features |
|---|---|---|
| 2024-11-01 | ✅ Latest | Full feature support with latest Azure capabilities |
Deploy a Resource Group using the latest API version:
import { Group } from "@microsoft/terraform-cdk-constructs/azure-resourcegroup";
const resourceGroup = new Group(this, 'myResourceGroup', {
name: 'rg-myapp-prod',
location: 'eastus',
tags: {
environment: 'production',
project: 'myapp',
owner: 'platform-team'
}
});Use a specific API version for fine-grained control:
import { Group } from "@microsoft/terraform-cdk-constructs/azure-resourcegroup/v2024_11_01";
const resourceGroup = new Group(this, 'myResourceGroup', {
name: 'rg-myapp-prod',
location: 'eastus',
tags: {
environment: 'production'
},
managedBy: '/subscriptions/xxx/resourceGroups/management-rg'
});Specify a management resource for resource groups managed by other services:
const managedRG = new Group(this, 'managedRG', {
name: 'rg-aks-managed',
location: 'eastus',
managedBy: '/subscriptions/xxx/resourceGroups/main-rg/providers/Microsoft.ContainerService/managedClusters/my-aks'
});Ignore changes to specific properties:
const resourceGroup = new Group(this, 'myResourceGroup', {
name: 'rg-myapp-prod',
location: 'eastus',
ignoreChanges: ['tags', 'managedBy']
});The Resource Group construct provides several outputs for use in other resources:
// Access resource group properties
console.log(resourceGroup.id); // Resource Group ID
console.log(resourceGroup.name); // Resource Group name
console.log(resourceGroup.location); // Resource Group location
// Access Terraform outputs
resourceGroup.idOutput; // Terraform output for ID
resourceGroup.nameOutput; // Terraform output for name
resourceGroup.locationOutput; // Terraform output for location
resourceGroup.tagsOutput; // Terraform output for tagsIf you're migrating from the AzureRM-based version (v0.x), the main differences are:
- Direct API Access: Uses Azure REST API directly instead of AzureRM provider
- Required Location: The
locationproperty is now required - Enhanced Features: Access to latest Azure features and API versions
- Version Control: Ability to specify exact API versions
See the Migration Guide for detailed migration instructions.