1. Packages
  2. AzAPI
  3. API Docs
  4. getResource
AzAPI v1.10.0 published on Wednesday, Nov 15, 2023 by dirien

azapi.getResource

Explore with Pulumi AI

azapi logo
AzAPI v1.10.0 published on Wednesday, Nov 15, 2023 by dirien

    This resource can access any existing Azure resource manager resource.

    Example Usage

    terraform {
      required_providers {
        azapi = {
          source = "Azure/azapi"
        }
      }
    }
    
    provider "azapi" {
    }
    
    provider "azurerm" {
      features {}
    }
    
    resource "azurerm_resource_group" "example" {
      name     = "example-rg"
      location = "west europe"
    }
    
    resource "azurerm_container_registry" "example" {
      name                = "example"
      resource_group_name = azurerm_resource_group.example.name
      location            = azurerm_resource_group.example.location
      sku                 = "Premium"
      admin_enabled       = false
    }
    
    data "azapi_resource" "example" {
      name      = "example"
      parent_id = azurerm_resource_group.example.id
      type      = "Microsoft.ContainerRegistry/registries@2020-11-01-preview"
    
      response_export_values = ["properties.loginServer", "properties.policies.quarantinePolicy.status"]
    }
    
    // it will output "registry1.azurecr.io"
    output "login_server" {
      value = jsondecode(data.azapi_resource.example.output).properties.loginServer
    }
    
    // it will output "disabled"
    output "quarantine_policy" {
      value = jsondecode(data.azapi_resource.example.output).properties.policies.quarantinePolicy.status
    }
    

    Using getResource

    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 getResource(args: GetResourceArgs, opts?: InvokeOptions): Promise<GetResourceResult>
    function getResourceOutput(args: GetResourceOutputArgs, opts?: InvokeOptions): Output<GetResourceResult>
    def get_resource(identity: Optional[GetResourceIdentity] = None,
                     name: Optional[str] = None,
                     parent_id: Optional[str] = None,
                     resource_id: Optional[str] = None,
                     response_export_values: Optional[Sequence[str]] = None,
                     type: Optional[str] = None,
                     opts: Optional[InvokeOptions] = None) -> GetResourceResult
    def get_resource_output(identity: Optional[pulumi.Input[GetResourceIdentityArgs]] = None,
                     name: Optional[pulumi.Input[str]] = None,
                     parent_id: Optional[pulumi.Input[str]] = None,
                     resource_id: Optional[pulumi.Input[str]] = None,
                     response_export_values: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                     type: Optional[pulumi.Input[str]] = None,
                     opts: Optional[InvokeOptions] = None) -> Output[GetResourceResult]
    func LookupResource(ctx *Context, args *LookupResourceArgs, opts ...InvokeOption) (*LookupResourceResult, error)
    func LookupResourceOutput(ctx *Context, args *LookupResourceOutputArgs, opts ...InvokeOption) LookupResourceResultOutput

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

    public static class GetResource 
    {
        public static Task<GetResourceResult> InvokeAsync(GetResourceArgs args, InvokeOptions? opts = null)
        public static Output<GetResourceResult> Invoke(GetResourceInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetResourceResult> getResource(GetResourceArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: azapi:index/getResource:getResource
      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.

    Identity ediri.Azapi.Inputs.GetResourceIdentity

    An identity block as defined below, which contains the Managed Service Identity information for 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.

    For type Microsoft.Resources/resourceGroups, the parent_id could be omitted, it defaults to subscription ID specified in provider or the default subscription(You could check the default subscription by azure cli command: az account show).

    ResourceId string

    The ID of an existing azure source.

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

    ResponseExportValues List<string>

    A list of path that needs to be exported from response body. Setting it to ["*"] will export the full response body. Here's an example. If it sets to ["properties.loginServer", "properties.policies.quarantinePolicy.status"], it will set the following json to computed property output.

    {
    "properties" : {
    "loginServer" : "registry1.azurecr.io"
    "policies" : {
    "quarantinePolicy" = {
    "status" = "disabled"
    }
    }
    }
    }
    
    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.

    Identity GetResourceIdentity

    An identity block as defined below, which contains the Managed Service Identity information for 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.

    For type Microsoft.Resources/resourceGroups, the parent_id could be omitted, it defaults to subscription ID specified in provider or the default subscription(You could check the default subscription by azure cli command: az account show).

    ResourceId string

    The ID of an existing azure source.

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

    ResponseExportValues []string

    A list of path that needs to be exported from response body. Setting it to ["*"] will export the full response body. Here's an example. If it sets to ["properties.loginServer", "properties.policies.quarantinePolicy.status"], it will set the following json to computed property output.

    {
    "properties" : {
    "loginServer" : "registry1.azurecr.io"
    "policies" : {
    "quarantinePolicy" = {
    "status" = "disabled"
    }
    }
    }
    }
    
    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.

    identity GetResourceIdentity

    An identity block as defined below, which contains the Managed Service Identity information for 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.

    For type Microsoft.Resources/resourceGroups, the parent_id could be omitted, it defaults to subscription ID specified in provider or the default subscription(You could check the default subscription by azure cli command: az account show).

    resourceId String

    The ID of an existing azure source.

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

    responseExportValues List<String>

    A list of path that needs to be exported from response body. Setting it to ["*"] will export the full response body. Here's an example. If it sets to ["properties.loginServer", "properties.policies.quarantinePolicy.status"], it will set the following json to computed property output.

    {
    "properties" : {
    "loginServer" : "registry1.azurecr.io"
    "policies" : {
    "quarantinePolicy" = {
    "status" = "disabled"
    }
    }
    }
    }
    
    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.

    identity GetResourceIdentity

    An identity block as defined below, which contains the Managed Service Identity information for 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.

    For type Microsoft.Resources/resourceGroups, the parent_id could be omitted, it defaults to subscription ID specified in provider or the default subscription(You could check the default subscription by azure cli command: az account show).

    resourceId string

    The ID of an existing azure source.

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

    responseExportValues string[]

    A list of path that needs to be exported from response body. Setting it to ["*"] will export the full response body. Here's an example. If it sets to ["properties.loginServer", "properties.policies.quarantinePolicy.status"], it will set the following json to computed property output.

    {
    "properties" : {
    "loginServer" : "registry1.azurecr.io"
    "policies" : {
    "quarantinePolicy" = {
    "status" = "disabled"
    }
    }
    }
    }
    
    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.

    identity GetResourceIdentity

    An identity block as defined below, which contains the Managed Service Identity information for 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.

    For type Microsoft.Resources/resourceGroups, the parent_id could be omitted, it defaults to subscription ID specified in provider or the default subscription(You could check the default subscription by azure cli command: az account show).

    resource_id str

    The ID of an existing azure source.

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

    response_export_values Sequence[str]

    A list of path that needs to be exported from response body. Setting it to ["*"] will export the full response body. Here's an example. If it sets to ["properties.loginServer", "properties.policies.quarantinePolicy.status"], it will set the following json to computed property output.

    {
    "properties" : {
    "loginServer" : "registry1.azurecr.io"
    "policies" : {
    "quarantinePolicy" = {
    "status" = "disabled"
    }
    }
    }
    }
    
    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.

    identity Property Map

    An identity block as defined below, which contains the Managed Service Identity information for 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.

    For type Microsoft.Resources/resourceGroups, the parent_id could be omitted, it defaults to subscription ID specified in provider or the default subscription(You could check the default subscription by azure cli command: az account show).

    resourceId String

    The ID of an existing azure source.

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

    responseExportValues List<String>

    A list of path that needs to be exported from response body. Setting it to ["*"] will export the full response body. Here's an example. If it sets to ["properties.loginServer", "properties.policies.quarantinePolicy.status"], it will set the following json to computed property output.

    {
    "properties" : {
    "loginServer" : "registry1.azurecr.io"
    "policies" : {
    "quarantinePolicy" = {
    "status" = "disabled"
    }
    }
    }
    }
    

    getResource Result

    The following output properties are available:

    Id string

    The provider-assigned unique ID for this managed resource.

    Identity ediri.Azapi.Outputs.GetResourceIdentity

    An identity block as defined below, which contains the Managed Service Identity information for this azure resource.

    Location string

    The Azure Region where the azure resource should exist.

    Output string

    The output json containing the properties specified in response_export_values. Here're some examples to decode json and extract the value.

    // it will output "registry1.azurecr.io"
    output "login_server" {
    value = jsondecode(azapi_resource.example.output).properties.loginServer
    }
    
    ParentId string
    Tags Dictionary<string, string>

    A mapping of tags which should be assigned to the azure resource.

    Type string

    The Type of Identity which should be used for this azure resource. Possible values are SystemAssigned, UserAssigned and SystemAssigned,UserAssigned.

    Name string
    ResourceId string
    ResponseExportValues List<string>
    Id string

    The provider-assigned unique ID for this managed resource.

    Identity GetResourceIdentity

    An identity block as defined below, which contains the Managed Service Identity information for this azure resource.

    Location string

    The Azure Region where the azure resource should exist.

    Output string

    The output json containing the properties specified in response_export_values. Here're some examples to decode json and extract the value.

    // it will output "registry1.azurecr.io"
    output "login_server" {
    value = jsondecode(azapi_resource.example.output).properties.loginServer
    }
    
    ParentId string
    Tags map[string]string

    A mapping of tags which should be assigned to the azure resource.

    Type string

    The Type of Identity which should be used for this azure resource. Possible values are SystemAssigned, UserAssigned and SystemAssigned,UserAssigned.

    Name string
    ResourceId string
    ResponseExportValues []string
    id String

    The provider-assigned unique ID for this managed resource.

    identity GetResourceIdentity

    An identity block as defined below, which contains the Managed Service Identity information for this azure resource.

    location String

    The Azure Region where the azure resource should exist.

    output String

    The output json containing the properties specified in response_export_values. Here're some examples to decode json and extract the value.

    // it will output "registry1.azurecr.io"
    output "login_server" {
    value = jsondecode(azapi_resource.example.output).properties.loginServer
    }
    
    parentId String
    tags Map<String,String>

    A mapping of tags which should be assigned to the azure resource.

    type String

    The Type of Identity which should be used for this azure resource. Possible values are SystemAssigned, UserAssigned and SystemAssigned,UserAssigned.

    name String
    resourceId String
    responseExportValues List<String>
    id string

    The provider-assigned unique ID for this managed resource.

    identity GetResourceIdentity

    An identity block as defined below, which contains the Managed Service Identity information for this azure resource.

    location string

    The Azure Region where the azure resource should exist.

    output string

    The output json containing the properties specified in response_export_values. Here're some examples to decode json and extract the value.

    // it will output "registry1.azurecr.io"
    output "login_server" {
    value = jsondecode(azapi_resource.example.output).properties.loginServer
    }
    
    parentId string
    tags {[key: string]: string}

    A mapping of tags which should be assigned to the azure resource.

    type string

    The Type of Identity which should be used for this azure resource. Possible values are SystemAssigned, UserAssigned and SystemAssigned,UserAssigned.

    name string
    resourceId string
    responseExportValues string[]
    id str

    The provider-assigned unique ID for this managed resource.

    identity GetResourceIdentity

    An identity block as defined below, which contains the Managed Service Identity information for this azure resource.

    location str

    The Azure Region where the azure resource should exist.

    output str

    The output json containing the properties specified in response_export_values. Here're some examples to decode json and extract the value.

    // it will output "registry1.azurecr.io"
    output "login_server" {
    value = jsondecode(azapi_resource.example.output).properties.loginServer
    }
    
    parent_id str
    tags Mapping[str, str]

    A mapping of tags which should be assigned to the azure resource.

    type str

    The Type of Identity which should be used for this azure resource. Possible values are SystemAssigned, UserAssigned and SystemAssigned,UserAssigned.

    name str
    resource_id str
    response_export_values Sequence[str]
    id String

    The provider-assigned unique ID for this managed resource.

    identity Property Map

    An identity block as defined below, which contains the Managed Service Identity information for this azure resource.

    location String

    The Azure Region where the azure resource should exist.

    output String

    The output json containing the properties specified in response_export_values. Here're some examples to decode json and extract the value.

    // it will output "registry1.azurecr.io"
    output "login_server" {
    value = jsondecode(azapi_resource.example.output).properties.loginServer
    }
    
    parentId String
    tags Map<String>

    A mapping of tags which should be assigned to the azure resource.

    type String

    The Type of Identity which should be used for this azure resource. Possible values are SystemAssigned, UserAssigned and SystemAssigned,UserAssigned.

    name String
    resourceId String
    responseExportValues List<String>

    Supporting Types

    GetResourceIdentity

    IdentityIds List<string>

    A list of User Managed Identity ID's which should be assigned to the azure resource.

    PrincipalId string

    The Principal ID for the Service Principal associated with the Managed Service Identity of this azure resource.

    TenantId string

    The Tenant ID for the Service Principal associated with the Managed Service Identity of this azure resource.

    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.

    IdentityIds []string

    A list of User Managed Identity ID's which should be assigned to the azure resource.

    PrincipalId string

    The Principal ID for the Service Principal associated with the Managed Service Identity of this azure resource.

    TenantId string

    The Tenant ID for the Service Principal associated with the Managed Service Identity of this azure resource.

    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.

    identityIds List<String>

    A list of User Managed Identity ID's which should be assigned to the azure resource.

    principalId String

    The Principal ID for the Service Principal associated with the Managed Service Identity of this azure resource.

    tenantId String

    The Tenant ID for the Service Principal associated with the Managed Service Identity of this azure resource.

    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.

    identityIds string[]

    A list of User Managed Identity ID's which should be assigned to the azure resource.

    principalId string

    The Principal ID for the Service Principal associated with the Managed Service Identity of this azure resource.

    tenantId string

    The Tenant ID for the Service Principal associated with the Managed Service Identity of this azure resource.

    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.

    identity_ids Sequence[str]

    A list of User Managed Identity ID's which should be assigned to the azure resource.

    principal_id str

    The Principal ID for the Service Principal associated with the Managed Service Identity of this azure resource.

    tenant_id str

    The Tenant ID for the Service Principal associated with the Managed Service Identity of this azure resource.

    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.

    identityIds List<String>

    A list of User Managed Identity ID's which should be assigned to the azure resource.

    principalId String

    The Principal ID for the Service Principal associated with the Managed Service Identity of this azure resource.

    tenantId String

    The Tenant ID for the Service Principal associated with the Managed Service Identity of this azure resource.

    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.

    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.10.0 published on Wednesday, Nov 15, 2023 by dirien