Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dataproc module bug fix #1848

Merged
merged 4 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 5 additions & 21 deletions blueprints/factories/project-factory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ In addition to the yaml files describing projects, the project factory accepts t

Some examples on where to use each of the three sets are provided below.

## Overriding project id

By default, the project id is derived from the file path relative to the data root. Path slashes are replaced with dashes to allow for multilevel data folders (e.g. `app01/fe.yaml`, `app02/fe.yaml`, etc.). The project id can be overridden by specifying a custom `name` attribute in the yaml file. Refer to the example below for details.

## Example

```hcl
Expand Down Expand Up @@ -61,7 +57,7 @@ module "project-factory" {
# location where the yaml files are read from
factory_data_path = "data"
}
# tftest modules=8 resources=32 files=app01,app02-be,app03-be,app03-fe inventory=example.yaml
# tftest modules=7 resources=26 files=prj-app-1,prj-app-2,prj-app-3 inventory=example.yaml
```

```yaml
Expand All @@ -84,12 +80,12 @@ service_accounts:
app-1-fe:
display_name: "Test app 1 frontend."

# tftest-file id=app01 path=data/app01.yaml
# tftest-file id=prj-app-1 path=data/prj-app-1.yaml
```

```yaml
labels:
app: app02
app: app-2
team: foo
parent: folders/12345678
service_accounts:
Expand All @@ -101,29 +97,17 @@ services:
shared_vpc_service_config:
host_project: foo-host

# tftest-file id=app02-be path=data/app02/be.yaml
# tftest-file id=prj-app-2 path=data/prj-app-2.yaml
```

```yaml
name: app03-be-0
parent: folders/12345678
services:
- run.googleapis.com
- storage.googleapis.com

# tftest-file id=app03-be path=data/app03/be.yaml
# tftest-file id=prj-app-3 path=data/prj-app-3.yaml
```

```yaml
name: app03-fe-0
parent: folders/12345678
services:
- run.googleapis.com
- storage.googleapis.com

# tftest-file id=app03-fe path=data/app03/fe.yaml
```

<!-- BEGIN TFDOC -->
## Variables

Expand Down
1 change: 0 additions & 1 deletion blueprints/factories/project-factory/factory.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ locals {
try(v.metric_scopes, null),
var.data_defaults.metric_scopes
)
name = try(v.name, replace(k, "/", "-"))
org_policies = try(v.org_policies, {})
parent = coalesce(
var.data_overrides.parent,
Expand Down
2 changes: 1 addition & 1 deletion blueprints/factories/project-factory/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module "projects" {
source = "../../../modules/project"
for_each = local.projects
billing_account = each.value.billing_account
name = each.value.name
name = each.key
parent = try(each.value.parent, null)
prefix = each.value.prefix
auto_create_network = try(each.value.auto_create_network, false)
Expand Down
2 changes: 1 addition & 1 deletion modules/dataproc/README.md

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions modules/dataproc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ resource "google_dataproc_cluster" "cluster" {
dynamic "accelerators" {
for_each = var.dataproc_config.cluster_config.worker_config.accelerators == null ? [] : [""]
content {
accelerator_type = var.dataproc_config.cluster_config.accelerators.accelerator_type
accelerator_count = var.dataproc_config.cluster_config.accelerators.accelerator_count
accelerator_type = var.dataproc_config.cluster_config.worker_config.accelerators.accelerator_type
accelerator_count = var.dataproc_config.cluster_config.worker_config.accelerators.accelerator_count
}
}
}
Expand Down Expand Up @@ -185,10 +185,10 @@ resource "google_dataproc_cluster" "cluster" {
for_each = var.dataproc_config.cluster_config.dataproc_metric_config == null ? [] : [""]
content {
dynamic "metrics" {
for_each = var.dataproc_config.cluster_config.dataproc_metric_config.metrics == null ? [] : [""]
for_each = coalesce(var.dataproc_config.cluster_config.dataproc_metric_config.metrics, [])
content {
metric_source = var.dataproc_config.cluster_config.dataproc_metric_config.metrics.metric_source
metric_overrides = var.dataproc_config.cluster_config.dataproc_metric_config.metrics.metric_overrides
metric_source = metrics.value.metric_source
metric_overrides = metrics.value.metric_overrides
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/dataproc/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ variable "dataproc_config" {
dataproc_metric_config = optional(object({
metrics = list(object({
metric_source = string
metric_overrides = optional(string)
metric_overrides = optional(list(string))
}))
}))
metastore_config = optional(object({
Expand Down
Loading