1. Packages
  2. AzAPI
  3. API Docs
  4. getResourceId
AzAPI v1.12.2 published on Saturday, May 11, 2024 by dirien

azapi.getResourceId

Explore with Pulumi AI

azapi logo
AzAPI v1.12.2 published on Saturday, May 11, 2024 by dirien

    This resource can parse an Azure resource ID into its separate fields.

    Example Usage

    terraform {
      required_providers {
        azapi = {
          source = "Azure/azapi"
        }
      }
    }
    
    provider "azapi" {
    }
    
    data "azapi_resource_id" "account" {
      type        = "Microsoft.Automation/automationAccounts@2021-06-22"
      resource_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Automation/automationAccounts/automationAccount1"
    }
    
    output "account_name" {
      value = data.azapi_resource_id.account.name
    }
    
    output "account_resource_group" {
      value = data.azapi_resource_id.account.resource_group_name
    }
    
    output "account_subscription" {
      value = data.azapi_resource_id.account.subscription_id
    }
    
    output "account_parent_id" {
      value = data.azapi_resource_id.account.parent_id
    }
    
    data "azapi_resource_id" "vnet" {
      type      = "Microsoft.Network/virtualNetworks@2021-02-01"
      parent_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1"
      name      = "vnet1"
    }
    
    output "vnet_id" {
      value = data.azapi_resource_id.vnet.id
    }
    
    output "vnet_resource_group" {
      value = data.azapi_resource_id.vnet.resource_group_name
    }
    
    output "vnet_subscription" {
      value = data.azapi_resource_id.vnet.subscription_id
    }
    

    Using getResourceId

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getResourceId(args: GetResourceIdArgs, opts?: InvokeOptions): Promise<GetResourceIdResult>
    function getResourceIdOutput(args: GetResourceIdOutputArgs, opts?: InvokeOptions): Output<GetResourceIdResult>
    def get_resource_id(name: Optional[str] = None,
                        parent_id: Optional[str] = None,
                        resource_id: Optional[str] = None,
                        type: Optional[str] = None,
                        opts: Optional[InvokeOptions] = None) -> GetResourceIdResult
    def get_resource_id_output(name: Optional[pulumi.Input[str]] = None,
                        parent_id: Optional[pulumi.Input[str]] = None,
                        resource_id: Optional[pulumi.Input[str]] = None,
                        type: Optional[pulumi.Input[str]] = None,
                        opts: Optional[InvokeOptions] = None) -> Output[GetResourceIdResult]
    func GetResourceId(ctx *Context, args *GetResourceIdArgs, opts ...InvokeOption) (*GetResourceIdResult, error)
    func GetResourceIdOutput(ctx *Context, args *GetResourceIdOutputArgs, opts ...InvokeOption) GetResourceIdResultOutput

    > Note: This function is named GetResourceId in the Go SDK.

    public static class GetResourceId 
    {
        public static Task<GetResourceIdResult> InvokeAsync(GetResourceIdArgs args, InvokeOptions? opts = null)
        public static Output<GetResourceIdResult> Invoke(GetResourceIdInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetResourceIdResult> getResourceId(GetResourceIdArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: azapi:index/getResourceId:getResourceId
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Type string
    It is in a format like <resource-type>@<api-version>. <resource-type> is the Azure resource type, for example, Microsoft.Storage/storageAccounts. <api-version> is version of the API used to manage this azure resource.
    Name string
    Specifies the name of the azure resource.
    ParentId string

    The ID of the azure resource in which this resource is created. It supports different kinds of deployment scope for top level resources:

    • resource group scope: parent_id should be the ID of a resource group, it's recommended to manage a resource group by azurerm_resource_group.
    • management group scope: parent_id should be the ID of a management group, it's recommended to manage a management group by azurerm_management_group.
    • extension scope: parent_id should be the ID of the resource you're adding the extension to.
    • subscription scope: parent_id should be like /subscriptions/00000000-0000-0000-0000-000000000000
    • tenant scope: parent_id should be /

    For child level resources, the parent_id should be the ID of its parent resource, for example, subnet resource's parent_id is the ID of the vnet.

    ResourceId string

    The ID of an existing azure source.

    Note: Configuring name and parent_id is an alternative way to configure resource_id.

    Type string
    It is in a format like <resource-type>@<api-version>. <resource-type> is the Azure resource type, for example, Microsoft.Storage/storageAccounts. <api-version> is version of the API used to manage this azure resource.
    Name string
    Specifies the name of the azure resource.
    ParentId string

    The ID of the azure resource in which this resource is created. It supports different kinds of deployment scope for top level resources:

    • resource group scope: parent_id should be the ID of a resource group, it's recommended to manage a resource group by azurerm_resource_group.
    • management group scope: parent_id should be the ID of a management group, it's recommended to manage a management group by azurerm_management_group.
    • extension scope: parent_id should be the ID of the resource you're adding the extension to.
    • subscription scope: parent_id should be like /subscriptions/00000000-0000-0000-0000-000000000000
    • tenant scope: parent_id should be /

    For child level resources, the parent_id should be the ID of its parent resource, for example, subnet resource's parent_id is the ID of the vnet.

    ResourceId string

    The ID of an existing azure source.

    Note: Configuring name and parent_id is an alternative way to configure resource_id.

    type String
    It is in a format like <resource-type>@<api-version>. <resource-type> is the Azure resource type, for example, Microsoft.Storage/storageAccounts. <api-version> is version of the API used to manage this azure resource.
    name String
    Specifies the name of the azure resource.
    parentId String

    The ID of the azure resource in which this resource is created. It supports different kinds of deployment scope for top level resources:

    • resource group scope: parent_id should be the ID of a resource group, it's recommended to manage a resource group by azurerm_resource_group.
    • management group scope: parent_id should be the ID of a management group, it's recommended to manage a management group by azurerm_management_group.
    • extension scope: parent_id should be the ID of the resource you're adding the extension to.
    • subscription scope: parent_id should be like /subscriptions/00000000-0000-0000-0000-000000000000
    • tenant scope: parent_id should be /

    For child level resources, the parent_id should be the ID of its parent resource, for example, subnet resource's parent_id is the ID of the vnet.

    resourceId String

    The ID of an existing azure source.

    Note: Configuring name and parent_id is an alternative way to configure resource_id.

    type string
    It is in a format like <resource-type>@<api-version>. <resource-type> is the Azure resource type, for example, Microsoft.Storage/storageAccounts. <api-version> is version of the API used to manage this azure resource.
    name string
    Specifies the name of the azure resource.
    parentId string

    The ID of the azure resource in which this resource is created. It supports different kinds of deployment scope for top level resources:

    • resource group scope: parent_id should be the ID of a resource group, it's recommended to manage a resource group by azurerm_resource_group.
    • management group scope: parent_id should be the ID of a management group, it's recommended to manage a management group by azurerm_management_group.
    • extension scope: parent_id should be the ID of the resource you're adding the extension to.
    • subscription scope: parent_id should be like /subscriptions/00000000-0000-0000-0000-000000000000
    • tenant scope: parent_id should be /

    For child level resources, the parent_id should be the ID of its parent resource, for example, subnet resource's parent_id is the ID of the vnet.

    resourceId string

    The ID of an existing azure source.

    Note: Configuring name and parent_id is an alternative way to configure resource_id.

    type str
    It is in a format like <resource-type>@<api-version>. <resource-type> is the Azure resource type, for example, Microsoft.Storage/storageAccounts. <api-version> is version of the API used to manage this azure resource.
    name str
    Specifies the name of the azure resource.
    parent_id str

    The ID of the azure resource in which this resource is created. It supports different kinds of deployment scope for top level resources:

    • resource group scope: parent_id should be the ID of a resource group, it's recommended to manage a resource group by azurerm_resource_group.
    • management group scope: parent_id should be the ID of a management group, it's recommended to manage a management group by azurerm_management_group.
    • extension scope: parent_id should be the ID of the resource you're adding the extension to.
    • subscription scope: parent_id should be like /subscriptions/00000000-0000-0000-0000-000000000000
    • tenant scope: parent_id should be /

    For child level resources, the parent_id should be the ID of its parent resource, for example, subnet resource's parent_id is the ID of the vnet.

    resource_id str

    The ID of an existing azure source.

    Note: Configuring name and parent_id is an alternative way to configure resource_id.

    type String
    It is in a format like <resource-type>@<api-version>. <resource-type> is the Azure resource type, for example, Microsoft.Storage/storageAccounts. <api-version> is version of the API used to manage this azure resource.
    name String
    Specifies the name of the azure resource.
    parentId String

    The ID of the azure resource in which this resource is created. It supports different kinds of deployment scope for top level resources:

    • resource group scope: parent_id should be the ID of a resource group, it's recommended to manage a resource group by azurerm_resource_group.
    • management group scope: parent_id should be the ID of a management group, it's recommended to manage a management group by azurerm_management_group.
    • extension scope: parent_id should be the ID of the resource you're adding the extension to.
    • subscription scope: parent_id should be like /subscriptions/00000000-0000-0000-0000-000000000000
    • tenant scope: parent_id should be /

    For child level resources, the parent_id should be the ID of its parent resource, for example, subnet resource's parent_id is the ID of the vnet.

    resourceId String

    The ID of an existing azure source.

    Note: Configuring name and parent_id is an alternative way to configure resource_id.

    getResourceId Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    The name of the azure resource.
    ParentId string
    The ID of the azure resource in which this resource is created.
    Parts Dictionary<string, string>
    The map of the resource ID parts, where the key is the part name and the value is the part value. e.g. virtualNetworks=myVnet.
    ProviderNamespace string
    The azure resource provider namespace of the azure resource.
    ResourceGroupName string
    The resource group name of the azure resource.
    ResourceId string
    SubscriptionId string
    The subscription ID of the azure resource.
    Type string
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    The name of the azure resource.
    ParentId string
    The ID of the azure resource in which this resource is created.
    Parts map[string]string
    The map of the resource ID parts, where the key is the part name and the value is the part value. e.g. virtualNetworks=myVnet.
    ProviderNamespace string
    The azure resource provider namespace of the azure resource.
    ResourceGroupName string
    The resource group name of the azure resource.
    ResourceId string
    SubscriptionId string
    The subscription ID of the azure resource.
    Type string
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    The name of the azure resource.
    parentId String
    The ID of the azure resource in which this resource is created.
    parts Map<String,String>
    The map of the resource ID parts, where the key is the part name and the value is the part value. e.g. virtualNetworks=myVnet.
    providerNamespace String
    The azure resource provider namespace of the azure resource.
    resourceGroupName String
    The resource group name of the azure resource.
    resourceId String
    subscriptionId String
    The subscription ID of the azure resource.
    type String
    id string
    The provider-assigned unique ID for this managed resource.
    name string
    The name of the azure resource.
    parentId string
    The ID of the azure resource in which this resource is created.
    parts {[key: string]: string}
    The map of the resource ID parts, where the key is the part name and the value is the part value. e.g. virtualNetworks=myVnet.
    providerNamespace string
    The azure resource provider namespace of the azure resource.
    resourceGroupName string
    The resource group name of the azure resource.
    resourceId string
    subscriptionId string
    The subscription ID of the azure resource.
    type string
    id str
    The provider-assigned unique ID for this managed resource.
    name str
    The name of the azure resource.
    parent_id str
    The ID of the azure resource in which this resource is created.
    parts Mapping[str, str]
    The map of the resource ID parts, where the key is the part name and the value is the part value. e.g. virtualNetworks=myVnet.
    provider_namespace str
    The azure resource provider namespace of the azure resource.
    resource_group_name str
    The resource group name of the azure resource.
    resource_id str
    subscription_id str
    The subscription ID of the azure resource.
    type str
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    The name of the azure resource.
    parentId String
    The ID of the azure resource in which this resource is created.
    parts Map<String>
    The map of the resource ID parts, where the key is the part name and the value is the part value. e.g. virtualNetworks=myVnet.
    providerNamespace String
    The azure resource provider namespace of the azure resource.
    resourceGroupName String
    The resource group name of the azure resource.
    resourceId String
    subscriptionId String
    The subscription ID of the azure resource.
    type String

    Package Details

    Repository
    azapi dirien/pulumi-azapi
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the azapi Terraform Provider.
    azapi logo
    AzAPI v1.12.2 published on Saturday, May 11, 2024 by dirien