Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6f6e7d3
add new block and rename old functions
Rose-Northey Sep 23, 2025
af02fde
ignore main.tf to be removed later
Rose-Northey Sep 23, 2025
f3d1471
fix naming typo
Rose-Northey Sep 23, 2025
27297ad
set default and take away default for with and without strategy
Rose-Northey Sep 24, 2025
ccd3f10
fixing errors
Rose-Northey Sep 24, 2025
d814c1c
FIXED! Initial retention working
Rose-Northey Sep 24, 2025
02f163d
refactor
Rose-Northey Sep 24, 2025
1defc7e
edit lifecycle retention descriptions
Rose-Northey Sep 24, 2025
c68bbdd
refactor
Rose-Northey Sep 24, 2025
f4ba2ec
lifecycle docs
Rose-Northey Sep 24, 2025
ceef8f4
only one of each retention block may be used
Rose-Northey Sep 24, 2025
6b9ef79
fixing bugs
Rose-Northey Sep 25, 2025
7853a57
fix phases bug
Rose-Northey Sep 25, 2025
a339fbe
fix tentacle bug
Rose-Northey Sep 25, 2025
4972c45
change error message
Rose-Northey Sep 25, 2025
d85d400
add descriptions
Rose-Northey Sep 25, 2025
c124fe8
refactor and move deprecated code into own files
Rose-Northey Sep 25, 2025
d706a3a
refactor and fix
Rose-Northey Sep 25, 2025
63f1212
put deprecated functions into own file
Rose-Northey Sep 26, 2025
afe387e
fixes
Rose-Northey Sep 26, 2025
6a6fd87
rename and isolate type issue
Rose-Northey Sep 26, 2025
c7fa9c4
datasource reading of both types of blocks
Rose-Northey Sep 28, 2025
9965522
wip fixing bug
Rose-Northey Sep 28, 2025
fa7e7f9
finish testing on both blocks
Rose-Northey Sep 29, 2025
c24573c
make logic more readable
Rose-Northey Sep 29, 2025
b3393fa
test for not including multiple types of retention with two types of …
Rose-Northey Sep 29, 2025
112b050
link up feature flag
Rose-Northey Sep 30, 2025
79a5def
don't allow tests for old retention block to run when disallowed
Rose-Northey Sep 30, 2025
df854d4
wip
Rose-Northey Sep 30, 2025
334b6dc
edit phase test
Rose-Northey Sep 30, 2025
1ce6886
refactor working state
Rose-Northey Sep 30, 2025
6e82f91
rename and split datasource
Rose-Northey Sep 30, 2025
c216138
add accidental removal
Rose-Northey Sep 30, 2025
ee88116
undo id item bug
Rose-Northey Sep 30, 2025
1b618f4
split blocks into deprecated and new
Rose-Northey Sep 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ terraform/**/.terraform/*
results.xml

.DS_Store

main.tf
44 changes: 44 additions & 0 deletions docs/data-sources/lifecycles.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ Read-Only:
- `name` (String) The name of the lifecycle.
- `phase` (Attributes List) (see [below for nested schema](#nestedatt--lifecycles--phase))
- `release_retention_policy` (Attributes List) (see [below for nested schema](#nestedatt--lifecycles--release_retention_policy))
- `release_retention_with_strategy` (Attributes List) (see [below for nested schema](#nestedatt--lifecycles--release_retention_with_strategy))
- `space_id` (String) The space ID associated with this lifecycle.
- `tentacle_retention_policy` (Attributes List) (see [below for nested schema](#nestedatt--lifecycles--tentacle_retention_policy))
- `tentacle_retention_with_strategy` (Attributes List) (see [below for nested schema](#nestedatt--lifecycles--tentacle_retention_with_strategy))

<a id="nestedatt--lifecycles--phase"></a>
### Nested Schema for `lifecycles.phase`
Expand All @@ -63,7 +65,9 @@ Read-Only:
- `name` (String) The name of the phase.
- `optional_deployment_targets` (List of String) The optional deployment targets for this phase.
- `release_retention_policy` (Attributes List) (see [below for nested schema](#nestedatt--lifecycles--phase--release_retention_policy))
- `release_retention_with_strategy` (Attributes List) (see [below for nested schema](#nestedatt--lifecycles--phase--release_retention_with_strategy))
- `tentacle_retention_policy` (Attributes List) (see [below for nested schema](#nestedatt--lifecycles--phase--tentacle_retention_policy))
- `tentacle_retention_with_strategy` (Attributes List) (see [below for nested schema](#nestedatt--lifecycles--phase--tentacle_retention_with_strategy))

<a id="nestedatt--lifecycles--phase--release_retention_policy"></a>
### Nested Schema for `lifecycles.phase.release_retention_policy`
Expand All @@ -75,6 +79,16 @@ Read-Only:
- `unit` (String) The unit of time for the retention policy.


<a id="nestedatt--lifecycles--phase--release_retention_with_strategy"></a>
### Nested Schema for `lifecycles.phase.release_retention_with_strategy`

Read-Only:

- `quantity_to_keep` (Number) The quantity of releases to keep.
- `strategy` (String) The retention strategy.
- `unit` (String) The unit of time for the retention policy.


<a id="nestedatt--lifecycles--phase--tentacle_retention_policy"></a>
### Nested Schema for `lifecycles.phase.tentacle_retention_policy`

Expand All @@ -85,6 +99,16 @@ Read-Only:
- `unit` (String) The unit of time for the retention policy.


<a id="nestedatt--lifecycles--phase--tentacle_retention_with_strategy"></a>
### Nested Schema for `lifecycles.phase.tentacle_retention_with_strategy`

Read-Only:

- `quantity_to_keep` (Number) The quantity of releases to keep.
- `strategy` (String) The retention strategy.
- `unit` (String) The unit of time for the retention policy.



<a id="nestedatt--lifecycles--release_retention_policy"></a>
### Nested Schema for `lifecycles.release_retention_policy`
Expand All @@ -96,6 +120,16 @@ Read-Only:
- `unit` (String) The unit of time for the retention policy.


<a id="nestedatt--lifecycles--release_retention_with_strategy"></a>
### Nested Schema for `lifecycles.release_retention_with_strategy`

Read-Only:

- `quantity_to_keep` (Number) The quantity of releases to keep.
- `strategy` (String) The retention strategy.
- `unit` (String) The unit of time for the retention policy.


<a id="nestedatt--lifecycles--tentacle_retention_policy"></a>
### Nested Schema for `lifecycles.tentacle_retention_policy`

Expand All @@ -106,3 +140,13 @@ Read-Only:
- `unit` (String) The unit of time for the retention policy.


<a id="nestedatt--lifecycles--tentacle_retention_with_strategy"></a>
### Nested Schema for `lifecycles.tentacle_retention_with_strategy`

Read-Only:

- `quantity_to_keep` (Number) The quantity of releases to keep.
- `strategy` (String) The retention strategy.
- `unit` (String) The unit of time for the retention policy.


95 changes: 91 additions & 4 deletions docs/resources/lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,23 @@ page_title: "octopusdeploy_lifecycle Resource - terraform-provider-octopusdeploy
subcategory: ""
description: |-
This resource manages lifecycles in Octopus Deploy.
Lifecycle retention is set using either the retention_policy and retention_with_strategy blocks.
- When using an octopus version prior to 2025.3
- the release_retention_policy and tentacle_retention_policy blocks are used
- when using an octopus version 2025.3 or later
- the release_retention_with_strategy and tentacle_retention_with_strategy blocks may be used
---

# octopusdeploy_lifecycle (Resource)

This resource manages lifecycles in Octopus Deploy.

Lifecycle retention is set using either the `retention_policy` and `retention_with_strategy` blocks.
- When using an octopus version prior to `2025.3`
- the `release_retention_policy` and `tentacle_retention_policy` blocks are used
- when using an octopus version `2025.3` or later
- the `release_retention_with_strategy` and `tentacle_retention_with_strategy` blocks may be used

## Example Usage

```terraform
Expand Down Expand Up @@ -64,9 +75,15 @@ resource "octopusdeploy_lifecycle" "example" {

- `description` (String) The description of this lifecycle.
- `phase` (Block List) Defines a phase in the lifecycle. (see [below for nested schema](#nestedblock--phase))
- `release_retention_policy` (Block List) Defines the retention policy for releases or tentacles. (see [below for nested schema](#nestedblock--release_retention_policy))
- `release_retention_policy` (Block List, Deprecated) Defines the retention policy for releases or tentacles. (see [below for nested schema](#nestedblock--release_retention_policy))
- `release_retention_with_strategy` (Block List) Defines the retention policy for releases or tentacles.
- When this block is not included, the space-wide "Default" retention policy is used.
- This block may only be used on Octopus server 2025.3 or later. (see [below for nested schema](#nestedblock--release_retention_with_strategy))
- `space_id` (String) The space ID associated with this resource.
- `tentacle_retention_policy` (Block List) Defines the retention policy for releases or tentacles. (see [below for nested schema](#nestedblock--tentacle_retention_policy))
- `tentacle_retention_policy` (Block List, Deprecated) Defines the retention policy for releases or tentacles. (see [below for nested schema](#nestedblock--tentacle_retention_policy))
- `tentacle_retention_with_strategy` (Block List) Defines the retention policy for releases or tentacles.
- When this block is not included, the space-wide "Default" retention policy is used.
- This block may only be used on Octopus server 2025.3 or later. (see [below for nested schema](#nestedblock--tentacle_retention_with_strategy))

### Read-Only

Expand All @@ -87,8 +104,14 @@ Optional:
- `is_priority_phase` (Boolean) Deployments will be prioritized in this phase
- `minimum_environments_before_promotion` (Number) The number of units required before a release can enter the next phase. If 0, all environments are required.
- `optional_deployment_targets` (List of String) Environment IDs in this phase that a release can be deployed to, but is not automatically deployed to
- `release_retention_policy` (Block List) Defines the retention policy for releases or tentacles. (see [below for nested schema](#nestedblock--phase--release_retention_policy))
- `tentacle_retention_policy` (Block List) Defines the retention policy for releases or tentacles. (see [below for nested schema](#nestedblock--phase--tentacle_retention_policy))
- `release_retention_policy` (Block List, Deprecated) Defines the retention policy for releases or tentacles. (see [below for nested schema](#nestedblock--phase--release_retention_policy))
- `release_retention_with_strategy` (Block List) Defines the retention policy for releases or tentacles.
- When this block is not included, the space-wide "Default" retention policy is used.
- This block may only be used on Octopus server 2025.3 or later. (see [below for nested schema](#nestedblock--phase--release_retention_with_strategy))
- `tentacle_retention_policy` (Block List, Deprecated) Defines the retention policy for releases or tentacles. (see [below for nested schema](#nestedblock--phase--tentacle_retention_policy))
- `tentacle_retention_with_strategy` (Block List) Defines the retention policy for releases or tentacles.
- When this block is not included, the space-wide "Default" retention policy is used.
- This block may only be used on Octopus server 2025.3 or later. (see [below for nested schema](#nestedblock--phase--tentacle_retention_with_strategy))

<a id="nestedblock--phase--release_retention_policy"></a>
### Nested Schema for `phase.release_retention_policy`
Expand All @@ -100,6 +123,22 @@ Optional:
- `unit` (String) The unit of quantity to keep. Valid units are Days or Items. The default value is Days.


<a id="nestedblock--phase--release_retention_with_strategy"></a>
### Nested Schema for `phase.release_retention_with_strategy`

Required:

- `strategy` (String) How retention will be set. Valid strategies are `Default`, `Forever`, and `Count`. The default value is `Default`.
- `strategy = "Default"`, is used if the retention is set by the space-wide default lifecycle retention policy. When `Default` is used, no other attributes can be set since the specific retention policy is no longer defined within this lifecycle.
- `strategy = "Forever"`, is used if items within this lifecycle should never be deleted.
- `strategy = "Count"`, is used if a specific number of days/releases should be kept.

Optional:

- `quantity_to_keep` (Number) The number of days/releases to keep. The default value is 30. If 0 then all are kept.
- `unit` (String) The unit of quantity to keep. Valid units are Days or Items. The default value is Days.


<a id="nestedblock--phase--tentacle_retention_policy"></a>
### Nested Schema for `phase.tentacle_retention_policy`

Expand All @@ -110,6 +149,22 @@ Optional:
- `unit` (String) The unit of quantity to keep. Valid units are Days or Items. The default value is Days.


<a id="nestedblock--phase--tentacle_retention_with_strategy"></a>
### Nested Schema for `phase.tentacle_retention_with_strategy`

Required:

- `strategy` (String) How retention will be set. Valid strategies are `Default`, `Forever`, and `Count`. The default value is `Default`.
- `strategy = "Default"`, is used if the retention is set by the space-wide default lifecycle retention policy. When `Default` is used, no other attributes can be set since the specific retention policy is no longer defined within this lifecycle.
- `strategy = "Forever"`, is used if items within this lifecycle should never be deleted.
- `strategy = "Count"`, is used if a specific number of days/releases should be kept.

Optional:

- `quantity_to_keep` (Number) The number of days/releases to keep. The default value is 30. If 0 then all are kept.
- `unit` (String) The unit of quantity to keep. Valid units are Days or Items. The default value is Days.



<a id="nestedblock--release_retention_policy"></a>
### Nested Schema for `release_retention_policy`
Expand All @@ -121,6 +176,22 @@ Optional:
- `unit` (String) The unit of quantity to keep. Valid units are Days or Items. The default value is Days.


<a id="nestedblock--release_retention_with_strategy"></a>
### Nested Schema for `release_retention_with_strategy`

Required:

- `strategy` (String) How retention will be set. Valid strategies are `Default`, `Forever`, and `Count`. The default value is `Default`.
- `strategy = "Default"`, is used if the retention is set by the space-wide default lifecycle retention policy. When `Default` is used, no other attributes can be set since the specific retention policy is no longer defined within this lifecycle.
- `strategy = "Forever"`, is used if items within this lifecycle should never be deleted.
- `strategy = "Count"`, is used if a specific number of days/releases should be kept.

Optional:

- `quantity_to_keep` (Number) The number of days/releases to keep. The default value is 30. If 0 then all are kept.
- `unit` (String) The unit of quantity to keep. Valid units are Days or Items. The default value is Days.


<a id="nestedblock--tentacle_retention_policy"></a>
### Nested Schema for `tentacle_retention_policy`

Expand All @@ -130,6 +201,22 @@ Optional:
- `should_keep_forever` (Boolean) Indicates if items should never be deleted. The default value is false.
- `unit` (String) The unit of quantity to keep. Valid units are Days or Items. The default value is Days.


<a id="nestedblock--tentacle_retention_with_strategy"></a>
### Nested Schema for `tentacle_retention_with_strategy`

Required:

- `strategy` (String) How retention will be set. Valid strategies are `Default`, `Forever`, and `Count`. The default value is `Default`.
- `strategy = "Default"`, is used if the retention is set by the space-wide default lifecycle retention policy. When `Default` is used, no other attributes can be set since the specific retention policy is no longer defined within this lifecycle.
- `strategy = "Forever"`, is used if items within this lifecycle should never be deleted.
- `strategy = "Count"`, is used if a specific number of days/releases should be kept.

Optional:

- `quantity_to_keep` (Number) The number of days/releases to keep. The default value is 30. If 0 then all are kept.
- `unit` (String) The unit of quantity to keep. Valid units are Days or Items. The default value is Days.

## Import

Import is supported using the following syntax:
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,4 @@ require (
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

Loading
Loading