blob: ee58a8a6998c8a373cdde6f07ffe70d93e5478bc [file] [log] [blame]
---
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in
# .github/CONTRIBUTING.md.
#
# ----------------------------------------------------------------------------
subcategory: "Cloud Deploy"
description: |-
An `Automation` enables the automation of manually driven actions for a Delivery Pipeline, which includes Release promotion amongst Targets, Rollout repair and Rollout deployment strategy advancement.
---
# google\_clouddeploy\_automation
An `Automation` enables the automation of manually driven actions for a Delivery Pipeline, which includes Release promotion amongst Targets, Rollout repair and Rollout deployment strategy advancement.
~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider.
See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources.
To get more information about Automation, see:
* [API documentation](https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.deliveryPipelines.automations)
* How-to Guides
* [Automate your deployment](https://cloud.google.com/deploy/docs/automation)
## Example Usage - Clouddeploy Automation Basic
```hcl
resource "google_clouddeploy_automation" "b-automation" {
provider = google-beta
name = "cd-automation"
project = google_clouddeploy_delivery_pipeline.pipeline.project
location = google_clouddeploy_delivery_pipeline.pipeline.location
delivery_pipeline = google_clouddeploy_delivery_pipeline.pipeline.name
service_account = "my@service-account.com"
selector {
targets {
id = "*"
}
}
suspended = false
rules {
promote_release_rule {
id = "promote-release"
}
}
}
resource "google_clouddeploy_delivery_pipeline" "pipeline" {
provider = google-beta
name = "cd-pipeline"
location = "us-central1"
serial_pipeline {
stages {
target_id = "test"
profiles = []
}
}
}
```
## Example Usage - Clouddeploy Automation Full
```hcl
resource "google_clouddeploy_automation" "f-automation" {
provider = google-beta
name = "cd-automation"
location = "us-central1"
delivery_pipeline = google_clouddeploy_delivery_pipeline.pipeline.name
service_account = "my@service-account.com"
annotations = {
my_first_annotation = "example-annotation-1"
my_second_annotation = "example-annotation-2"
}
labels = {
my_first_label = "example-label-1"
my_second_label = "example-label-2"
}
description = "automation resource"
selector {
targets {
id = "test"
labels = {
foo = "bar"
}
}
}
suspended = true
rules {
promote_release_rule{
id = "promote-release"
wait = "200s"
destination_target_id = "@next"
destination_phase = "stable"
}
}
rules {
advance_rollout_rule {
id = "advance-rollout"
source_phases = ["deploy"]
wait = "200s"
}
}
}
resource "google_clouddeploy_delivery_pipeline" "pipeline" {
provider = google-beta
name = "cd-pipeline"
location = "us-central1"
serial_pipeline {
stages {
target_id = "test"
profiles = ["test-profile"]
}
}
}
```
## Argument Reference
The following arguments are supported:
* `name` -
(Required)
Name of the `Automation`.
* `service_account` -
(Required)
Required. Email address of the user-managed IAM service account that creates Cloud Deploy release and rollout resources.
* `selector` -
(Required)
Required. Selected resources to which the automation will be applied.
Structure is [documented below](#nested_selector).
* `rules` -
(Required)
Required. List of Automation rules associated with the Automation resource. Must have at least one rule and limited to 250 rules per Delivery Pipeline. Note: the order of the rules here is not the same as the order of execution.
Structure is [documented below](#nested_rules).
* `location` -
(Required)
The location for the resource
* `delivery_pipeline` -
(Required)
The delivery_pipeline for the resource
<a name="nested_selector"></a>The `selector` block supports:
* `targets` -
(Required)
Contains attributes about a target.
Structure is [documented below](#nested_targets).
<a name="nested_targets"></a>The `targets` block supports:
* `id` -
(Optional)
ID of the `Target`. The value of this field could be one of the following: * The last segment of a target name. It only needs the ID to determine which target is being referred to * "*", all targets in a location.
* `labels` -
(Optional)
Target labels.
<a name="nested_rules"></a>The `rules` block supports:
* `promote_release_rule` -
(Optional)
Optional. `PromoteReleaseRule` will automatically promote a release from the current target to a specified target.
Structure is [documented below](#nested_promote_release_rule).
* `advance_rollout_rule` -
(Optional)
Optional. The `AdvanceRolloutRule` will automatically advance a successful Rollout.
Structure is [documented below](#nested_advance_rollout_rule).
<a name="nested_promote_release_rule"></a>The `promote_release_rule` block supports:
* `id` -
(Required)
Required. ID of the rule. This id must be unique in the `Automation` resource to which this rule belongs. The format is `a-z{0,62}`.
* `wait` -
(Optional)
Optional. How long the release need to be paused until being promoted to the next target.
* `destination_target_id` -
(Optional)
Optional. The ID of the stage in the pipeline to which this `Release` is deploying. If unspecified, default it to the next stage in the promotion flow. The value of this field could be one of the following: * The last segment of a target name. It only needs the ID to determine if the target is one of the stages in the promotion sequence defined in the pipeline. * "@next", the next target in the promotion sequence.
* `destination_phase` -
(Optional)
Optional. The starting phase of the rollout created by this operation. Default to the first phase.
<a name="nested_advance_rollout_rule"></a>The `advance_rollout_rule` block supports:
* `id` -
(Required)
Required. ID of the rule. This id must be unique in the `Automation` resource to which this rule belongs. The format is `a-z{0,62}`.
* `wait` -
(Optional)
Optional. How long to wait after a rollout is finished.
* `source_phases` -
(Optional)
Optional. Proceeds only after phase name matched any one in the list. This value must consist of lower-case letters, numbers, and hyphens, start with a letter and end with a letter or a number, and have a max length of 63 characters. In other words, it must match the following regex: `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`.
- - -
* `description` -
(Optional)
Optional. Description of the `Automation`. Max length is 255 characters.
* `annotations` -
(Optional)
Optional. User annotations. These attributes can only be set and used by the user, and not by Cloud Deploy. Annotations must meet the following constraints: * Annotations are key/value pairs. * Valid annotation keys have two segments: an optional prefix and name, separated by a slash (`/`). * The name segment is required and must be 63 characters or less, beginning and ending with an alphanumeric character (`[a-z0-9A-Z]`) with dashes (`-`), underscores (`_`), dots (`.`), and alphanumerics between. * The prefix is optional. If specified, the prefix must be a DNS subdomain: a series of DNS labels separated by dots(`.`), not longer than 253 characters in total, followed by a slash (`/`). See https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/#syntax-and-character-set for more details.
**Note**: This field is non-authoritative, and will only manage the annotations present in your configuration.
Please refer to the field `effective_annotations` for all of the annotations present on the resource.
* `labels` -
(Optional)
Optional. Labels are attributes that can be set and used by both the user and by Cloud Deploy. Labels must meet the following constraints: * Keys and values can contain only lowercase letters, numeric characters, underscores, and dashes. * All characters must use UTF-8 encoding, and international characters are allowed. * Keys must start with a lowercase letter or international character. * Each resource is limited to a maximum of 64 labels. Both keys and values are additionally constrained to be <= 63 characters.
**Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
Please refer to the field `effective_labels` for all of the labels present on the resource.
* `suspended` -
(Optional)
Optional. When Suspended, automation is deactivated from execution.
* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
## Attributes Reference
In addition to the arguments listed above, the following computed attributes are exported:
* `id` - an identifier for the resource with format `projects/{{project}}/locations/{{location}}/deliveryPipelines/{{delivery_pipeline}}/automations/{{name}}`
* `uid` -
Output only. Unique identifier of the `Automation`.
* `create_time` -
Output only. Time at which the automation was created.
* `update_time` -
Output only. Time at which the automation was updated.
* `etag` -
Optional. The weak etag of the `Automation` resource. This checksum is computed by the server based on the value of other fields, and may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding.
* `effective_annotations` -
All of annotations (key/value pairs) present on the resource in GCP, including the annotations configured through Terraform, other clients and services.
* `terraform_labels` -
The combination of labels configured directly on the resource
and default labels configured on the provider.
* `effective_labels` -
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.
## Timeouts
This resource provides the following
[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options:
- `create` - Default is 20 minutes.
- `update` - Default is 20 minutes.
- `delete` - Default is 20 minutes.
## Import
Automation can be imported using any of these accepted formats:
* `projects/{{project}}/locations/{{location}}/deliveryPipelines/{{delivery_pipeline}}/automations/{{name}}`
* `{{project}}/{{location}}/{{delivery_pipeline}}/{{name}}`
* `{{location}}/{{delivery_pipeline}}/{{name}}`
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Automation using one of the formats above. For example:
```tf
import {
id = "projects/{{project}}/locations/{{location}}/deliveryPipelines/{{delivery_pipeline}}/automations/{{name}}"
to = google_clouddeploy_automation.default
}
```
When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), Automation can be imported using one of the formats above. For example:
```
$ terraform import google_clouddeploy_automation.default projects/{{project}}/locations/{{location}}/deliveryPipelines/{{delivery_pipeline}}/automations/{{name}}
$ terraform import google_clouddeploy_automation.default {{project}}/{{location}}/{{delivery_pipeline}}/{{name}}
$ terraform import google_clouddeploy_automation.default {{location}}/{{delivery_pipeline}}/{{name}}
```
## User Project Overrides
This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override).