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

azapi.ResourceAction

Explore with Pulumi AI

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

    This resource can perform any Azure resource manager resource action. It’s recommended to use azapi.ResourceAction resource to perform actions which change a resource’s state, please use azapi.ResourceAction data source, if user wants to perform readonly action.

    Note When delete azapi.ResourceAction, no operation will be performed.

    Example Usage

    terraform {
      required_providers {
        azapi = {
          source = "Azure/azapi"
        }
      }
    }
    
    provider "azapi" {
    }
    
    provider "azurerm" {
      features {}
    }
    
    variable "enabled" {
      type        = bool
      default     = false
      description = "whether start the spring service"
    }
    
    resource "azurerm_resource_group" "example" {
      name     = "example-rg"
      location = "west europe"
    }
    
    resource "azurerm_spring_cloud_service" "test" {
      name                = "example-spring"
      resource_group_name = azurerm_resource_group.test.name
      location            = azurerm_resource_group.test.location
      sku_name            = "S0"
    }
    
    resource "azapi_resource_action" "start" {
      type                   = "Microsoft.AppPlatform/Spring@2022-05-01-preview"
      resource_id            = azurerm_spring_cloud_service.test.id
      action                 = "start"
      response_export_values = ["*"]
    
      count = var.enabled ? 1 : 0
    }
    
    resource "azapi_resource_action" "stop" {
      type                   = "Microsoft.AppPlatform/Spring@2022-05-01-preview"
      resource_id            = azurerm_spring_cloud_service.test.id
      action                 = "stop"
      response_export_values = ["*"]
    
      count = var.enabled ? 0 : 1
    }
    

    Here’s an example to use the azapi.ResourceAction resource to register a provider.

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

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

    terraform {
      required_providers {
        azapi = {
          source = "Azure/azapi"
        }
      }
    }
    
    data "azapi_resource_action" "test" {
      type        = "Microsoft.ResourceGraph@2020-04-01-preview"
      resource_id = "/providers/Microsoft.ResourceGraph"
      action      = "resources"
      body = jsonencode({
        query = "resources| where name contains \"test\""
      })
      response_export_values = ["*"]
    }
    

    Create ResourceAction Resource

    new ResourceAction(name: string, args: ResourceActionArgs, opts?: CustomResourceOptions);
    @overload
    def ResourceAction(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       action: Optional[str] = None,
                       body: Optional[str] = None,
                       locks: Optional[Sequence[str]] = None,
                       method: Optional[str] = None,
                       resource_id: Optional[str] = None,
                       response_export_values: Optional[Sequence[str]] = None,
                       type: Optional[str] = None)
    @overload
    def ResourceAction(resource_name: str,
                       args: ResourceActionArgs,
                       opts: Optional[ResourceOptions] = None)
    func NewResourceAction(ctx *Context, name string, args ResourceActionArgs, opts ...ResourceOption) (*ResourceAction, error)
    public ResourceAction(string name, ResourceActionArgs args, CustomResourceOptions? opts = null)
    public ResourceAction(String name, ResourceActionArgs args)
    public ResourceAction(String name, ResourceActionArgs args, CustomResourceOptions options)
    
    type: azapi:ResourceAction
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args ResourceActionArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args ResourceActionArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args ResourceActionArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ResourceActionArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ResourceActionArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    ResourceAction Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The ResourceAction resource accepts the following input properties:

    ResourceId string

    The ID of an existing azure source.

    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.

    Locks List<string>

    A list of ARM resource IDs which are used to avoid modify azapi resources at the same time.

    Method string

    Specifies the Http method of the azure resource action. Allowed values are POST, PATCH, PUT and DELETE. Defaults to POST.

    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=="
    }
    ]
    }
    
    ResourceId string

    The ID of an existing azure source.

    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.

    Locks []string

    A list of ARM resource IDs which are used to avoid modify azapi resources at the same time.

    Method string

    Specifies the Http method of the azure resource action. Allowed values are POST, PATCH, PUT and DELETE. Defaults to POST.

    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=="
    }
    ]
    }
    
    resourceId String

    The ID of an existing azure source.

    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.

    locks List<String>

    A list of ARM resource IDs which are used to avoid modify azapi resources at the same time.

    method String

    Specifies the Http method of the azure resource action. Allowed values are POST, PATCH, PUT and DELETE. Defaults to POST.

    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=="
    }
    ]
    }
    
    resourceId string

    The ID of an existing azure source.

    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.

    locks string[]

    A list of ARM resource IDs which are used to avoid modify azapi resources at the same time.

    method string

    Specifies the Http method of the azure resource action. Allowed values are POST, PATCH, PUT and DELETE. Defaults to POST.

    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=="
    }
    ]
    }
    
    resource_id str

    The ID of an existing azure source.

    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.

    locks Sequence[str]

    A list of ARM resource IDs which are used to avoid modify azapi resources at the same time.

    method str

    Specifies the Http method of the azure resource action. Allowed values are POST, PATCH, PUT and DELETE. Defaults to POST.

    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=="
    }
    ]
    }
    
    resourceId String

    The ID of an existing azure source.

    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.

    locks List<String>

    A list of ARM resource IDs which are used to avoid modify azapi resources at the same time.

    method String

    Specifies the Http method of the azure resource action. Allowed values are POST, PATCH, PUT and DELETE. Defaults to POST.

    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=="
    }
    ]
    }
    

    Outputs

    All input properties are implicitly available as output properties. Additionally, the ResourceAction resource produces the following output properties:

    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.

    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.

    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.

    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.

    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.

    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.

    Look up Existing ResourceAction Resource

    Get an existing ResourceAction resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: ResourceActionState, opts?: CustomResourceOptions): ResourceAction
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            action: Optional[str] = None,
            body: Optional[str] = None,
            locks: Optional[Sequence[str]] = None,
            method: Optional[str] = None,
            output: Optional[str] = None,
            resource_id: Optional[str] = None,
            response_export_values: Optional[Sequence[str]] = None,
            type: Optional[str] = None) -> ResourceAction
    func GetResourceAction(ctx *Context, name string, id IDInput, state *ResourceActionState, opts ...ResourceOption) (*ResourceAction, error)
    public static ResourceAction Get(string name, Input<string> id, ResourceActionState? state, CustomResourceOptions? opts = null)
    public static ResourceAction get(String name, Output<String> id, ResourceActionState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    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.

    Locks List<string>

    A list of ARM resource IDs which are used to avoid modify azapi resources at the same time.

    Method string

    Specifies the Http method of the azure resource action. Allowed values are POST, PATCH, PUT and DELETE. Defaults to POST.

    Output string

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

    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.

    Locks []string

    A list of ARM resource IDs which are used to avoid modify azapi resources at the same time.

    Method string

    Specifies the Http method of the azure resource action. Allowed values are POST, PATCH, PUT and DELETE. Defaults to POST.

    Output string

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

    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.

    locks List<String>

    A list of ARM resource IDs which are used to avoid modify azapi resources at the same time.

    method String

    Specifies the Http method of the azure resource action. Allowed values are POST, PATCH, PUT and DELETE. Defaults to POST.

    output String

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

    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.

    locks string[]

    A list of ARM resource IDs which are used to avoid modify azapi resources at the same time.

    method string

    Specifies the Http method of the azure resource action. Allowed values are POST, PATCH, PUT and DELETE. Defaults to POST.

    output string

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

    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 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.

    locks Sequence[str]

    A list of ARM resource IDs which are used to avoid modify azapi resources at the same time.

    method str

    Specifies the Http method of the azure resource action. Allowed values are POST, PATCH, PUT and DELETE. Defaults to POST.

    output str

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

    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 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 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.

    locks List<String>

    A list of ARM resource IDs which are used to avoid modify azapi resources at the same time.

    method String

    Specifies the Http method of the azure resource action. Allowed values are POST, PATCH, PUT and DELETE. Defaults to POST.

    output String

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

    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.

    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