Skip to content

Commit

Permalink
Merge pull request #14 from mineiros-io/soerenmartius/timeouts
Browse files Browse the repository at this point in the history
Refactor timeouts
  • Loading branch information
soerenmartius authored Mar 13, 2022
2 parents cf8200d + 9e5bf26 commit be5125c
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 171 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.5]

### Changed

- BREAKING: Refactored `group_timeouts` and `membership_timeouts` to `module_timeouts`

## Fixed

- Correct docs for memberships
Expand Down Expand Up @@ -45,7 +51,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Initial Implementation

[unreleased]: https://github.com/mineiros-io/terraform-google-identity-group/compare/v0.0.4...HEAD
[unreleased]: https://github.com/mineiros-io/terraform-google-identity-group/compare/v0.0.5...HEAD
[0.0.5]: https://github3com/mineiros-io/terraform-google-identity-group/compare/v0.0.4...v0.0.5
[0.0.4]: https://github.com/mineiros-io/terraform-google-identity-group/compare/v0.0.3...v0.0.4
[0.0.3]: https://github.com/mineiros-io/terraform-google-identity-group/compare/v0.0.2...v0.0.3
[0.0.2]: https://github.com/mineiros-io/terraform-google-identity-group/compare/v0.0.1...v0.0.2
Expand Down
97 changes: 32 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,42 +102,6 @@ See [variables.tf] and [examples/] for details and use-cases.

The namespace in which the entity exists. If not specified, the EntityKey represents a Google-managed entity such as a Google user or a Google Group. If specified, the EntityKey represents an external-identity-mapped group. The namespace must correspond to an identity source created in Admin Console and must be in the form of `identitysources/{identity_source_id}`.

