azapi.ResourceAction
Explore with Pulumi AI
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 The action can be performed on either apply or destroy. The default is apply, see
when
argument for more details.
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
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new ResourceAction(name: string, args: ResourceActionArgs, opts?: CustomResourceOptions);
@overload
def ResourceAction(resource_name: str,
args: ResourceActionArgs,
opts: Optional[ResourceOptions] = None)
@overload
def ResourceAction(resource_name: str,
opts: Optional[ResourceOptions] = None,
resource_id: Optional[str] = None,
type: Optional[str] = None,
action: Optional[str] = None,
body: Optional[str] = None,
locks: Optional[Sequence[str]] = None,
method: Optional[str] = None,
response_export_values: Optional[Sequence[str]] = None,
when: Optional[str] = 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.
Parameters
- 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.
Constructor example
The following reference example uses placeholder values for all input properties.
var resourceActionResource = new Azapi.ResourceAction("resourceActionResource", new()
{
ResourceId = "string",
Type = "string",
Action = "string",
Body = "string",
Locks = new[]
{
"string",
},
Method = "string",
ResponseExportValues = new[]
{
"string",
},
When = "string",
});
example, err := azapi.NewResourceAction(ctx, "resourceActionResource", &azapi.ResourceActionArgs{
ResourceId: pulumi.String("string"),
Type: pulumi.String("string"),
Action: pulumi.String("string"),
Body: pulumi.String("string"),
Locks: pulumi.StringArray{
pulumi.String("string"),
},
Method: pulumi.String("string"),
ResponseExportValues: pulumi.StringArray{
pulumi.String("string"),
},
When: pulumi.String("string"),
})
var resourceActionResource = new ResourceAction("resourceActionResource", ResourceActionArgs.builder()
.resourceId("string")
.type("string")
.action("string")
.body("string")
.locks("string")
.method("string")
.responseExportValues("string")
.when("string")
.build());
resource_action_resource = azapi.ResourceAction("resourceActionResource",
resource_id="string",
type="string",
action="string",
body="string",
locks=["string"],
method="string",
response_export_values=["string"],
when="string")
const resourceActionResource = new azapi.ResourceAction("resourceActionResource", {
resourceId: "string",
type: "string",
action: "string",
body: "string",
locks: ["string"],
method: "string",
responseExportValues: ["string"],
when: "string",
});
type: azapi:ResourceAction
properties:
action: string
body: string
locks:
- string
method: string
resourceId: string
responseExportValues:
- string
type: string
when: string
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
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The ResourceAction resource accepts the following input properties:
- Resource
Id 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
andDELETE
. Defaults toPOST
. - 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["keys"]
, it will set the following json to computed propertyoutput
.{ "keys": [ { "KeyName": "Primary", "Permissions": "Full", "Value": "nHGYNd******i4wdug==" }, { "KeyName": "Secondary", "Permissions": "Full", "Value": "6yoCad******SLzKzg==" } ] }
- When string
- When to perform the action, value must be one of:
apply
,destroy
. Default isapply
.
- Resource
Id 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
andDELETE
. Defaults toPOST
. - 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["keys"]
, it will set the following json to computed propertyoutput
.{ "keys": [ { "KeyName": "Primary", "Permissions": "Full", "Value": "nHGYNd******i4wdug==" }, { "KeyName": "Secondary", "Permissions": "Full", "Value": "6yoCad******SLzKzg==" } ] }
- When string
- When to perform the action, value must be one of:
apply
,destroy
. Default isapply
.
- resource
Id 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
andDELETE
. Defaults toPOST
. - 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["keys"]
, it will set the following json to computed propertyoutput
.{ "keys": [ { "KeyName": "Primary", "Permissions": "Full", "Value": "nHGYNd******i4wdug==" }, { "KeyName": "Secondary", "Permissions": "Full", "Value": "6yoCad******SLzKzg==" } ] }
- when String
- When to perform the action, value must be one of:
apply
,destroy
. Default isapply
.
- resource
Id 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
andDELETE
. Defaults toPOST
. - 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["keys"]
, it will set the following json to computed propertyoutput
.{ "keys": [ { "KeyName": "Primary", "Permissions": "Full", "Value": "nHGYNd******i4wdug==" }, { "KeyName": "Secondary", "Permissions": "Full", "Value": "6yoCad******SLzKzg==" } ] }
- when string
- When to perform the action, value must be one of:
apply
,destroy
. Default isapply
.
- 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
andDELETE
. Defaults toPOST
. - 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["keys"]
, it will set the following json to computed propertyoutput
.{ "keys": [ { "KeyName": "Primary", "Permissions": "Full", "Value": "nHGYNd******i4wdug==" }, { "KeyName": "Secondary", "Permissions": "Full", "Value": "6yoCad******SLzKzg==" } ] }
- when str
- When to perform the action, value must be one of:
apply
,destroy
. Default isapply
.
- resource
Id 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
andDELETE
. Defaults toPOST
. - 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["keys"]
, it will set the following json to computed propertyoutput
.{ "keys": [ { "KeyName": "Primary", "Permissions": "Full", "Value": "nHGYNd******i4wdug==" }, { "KeyName": "Secondary", "Permissions": "Full", "Value": "6yoCad******SLzKzg==" } ] }
- when String
- When to perform the action, value must be one of:
apply
,destroy
. Default isapply
.
Outputs
All input properties are implicitly available as output properties. Additionally, the ResourceAction resource produces the following output properties:
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,
when: 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.
- 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
andDELETE
. Defaults toPOST
. - Output string
- The output json containing the properties specified in
response_export_values
. Here are some examples to decode json and extract the value. - Resource
Id string - The ID of an existing azure source.
- 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["keys"]
, it will set the following json to computed propertyoutput
.{ "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. - When string
- When to perform the action, value must be one of:
apply
,destroy
. Default isapply
.
- 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
andDELETE
. Defaults toPOST
. - Output string
- The output json containing the properties specified in
response_export_values
. Here are some examples to decode json and extract the value. - Resource
Id string - The ID of an existing azure source.
- 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["keys"]
, it will set the following json to computed propertyoutput
.{ "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. - When string
- When to perform the action, value must be one of:
apply
,destroy
. Default isapply
.
- 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
andDELETE
. Defaults toPOST
. - output String
- The output json containing the properties specified in
response_export_values
. Here are some examples to decode json and extract the value. - resource
Id String - The ID of an existing azure source.
- 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["keys"]
, it will set the following json to computed propertyoutput
.{ "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. - when String
- When to perform the action, value must be one of:
apply
,destroy
. Default isapply
.
- 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
andDELETE
. Defaults toPOST
. - output string
- The output json containing the properties specified in
response_export_values
. Here are some examples to decode json and extract the value. - resource
Id string - The ID of an existing azure source.
- 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["keys"]
, it will set the following json to computed propertyoutput
.{ "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. - when string
- When to perform the action, value must be one of:
apply
,destroy
. Default isapply
.
- 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
andDELETE
. Defaults toPOST
. - 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_ 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["keys"]
, it will set the following json to computed propertyoutput
.{ "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. - when str
- When to perform the action, value must be one of:
apply
,destroy
. Default isapply
.
- 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
andDELETE
. Defaults toPOST
. - output String
- The output json containing the properties specified in
response_export_values
. Here are some examples to decode json and extract the value. - resource
Id String - The ID of an existing azure source.
- 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["keys"]
, it will set the following json to computed propertyoutput
.{ "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. - when String
- When to perform the action, value must be one of:
apply
,destroy
. Default isapply
.
Package Details
- Repository
- azapi dirien/pulumi-azapi
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azapi
Terraform Provider.