azapi.getResource
Explore with Pulumi AI
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. Get Resource Identity - 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.
- Parent
Id 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'sparent_id
is the ID of the vnet.For type
Microsoft.Resources/resourceGroups
, theparent_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 group scope:
- Resource
Id string The ID of an existing azure source.
Note: Configuring
name
andparent_id
is an alternative way to configureresource_id
.- Response
Export List<string>Values - 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 propertyoutput
.{ "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
Get
Resource Identity - 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.
- Parent
Id 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'sparent_id
is the ID of the vnet.For type
Microsoft.Resources/resourceGroups
, theparent_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 group scope:
- Resource
Id string The ID of an existing azure source.
Note: Configuring
name
andparent_id
is an alternative way to configureresource_id
.- Response
Export []stringValues - 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 propertyoutput
.{ "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
Get
Resource Identity - 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.
- parent
Id 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'sparent_id
is the ID of the vnet.For type
Microsoft.Resources/resourceGroups
, theparent_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 group scope:
- resource
Id String The ID of an existing azure source.
Note: Configuring
name
andparent_id
is an alternative way to configureresource_id
.- response
Export List<String>Values - 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 propertyoutput
.{ "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
Get
Resource Identity - 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.
- parent
Id 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'sparent_id
is the ID of the vnet.For type
Microsoft.Resources/resourceGroups
, theparent_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 group scope:
- resource
Id string The ID of an existing azure source.
Note: Configuring
name
andparent_id
is an alternative way to configureresource_id
.- response
Export string[]Values - 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 propertyoutput
.{ "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
Get
Resource Identity - 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'sparent_id
is the ID of the vnet.For type
Microsoft.Resources/resourceGroups
, theparent_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 group scope:
- resource_
id str The ID of an existing azure source.
Note: Configuring
name
andparent_id
is an alternative way to configureresource_id
.- response_
export_ Sequence[str]values - 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 propertyoutput
.{ "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.
- parent
Id 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'sparent_id
is the ID of the vnet.For type
Microsoft.Resources/resourceGroups
, theparent_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 group scope:
- resource
Id String The ID of an existing azure source.
Note: Configuring
name
andparent_id
is an alternative way to configureresource_id
.- response
Export List<String>Values - 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 propertyoutput
.{ "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. Get Resource Identity - 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 }
- Parent
Id string - 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
andSystemAssigned,UserAssigned
. - Name string
- Resource
Id string - Response
Export List<string>Values
- Id string
- The provider-assigned unique ID for this managed resource.
- Identity
Get
Resource Identity - 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 }
- Parent
Id string - 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
andSystemAssigned,UserAssigned
. - Name string
- Resource
Id string - Response
Export []stringValues
- id String
- The provider-assigned unique ID for this managed resource.
- identity
Get
Resource Identity - 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 }
- parent
Id String - 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
andSystemAssigned,UserAssigned
. - name String
- resource
Id String - response
Export List<String>Values
- id string
- The provider-assigned unique ID for this managed resource.
- identity
Get
Resource Identity - 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 }
- parent
Id string - {[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
andSystemAssigned,UserAssigned
. - name string
- resource
Id string - response
Export string[]Values
- id str
- The provider-assigned unique ID for this managed resource.
- identity
Get
Resource Identity - 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 - 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
andSystemAssigned,UserAssigned
. - name str
- resource_
id str - response_
export_ Sequence[str]values
- 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 }
- parent
Id String - 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
andSystemAssigned,UserAssigned
. - name String
- resource
Id String - response
Export List<String>Values
Supporting Types
GetResourceIdentity
- Identity
Ids List<string> - A list of User Managed Identity ID's which should be assigned to the azure resource.
- Principal
Id string - The Principal ID for the Service Principal associated with the Managed Service Identity of this azure resource.
- Tenant
Id 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 []string - A list of User Managed Identity ID's which should be assigned to the azure resource.
- Principal
Id string - The Principal ID for the Service Principal associated with the Managed Service Identity of this azure resource.
- Tenant
Id 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 List<String> - A list of User Managed Identity ID's which should be assigned to the azure resource.
- principal
Id String - The Principal ID for the Service Principal associated with the Managed Service Identity of this azure resource.
- tenant
Id 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 string[] - A list of User Managed Identity ID's which should be assigned to the azure resource.
- principal
Id string - The Principal ID for the Service Principal associated with the Managed Service Identity of this azure resource.
- tenant
Id 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.
- identity
Ids List<String> - A list of User Managed Identity ID's which should be assigned to the azure resource.
- principal
Id String - The Principal ID for the Service Principal associated with the Managed Service Identity of this azure resource.
- tenant
Id 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.