Manages a Resource Deployment Script of Azure PowerShell.
resource "azurerm_resource_group" "example" {
name = "example-resources"
location = "West Europe"
}
resource "azurerm_user_assigned_identity" "example" {
name = "example-uai"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
}
resource "azurerm_resource_deployment_script_azure_power_shell" "example" {
name = "example-rdsaps"
resource_group_name = azurerm_resource_group.example.name
location = "West Europe"
version = "8.3"
retention_interval = "P1D"
command_line = "-name \"John Dole\""
cleanup_preference = "OnSuccess"
force_update_tag = "1"
timeout = "PT30M"
script_content = <<EOF
param([string] $name)
$output = 'Hello {0}.' -f $name
Write-Output $output
$DeploymentScriptOutputs = @{}
$DeploymentScriptOutputs['text'] = $output
EOF
identity {
type = "UserAssigned"
identity_ids = [
azurerm_user_assigned_identity.example.id
]
}
tags = {
key = "value"
}
}
param([string] $name)
$output = 'Hello {0}.' -f $name
Write-Output $output
$DeploymentScriptOutputs = @{}
$DeploymentScriptOutputs['text'] = $output
EOF
identity {
type = "UserAssigned"
identity_ids = [
azurerm_user_assigned_identity.example.id
]
}
tags = {
key = "value"
}
}
The following arguments are supported:
name
- (Required) Specifies the name which should be used for this Resource Deployment Script. The name length must be from 1 to 260 characters. The name can only contain alphanumeric, underscore, parentheses, hyphen and period, and it cannot end with a period. Changing this forces a new Resource Deployment Script to be created.
resource_group_name
- (Required) Specifies the name of the Resource Group where the Resource Deployment Script should exist. Changing this forces a new Resource Deployment Script to be created.
location
- (Required) Specifies the Azure Region where the Resource Deployment Script should exist. Changing this forces a new Resource Deployment Script to be created.
version
- (Required) Specifies the version of the Azure PowerShell that should be used in the format X.Y
(e.g. 9.7
). A canonical list of versions is available from the Microsoft Container Registry API. Changing this forces a new Resource Deployment Script to be created.
retention_interval
- (Required) Interval for which the service retains the script resource after it reaches a terminal state. Resource will be deleted when this duration expires. The time duration should be between 1
hour and 26
hours (inclusive) and should be specified in ISO 8601 format. Changing this forces a new Resource Deployment Script to be created.
command_line
- (Optional) Command line arguments to pass to the script. Changing this forces a new Resource Deployment Script to be created.
cleanup_preference
- (Optional) Specifies the cleanup preference when the script execution gets in a terminal state. Possible values are Always
, OnExpiration
, OnSuccess
. Defaults to Always
. Changing this forces a new Resource Deployment Script to be created.
container
- (Optional) A container
block as defined below. Changing this forces a new Resource Deployment Script to be created.
environment_variable
- (Optional) An environment_variable
block as defined below. Changing this forces a new Resource Deployment Script to be created.
force_update_tag
- (Optional) Gets or sets how the deployment script should be forced to execute even if the script resource has not changed. Can be current time stamp or a GUID. Changing this forces a new Resource Deployment Script to be created.
identity
- (Optional) An identity
block as defined below. Changing this forces a new Resource Deployment Script to be created.
primary_script_uri
- (Optional) Uri for the script. This is the entry point for the external script. Changing this forces a new Resource Deployment Script to be created.
script_content
- (Optional) Script body. Changing this forces a new Resource Deployment Script to be created.
storage_account
- (Optional) A storage_account
block as defined below. Changing this forces a new Resource Deployment Script to be created.
supporting_script_uris
- (Optional) Supporting files for the external script. Changing this forces a new Resource Deployment Script to be created.
timeout
- (Optional) Maximum allowed script execution time specified in ISO 8601 format. Needs to be greater than 0 and smaller than 1 day. Defaults to P1D
. Changing this forces a new Resource Deployment Script to be created.
tags
- (Optional) A mapping of tags which should be assigned to the Resource Deployment Script.
A container
block supports the following:
container_group_name
- (Optional) Container group name, if not specified then the name will get auto-generated. For more information, please refer to the Container Configuration documentation.An environment_variable
block supports the following:
name
- (Required) Specifies the name of the environment variable.
secure_value
- (Optional) Specifies the value of the secure environment variable.
value
- (Optional) Specifies the value of the environment variable.
An identity
block supports the following:
type
- (Required) Type of the managed identity. The only possible value is UserAssigned
. Changing this forces a new resource to be created.
identity_ids
- (Required) Specifies the list of user-assigned managed identity IDs associated with the resource. Changing this forces a new resource to be created.
A storage_account
block supports the following:
key
- (Required) Specifies the storage account access key.
name
- (Required) Specifies the storage account name.
In addition to the Arguments listed above - the following Attributes are exported:
id
- The ID of the Resource Deployment Script.
outputs
- List of script outputs.
The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 30 minutes) Used when creating the Resource Deployment Script.read
- (Defaults to 5 minutes) Used when retrieving the Resource Deployment Script.update
- (Defaults to 30 minutes) Used when updating the Resource Deployment Script.delete
- (Defaults to 30 minutes) Used when deleting the Resource Deployment Script.Resource Deployment Script can be imported using the resource id
, e.g.
terraform import azurerm_resource_deployment_script_azure_power_shell.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.Resources/deploymentScripts/script1