- [**`group_timeouts`**](#var-group_timeouts): *(Optional `object(group_timeout)`)*<a name="var-group_timeouts"></a>

How long certain operations are allowed to take before being considered to have failed.

Default is `{}`.

Example:

```hcl
group_timeouts = {
create = "4m"
update = "4m"
delete = "4m"
}
```

The `group_timeout` object accepts the following attributes:

- [**`create`**](#attr-group_timeouts-create): *(Optional `string`)*<a name="attr-group_timeouts-create"></a>

Timeout for create operations.

Default is `"6m"`.

- [**`update`**](#attr-group_timeouts-update): *(Optional `string`)*<a name="attr-group_timeouts-update"></a>

Timeout for update operations.

Default is `"4m"`.

- [**`delete`**](#attr-group_timeouts-delete): *(Optional `string`)*<a name="attr-group_timeouts-delete"></a>

Timeout for delete operations.

Default is `"4m"`.

- [**`memberships`**](#var-memberships): *(Optional `list(membership)`)*<a name="var-memberships"></a>

A list of memberships (id, roles) to get attached to the group resource created.
Expand All @@ -157,49 +121,52 @@ See [variables.tf] and [examples/] for details and use-cases.
roles = ["MEMBER", "MANAGER"]
```
- [**`membership_timeouts`**](#attr-memberships-membership_timeouts): *(Optional `object(group_timeout)`)*<a name="attr-memberships-membership_timeouts"></a>
How long certain operations are allowed to take before being considered to have failed.
Default is `{}`.
Example:
```hcl
group_timeouts = {
create = "4m"
update = "4m"
delete = "4m"
}
```
### Module Configuration
The `group_timeout` object accepts the following attributes:
- [**`module_enabled`**](#var-module_enabled): *(Optional `bool`)*<a name="var-module_enabled"></a>
- [**`create`**](#attr-memberships-membership_timeouts-create): *(Optional `string`)*<a name="attr-memberships-membership_timeouts-create"></a>
Specifies whether resources in the module will be created.
Timeout for create operations.
Default is `true`.
Default is `"4m"`.
- [**`module_timeouts`**](#var-module_timeouts): *(Optional `map(timeout)`)*<a name="var-module_timeouts"></a>
- [**`update`**](#attr-memberships-membership_timeouts-update): *(Optional `string`)*<a name="attr-memberships-membership_timeouts-update"></a>
A map of timeout objects that is keyed by Terraform resource name
defining timeouts for `create`, `update` and `delete` Terraform operations.
Supported resources are:
- `google_cloud_identity_group`
- `google_cloud_identity_group_membership`
Timeout for update operations.
Example:
Default is `"4m"`.
```hcl
module_timeouts = {
google_cloud_identity_group = {
create = "4m"
update = "4m"
delete = "4m"
}
google_cloud_identity_group_membership = {
create = "4m"
update = "4m"
delete = "4m"
}
}
```

- [**`delete`**](#attr-memberships-membership_timeouts-delete): *(Optional `string`)*<a name="attr-memberships-membership_timeouts-delete"></a>
Each `timeout` object in the map accepts the following attributes:

Timeout for delete operations.
- [**`create`**](#attr-module_timeouts-create): *(Optional `string`)*<a name="attr-module_timeouts-create"></a>

Default is `"4m"`.
Timeout for create operations.

### Module Configuration
- [**`update`**](#attr-module_timeouts-update): *(Optional `string`)*<a name="attr-module_timeouts-update"></a>

- [**`module_enabled`**](#var-module_enabled): *(Optional `bool`)*<a name="var-module_enabled"></a>
Timeout for update operations.

Specifies whether resources in the module will be created.
- [**`delete`**](#attr-module_timeouts-delete): *(Optional `string`)*<a name="attr-module_timeouts-delete"></a>

Default is `true`.
Timeout for delete operations.

- [**`module_depends_on`**](#var-module_depends_on): *(Optional `list(dependency)`)*<a name="var-module_depends_on"></a>

Expand Down
126 changes: 46 additions & 80 deletions README.tfdoc.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -144,46 +144,6 @@ section {
END
}

variable "group_timeouts" {
type = object(group_timeout)
default = {}
description = <<-END
How long certain operations are allowed to take before being considered to have failed.
END

readme_example = <<-END
group_timeouts = {
create = "4m"
update = "4m"
delete = "4m"
}
END

attribute "create" {
type = string
default = "6m"
description = <<-END
Timeout for create operations.
END
}

attribute "update" {
type = string
default = "4m"
description = <<-END
Timeout for update operations.
END
}

attribute "delete" {
type = string
default = "4m"
description = <<-END
Timeout for delete operations.
END
}
}

variable "memberships" {
type = list(membership)
description = <<-END
Expand All @@ -203,46 +163,6 @@ section {
roles = ["MEMBER", "MANAGER"]
END
}

attribute "membership_timeouts" {
type = object(group_timeout)
default = {}
description = <<-END
How long certain operations are allowed to take before being considered to have failed.
END

readme_example = <<-END
group_timeouts = {
create = "4m"
update = "4m"
delete = "4m"
}
END

attribute "create" {
type = string
default = "4m"
description = <<-END
Timeout for create operations.
END
}

attribute "update" {
type = string
default = "4m"
description = <<-END
Timeout for update operations.
END
}

attribute "delete" {
type = string
default = "4m"
description = <<-END
Timeout for delete operations.
END
}
}
}
}

Expand All @@ -257,6 +177,52 @@ section {
END
}

variable "module_timeouts" {
type = map(timeout)
description = <<-END
A map of timeout objects that is keyed by Terraform resource name
defining timeouts for `create`, `update` and `delete` Terraform operations.
Supported resources are:
- `google_cloud_identity_group`
- `google_cloud_identity_group_membership`
END
readme_example = <<-END
module_timeouts = {
google_cloud_identity_group = {
create = "4m"
update = "4m"
delete = "4m"
}
google_cloud_identity_group_membership = {
create = "4m"
update = "4m"
delete = "4m"
}
}
END

attribute "create" {
type = string
description = <<-END
Timeout for create operations.
END
}

attribute "update" {
type = string
description = <<-END
Timeout for update operations.
END
}

attribute "delete" {
type = string
description = <<-END
Timeout for delete operations.
END
}
}

variable "module_depends_on" {
type = list(dependency)
description = <<-END
Expand Down
12 changes: 6 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ resource "google_cloud_identity_group" "group" {
}

timeouts {
create = try(var.group_timeouts.create, "6m")
update = try(var.group_timeouts.update, "4m")
delete = try(var.group_timeouts.delete, "4m")
create = try(var.module_timeouts.google_cloud_identity_group.create, "6m")
update = try(var.module_timeouts.google_cloud_identity_group.update, "4m")
delete = try(var.module_timeouts.google_cloud_identity_group.delete, "4m")
}
}

Expand All @@ -52,8 +52,8 @@ resource "google_cloud_identity_group_membership" "membership" {
}

timeouts {
create = try(var.membership_timeouts.create, "4m")
update = try(var.membership_timeouts.update, "4m")
delete = try(var.membership_timeouts.delete, "4m")
create = try(var.module_timeouts.google_cloud_identity_group_membership.create, "4m")
update = try(var.module_timeouts.google_cloud_identity_group_membership.update, "4m")
delete = try(var.module_timeouts.google_cloud_identity_group_membership.delete, "4m")
}
}
19 changes: 12 additions & 7 deletions test/unit-complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,18 @@ module "test" {
]

# add most/all other optional arguments
# module_timeouts = {
# group_timeouts = {
# create = "10m"
# update = "10m"
# delete = "10m"
# }
# }
module_timeouts = {
google_cloud_identity_group = {
create = "10m"
update = "11m"
delete = "12m"
}
google_cloud_identity_group_membership = {
create = "13m"
update = "14m"
delete = "15m"
}
}

module_depends_on = ["nothing"]
}
Expand Down
18 changes: 6 additions & 12 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ variable "group_key_namespace" {
default = null
}

variable "group_timeouts" {
description = "(Optional) How long certain operations are allowed to take before being considered to have failed."
type = any
default = {}
}

variable "memberships" {
description = "(Optional) A list of memberships (id, roles) to get attached to the group resource created."
type = any
Expand All @@ -70,12 +64,6 @@ variable "memberships" {
}
}

variable "membership_timeouts" {
description = "(Optional) How long certain operations are allowed to take before being considered to have failed."
type = any
default = {}
}

# ---------------------------------------------------------------------------------------------------------------------
# MODULE CONFIGURATION PARAMETERS
# These variables are used to configure the module.
Expand All @@ -87,6 +75,12 @@ variable "module_enabled" {
default = true
}

variable "module_timeouts" {
description = "(Optional) A map of timeout objects that is keyed by Terraform resource name defining timeouts for `create`, `update` and `delete` Terraform operations."
type = any
default = null
}

variable "module_depends_on" {
type = any
description = "(Optional) A list of external resources the module depends_on. Default is '[]'."
Expand Down

0 comments on commit be5125c

Please sign in to comment.