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

azapi.getResourceAction

Explore with Pulumi AI

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

    This resource can perform resource action which gets information from an existing resource. It’s recommended to use azapi.ResourceAction data source to perform readonly action, please use azapi.ResourceAction resource, if user wants to perform actions which change a resource’s state.

    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_automation_account" "example" {
      name                = "example-account"
      resource_group_name = azurerm_resource_group.example.name
      location            = azurerm_resource_group.example.location
      sku_name            = "Basic"
    }
    
    data "azapi_resource_action" "example" {
      type                   = "Microsoft.Automation/automationAccounts@2021-06-22"
      resource_id            = azurerm_automation_account.example.id
      action                 = "listKeys"
      response_export_values = ["*"]
    }
    

    Here’s an example to use the azapi.ResourceAction data source to get a provider’s permissions.

    provider "azurerm" {
      features {}
    }
    
    data "azurerm_client_config" "current" {}
    
    data "azapi_resource_action" "test" {
      type        = "Microsoft.Resources/providers@2021-04-01"
      resource_id = "/subscriptions/${data.azurerm_client_config.current.subscription_id}/providers/Microsoft.Network"
      action      = "providerPermissions"
      method      = "GET"
    }
    

    Here’s an example to use the azapi.ResourceAction data source to perform a provider action.

    terraform {
      required_providers {
        azapi = {
          source = "Azure/azapi"
        }
      }
    }
    
    resource "azapi_resource_action" "test" {
      type        = "Microsoft.Cache@2023-04-01"
      resource_id = "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Cache"
      action      = "CheckNameAvailability"
      body = jsonencode({
        type = "Microsoft.Cache/Redis"
        name = "cacheName"
      })
    }
    

    Using getResourceAction

    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 getResourceAction(args: GetResourceActionArgs, opts?: InvokeOptions): Promise<GetResourceActionResult>
    function getResourceActionOutput(args: GetResourceActionOutputArgs, opts?: InvokeOptions): Output<GetResourceActionResult>
    def get_resource_action(action: Optional[str] = None,
                            body: Optional[str] = None,
                            method: Optional[str] = None,
                            resource_id: Optional[str] = None,
                            response_export_values: Optional[Sequence[str]] = None,
                            type: Optional[str] = None,
                            opts: Optional[InvokeOptions] = None) -> GetResourceActionResult
    def get_resource_action_output(action: Optional[pulumi.Input[str]] = None,
                            body: Optional[pulumi.Input[str]] = None,
                            method: 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[GetResourceActionResult]
    func LookupResourceAction(ctx *Context, args *LookupResourceActionArgs, opts ...InvokeOption) (*LookupResourceActionResult, error)
    func LookupResourceActionOutput(ctx *Context, args *LookupResourceActionOutputArgs, opts ...InvokeOption) LookupResourceActionResultOutput

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

    public static class GetResourceAction 
    {
        public static Task<GetResourceActionResult> InvokeAsync(GetResourceActionArgs args, InvokeOptions? opts = null)
        public static Output<GetResourceActionResult> Invoke(GetResourceActionInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetResourceActionResult> getResourceAction(GetResourceActionArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: azapi:index/getResourceAction:getResourceAction
      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.
    Action string
    The name of the resource action. It's also possible to make Http requests towards the resource ID if leave this field empty.
    Body string
    A JSON object that contains the request body.
    Method string
    Specifies the Http method of the azure resource action. Allowed values are POST and GET. Defaults to POST.
    ResourceId string
    The ID of an existing azure source.
    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 ["keys"], it will set the following json to computed property output.

    {
    "keys": [
    {
    "KeyName": "Primary",
    "Permissions": "Full",
    "Value": "nHGYNd******i4wdug=="
    },
    {
    "KeyName": "Secondary",
    "Permissions": "Full",
    "Value": "6yoCad******SLzKzg=="
    }
    ]
    }
    
    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.
    Action string
    The name of the resource action. It's also possible to make Http requests towards the resource ID if leave this field empty.
    Body string
    A JSON object that contains the request body.
    Method string
    Specifies the Http method of the azure resource action. Allowed values are POST and GET. Defaults to POST.
    ResourceId string
    The ID of an existing azure source.
    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 ["keys"], it will set the following json to computed property output.

    {
    "keys": [
    {
    "KeyName": "Primary",
    "Permissions": "Full",
    "Value": "nHGYNd******i4wdug=="
    },
    {
    "KeyName": "Secondary",
    "Permissions": "Full",
    "Value": "6yoCad******SLzKzg=="
    }
    ]
    }
    
    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.
    action String
    The name of the resource action. It's also possible to make Http requests towards the resource ID if leave this field empty.
    body String
    A JSON object that contains the request body.
    method String
    Specifies the Http method of the azure resource action. Allowed values are POST and GET. Defaults to POST.
    resourceId String
    The ID of an existing azure source.
    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 ["keys"], it will set the following json to computed property output.

    {
    "keys": [
    {
    "KeyName": "Primary",
    "Permissions": "Full",
    "Value": "nHGYNd******i4wdug=="
    },
    {
    "KeyName": "Secondary",
    "Permissions": "Full",
    "Value": "6yoCad******SLzKzg=="
    }
    ]
    }
    
    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.
    action string
    The name of the resource action. It's also possible to make Http requests towards the resource ID if leave this field empty.
    body string
    A JSON object that contains the request body.
    method string
    Specifies the Http method of the azure resource action. Allowed values are POST and GET. Defaults to POST.
    resourceId string
    The ID of an existing azure source.
    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 ["keys"], it will set the following json to computed property output.

    {
    "keys": [
    {
    "KeyName": "Primary",
    "Permissions": "Full",
    "Value": "nHGYNd******i4wdug=="
    },
    {
    "KeyName": "Secondary",
    "Permissions": "Full",
    "Value": "6yoCad******SLzKzg=="
    }
    ]
    }
    
    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.
    action str
    The name of the resource action. It's also possible to make Http requests towards the resource ID if leave this field empty.
    body str
    A JSON object that contains the request body.
    method str
    Specifies the Http method of the azure resource action. Allowed values are POST and GET. Defaults to POST.
    resource_id str
    The ID of an existing azure source.
    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 ["keys"], it will set the following json to computed property output.

    {
    "keys": [
    {
    "KeyName": "Primary",
    "Permissions": "Full",
    "Value": "nHGYNd******i4wdug=="
    },
    {
    "KeyName": "Secondary",
    "Permissions": "Full",
    "Value": "6yoCad******SLzKzg=="
    }
    ]
    }
    
    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.
    action String
    The name of the resource action. It's also possible to make Http requests towards the resource ID if leave this field empty.
    body String
    A JSON object that contains the request body.
    method String
    Specifies the Http method of the azure resource action. Allowed values are POST and GET. Defaults to POST.
    resourceId String
    The ID of an existing azure source.
    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 ["keys"], it will set the following json to computed property output.

    {
    "keys": [
    {
    "KeyName": "Primary",
    "Permissions": "Full",
    "Value": "nHGYNd******i4wdug=="
    },
    {
    "KeyName": "Secondary",
    "Permissions": "Full",
    "Value": "6yoCad******SLzKzg=="
    }
    ]
    }
    

    getResourceAction Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    Output string
    The output json containing the properties specified in response_export_values. Here are some examples to decode json and extract the value.

    // it will output "nHGYNd******i4wdug=="
    output "primary_key" {
    value = jsondecode(azapi_resource_action.test.output).keys.0.Value
    }
    
    Type string
    Action string
    Body string
    Method string
    ResourceId string
    ResponseExportValues List<string>
    Id string
    The provider-assigned unique ID for this managed resource.
    Output string
    The output json containing the properties specified in response_export_values. Here are some examples to decode json and extract the value.

    // it will output "nHGYNd******i4wdug=="
    output "primary_key" {
    value = jsondecode(azapi_resource_action.test.output).keys.0.Value
    }
    
    Type string
    Action string
    Body string
    Method string
    ResourceId string
    ResponseExportValues []string
    id String
    The provider-assigned unique ID for this managed resource.
    output String
    The output json containing the properties specified in response_export_values. Here are some examples to decode json and extract the value.

    // it will output "nHGYNd******i4wdug=="
    output "primary_key" {
    value = jsondecode(azapi_resource_action.test.output).keys.0.Value
    }
    
    type String
    action String
    body String
    method String
    resourceId String
    responseExportValues List<String>
    id string
    The provider-assigned unique ID for this managed resource.
    output string
    The output json containing the properties specified in response_export_values. Here are some examples to decode json and extract the value.

    // it will output "nHGYNd******i4wdug=="
    output "primary_key" {
    value = jsondecode(azapi_resource_action.test.output).keys.0.Value
    }
    
    type string
    action string
    body string
    method string
    resourceId string
    responseExportValues string[]
    id str
    The provider-assigned unique ID for this managed resource.
    output str
    The output json containing the properties specified in response_export_values. Here are some examples to decode json and extract the value.

    // it will output "nHGYNd******i4wdug=="
    output "primary_key" {
    value = jsondecode(azapi_resource_action.test.output).keys.0.Value
    }
    
    type str
    action str
    body str
    method str
    resource_id str
    response_export_values Sequence[str]
    id String
    The provider-assigned unique ID for this managed resource.
    output String
    The output json containing the properties specified in response_export_values. Here are some examples to decode json and extract the value.

    // it will output "nHGYNd******i4wdug=="
    output "primary_key" {
    value = jsondecode(azapi_resource_action.test.output).keys.0.Value
    }
    
    type String
    action String
    body String
    method String
    resourceId String
    responseExportValues List<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