Skip to content

Commit fb37486

Browse files
committed
Removed service account usage in simple-workflow module
1 parent aecc2c0 commit fb37486

File tree

17 files changed

+50
-201
lines changed

17 files changed

+50
-201
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ docker_generate_docs:
8080
-e ENABLE_BPMETADATA=1 \
8181
-v "$(CURDIR)":/workspace \
8282
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
83-
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs display'
83+
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs display --per-module-requirements'
8484

8585
# Alias for backwards compatibility
8686
.PHONY: generate_docs

examples/simple_workflow/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
| Name | Description |
1111
|------|-------------|
12+
| project\_id | Google Cloud project in which the workflow is deployed |
13+
| revision\_id | The revision\_id of the workflow. |
1214
| workflow\_id | The id of the workflow. |
13-
| workflow\_region | The id of the workflow. |
14-
| workflow\_revision\_id | The revision\_id of the workflow. |
1515

1616
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/simple_workflow/main.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ module "standalone_workflow" {
2828

2929
project_id = var.project_id
3030
workflow_name = "standalone-workflow"
31-
region = "us-central1"
31+
location = "us-central1"
3232
service_account_email = module.service_account.email
33-
service_account_create = true
3433
workflow_source = <<-EOF
3534
# This is a sample workflow that simply reads wikipedia
3635
# Note that $$ is needed for Terraform

examples/simple_workflow/outputs.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ output "workflow_id" {
1919
value = module.standalone_workflow.workflow_id
2020
}
2121

22-
output "workflow_region" {
23-
description = "The id of the workflow."
24-
value = module.standalone_workflow.workflow_region
22+
output "revision_id" {
23+
description = "The revision_id of the workflow."
24+
value = module.standalone_workflow.revision_id
2525
}
2626

27-
output "workflow_revision_id" {
28-
description = "The revision_id of the workflow."
29-
value = module.standalone_workflow.workflow_revision_id
27+
output "project_id" {
28+
description = "Google Cloud project in which the workflow is deployed"
29+
value = var.project_id
3030
}

modules/simple_workflow/README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,10 @@ Functional examples are included in the
4646

4747
| Name | Description | Type | Default | Required |
4848
|------|-------------|------|---------|:--------:|
49+
| location | The name of the location where workflow will be created | `string` | n/a | yes |
4950
| project\_id | The project ID to deploy to | `string` | n/a | yes |
50-
| region | The name of the region where workflow will be created | `string` | n/a | yes |
51-
| service\_account\_create | Auto-create service account. | `bool` | `false` | no |
52-
| service\_account\_email | Service account email. Unused if service account is auto-created. | `string` | `null` | no |
53-
| workflow\_description | Description for the cloud workflow | `string` | `"Sample workflow Description"` | no |
51+
| service\_account\_email | Service account email. | `string` | `null` | no |
52+
| workflow\_description | Description for the cloud workflow | `string` | `""` | no |
5453
| workflow\_labels | A set of key/value label pairs to assign to the workflow | `map(string)` | `{}` | no |
5554
| workflow\_name | The name of the cloud workflow to create | `string` | n/a | yes |
5655
| workflow\_source | Workflow YAML code to be executed. The size limit is 32KB. | `string` | n/a | yes |
@@ -59,9 +58,8 @@ Functional examples are included in the
5958

6059
| Name | Description |
6160
|------|-------------|
61+
| revision\_id | The revision of the workflow. A new one is generated if the service account or source contents is changed. |
6262
| workflow\_id | Workflow identifier for the resource with format projects/{{project}}/locations/{{region}}/workflows/{{name}} |
63-
| workflow\_region | The region of the workflow. |
64-
| workflow\_revision\_id | The revision of the workflow. A new one is generated if the service account or source contents is changed. |
6563

6664
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
6765

modules/simple_workflow/main.tf

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,42 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17-
locals {
18-
service_account_email = (
19-
var.service_account_create
20-
? (
21-
length(module.service_account) > 0
22-
? module.service_account[0].email
23-
: null
24-
)
25-
: var.service_account_email
26-
)
27-
}
28-
29-
resource "random_string" "string" {
30-
count = var.service_account_create ? 1 : 0
31-
length = 6
32-
lower = true
33-
upper = false
34-
special = false
35-
numeric = false
36-
}
37-
38-
module "service_account" {
39-
count = var.service_account_create ? 1 : 0
40-
source = "terraform-google-modules/service-accounts/google"
41-
version = "~> 4.1.1"
42-
project_id = var.project_id
43-
prefix = "wf-${random_string.string[0].result}"
44-
names = ["simple"]
45-
project_roles = ["${var.project_id}=>roles/workflows.invoker"]
46-
}
47-
4817
resource "google_workflows_workflow" "simple_workflow" {
4918
name = var.workflow_name
50-
region = var.region
19+
region = var.location
5120
description = var.workflow_description
52-
service_account = local.service_account_email
21+
service_account = var.service_account_email
5322
project = var.project_id
5423
labels = var.workflow_labels
5524
source_contents = var.workflow_source

modules/simple_workflow/metadata.display.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,29 @@ spec:
2424
source:
2525
repo: https://github.com/GoogleCloudPlatform/terraform-google-cloud-workflows.git
2626
sourceType: git
27-
dir: /modules/simple-workflow
27+
dir: /modules/simple_workflow
2828
ui:
2929
input:
3030
variables:
31+
location:
32+
name: location
33+
title: Location
3134
project_id:
3235
name: project_id
3336
title: Project Id
3437
region:
3538
name: region
3639
title: Region
37-
service_account_create:
38-
name: service_account_create
39-
title: Service Account Create
4040
service_account_email:
4141
name: service_account_email
4242
title: Service Account Email
43-
regexValidation: "^[a-z][a-z0-9-]{4,28}[a-z0-9]@[a-z][a-z0-9-]{4,28}[a-z0-9]\\.iam\\.gserviceaccount\\.com$"
43+
regexValidation: ^[a-z][a-z0-9-]{4,28}[a-z0-9]@[a-z][a-z0-9-]{4,28}[a-z0-9]\.iam\.gserviceaccount\.com$
4444
validation: "Service account must be a valid email address in the format: SA_NAME@PROJECT_ID.iam.gserviceaccount.com."
45+
level: 1
4546
workflow_description:
4647
name: workflow_description
4748
title: Workflow Description
49+
level: 1
4850
workflow_labels:
4951
name: workflow_labels
5052
title: Workflow Labels

modules/simple_workflow/metadata.yaml

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ spec:
2424
source:
2525
repo: https://github.com/GoogleCloudPlatform/terraform-google-cloud-workflows.git
2626
sourceType: git
27-
dir: /modules/simple-workflow
27+
dir: /modules/simple_workflow
2828
version: 0.1.0
2929
actuationTool:
3030
flavor: Terraform
@@ -57,9 +57,9 @@ spec:
5757
- name: workflow_description
5858
description: Description for the cloud workflow
5959
varType: string
60-
defaultValue: Sample workflow Description
61-
- name: region
62-
description: The name of the region where workflow will be created
60+
defaultValue: ""
61+
- name: location
62+
description: The name of the location where workflow will be created
6363
varType: string
6464
required: true
6565
- name: workflow_source
@@ -71,33 +71,25 @@ spec:
7171
varType: map(string)
7272
defaultValue: {}
7373
- name: service_account_email
74-
description: Service account email. Unused if service account is auto-created.
74+
description: Service account email.
7575
varType: string
7676
connections:
7777
- source:
7878
source: github.com/terraform-google-modules/terraform-google-service-accounts//modules/simple-sa
7979
version: ">= 4.4"
8080
spec:
8181
outputExpr: email
82-
- name: service_account_create
83-
description: Auto-create service account.
84-
varType: bool
85-
defaultValue: false
8682
outputs:
83+
- name: revision_id
84+
description: The revision of the workflow. A new one is generated if the service account or source contents is changed.
8785
- name: workflow_id
8886
description: Workflow identifier for the resource with format projects/{{project}}/locations/{{region}}/workflows/{{name}}
8987
type: string
90-
- name: workflow_region
91-
description: The region of the workflow.
92-
type: string
93-
- name: workflow_revision_id
94-
description: The revision of the workflow. A new one is generated if the service account or source contents is changed.
95-
type: string
9688
requirements:
9789
roles:
9890
- level: Project
9991
roles:
100-
- roles/owner
92+
- roles/workflows.invoker
10193
services:
10294
- iam.googleapis.com
10395
- cloudresourcemanager.googleapis.com
@@ -109,5 +101,3 @@ spec:
109101
providerVersions:
110102
- source: hashicorp/google
111103
version: ">= 3.53, < 5.0"
112-
- source: hashicorp/random
113-
version: ~> 3.4.3

modules/simple_workflow/outputs.tf

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@ output "workflow_id" {
1919
description = "Workflow identifier for the resource with format projects/{{project}}/locations/{{region}}/workflows/{{name}}"
2020
}
2121

22-
output "workflow_revision_id" {
22+
output "revision_id" {
2323
value = google_workflows_workflow.simple_workflow.revision_id
2424
description = "The revision of the workflow. A new one is generated if the service account or source contents is changed."
2525
}
26-
27-
output "workflow_region" {
28-
value = google_workflows_workflow.simple_workflow.region
29-
description = "The region of the workflow."
30-
}

modules/simple_workflow/variables.tf

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ variable "workflow_name" {
2727
variable "workflow_description" {
2828
description = "Description for the cloud workflow"
2929
type = string
30-
default = "Sample workflow Description"
30+
default = ""
3131
}
3232

33-
variable "region" {
34-
description = "The name of the region where workflow will be created"
33+
variable "location" {
34+
description = "The name of the location where workflow will be created"
3535
type = string
3636
}
3737

@@ -47,13 +47,7 @@ variable "workflow_labels" {
4747
}
4848

4949
variable "service_account_email" {
50-
description = "Service account email. Unused if service account is auto-created."
50+
description = "Service account email."
5151
type = string
5252
default = null
5353
}
54-
55-
variable "service_account_create" {
56-
description = "Auto-create service account."
57-
type = bool
58-
default = false
59-
}

0 commit comments

Comments
 (0)