Skip to content

Commit

Permalink
Handle service account name in control
Browse files Browse the repository at this point in the history
The ambiguity of what google_container_cluster expects as a value for
service_account is not worth addressing in this module.
  • Loading branch information
aaron-lane committed Apr 5, 2019
1 parent cad247c commit 177991a
Show file tree
Hide file tree
Showing 28 changed files with 40 additions and 72 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| region | The region to host the cluster in (required) | string | n/a | yes |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | string | `"true"` | no |
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | string | `"false"` | no |
| service\_account | The name of the service account to run nodes as if not overridden in `node_pools`. The default value will cause a cluster-specific service account to be created. | string | `"create"` | no |
| service\_account | The service account to run nodes as if not overridden in `node_pools`. The default value will cause a cluster-specific service account to be created. | string | `"create"` | no |
| stub\_domains | Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server | map | `<map>` | no |
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
| zones | The zones to host the cluster in (optional if regional cluster / required if zonal) | list | `<list>` | no |
Expand All @@ -160,8 +160,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| node\_pools\_names | List of node pools names |
| node\_pools\_versions | List of node pools versions |
| region | Cluster region |
| service\_account | The email address of the service account to default running nodes as if not overridden in `node_pools`. |
| service\_account\_name | The name of the service account to default running nodes as if not overridden in `node_pools`. |
| service\_account | The service account to default running nodes as if not overridden in `node_pools`. |
| type | Cluster type (regional / zonal) |
| zones | List of zones in which the cluster resides |

Expand Down
7 changes: 1 addition & 6 deletions autogen/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ output "node_pools_versions" {
}

output "service_account" {
description = "The email address of the service account to default running nodes as if not overridden in `node_pools`."
description = "The service account to default running nodes as if not overridden in `node_pools`."
value = "${local.service_account}"
}

output "service_account_name" {
description = "The name of the service account to default running nodes as if not overridden in `node_pools`."
value = "projects/${var.project_id}/serviceAccounts/${local.service_account}"
}
2 changes: 1 addition & 1 deletion autogen/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ variable "monitoring_service" {
}

variable "service_account" {
description = "The name of the service account to run nodes as if not overridden in `node_pools`. The default value will cause a cluster-specific service account to be created."
description = "The service account to run nodes as if not overridden in `node_pools`. The default value will cause a cluster-specific service account to be created."
default = "create"
}
{% if private_cluster %}
Expand Down
2 changes: 1 addition & 1 deletion examples/deploy_service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ It will:
| network | |
| project\_id | |
| region | |
| service\_account | The email address of the service account to default running nodes as if not overridden in `node_pools`. |
| service\_account | The service account to default running nodes as if not overridden in `node_pools`. |
| subnetwork | |
| zones | List of zones in which the cluster resides |

Expand Down
2 changes: 1 addition & 1 deletion examples/deploy_service/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ output "ca_certificate" {
}

output "service_account" {
description = "The email address of the service account to default running nodes as if not overridden in `node_pools`."
description = "The service account to default running nodes as if not overridden in `node_pools`."
value = "${module.gke.service_account}"
}
2 changes: 1 addition & 1 deletion examples/node_pool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ This example illustrates how to create a cluster with multiple custom node-pool
| network | |
| project\_id | |
| region | |
| service\_account | The email address of the service account to default running nodes as if not overridden in `node_pools`. |
| service\_account | The service account to default running nodes as if not overridden in `node_pools`. |
| subnetwork | |
| zones | List of zones in which the cluster resides |

Expand Down
2 changes: 1 addition & 1 deletion examples/node_pool/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ output "ca_certificate" {
}

output "service_account" {
description = "The email address of the service account to default running nodes as if not overridden in `node_pools`."
description = "The service account to default running nodes as if not overridden in `node_pools`."
value = "${module.gke.service_account}"
}
2 changes: 1 addition & 1 deletion examples/shared_vpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ This example illustrates how to create a simple cluster where the host network i
| network | |
| project\_id | |
| region | |
| service\_account | The email address of the service account to default running nodes as if not overridden in `node_pools`. |
| service\_account | The service account to default running nodes as if not overridden in `node_pools`. |
| subnetwork | |
| zones | List of zones in which the cluster resides |

Expand Down
2 changes: 1 addition & 1 deletion examples/shared_vpc/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ output "ca_certificate" {
}

output "service_account" {
description = "The email address of the service account to default running nodes as if not overridden in `node_pools`."
description = "The service account to default running nodes as if not overridden in `node_pools`."
value = "${module.gke.service_account}"
}
2 changes: 1 addition & 1 deletion examples/simple_regional/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This example illustrates how to create a simple cluster.
| network | |
| project\_id | |
| region | |
| service\_account | The email address of the service account to default running nodes as if not overridden in `node_pools`. |
| service\_account | The service account to default running nodes as if not overridden in `node_pools`. |
| subnetwork | |
| zones | List of zones in which the cluster resides |

Expand Down
2 changes: 1 addition & 1 deletion examples/simple_regional/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ output "ca_certificate" {
}

output "service_account" {
description = "The email address of the service account to default running nodes as if not overridden in `node_pools`."
description = "The service account to default running nodes as if not overridden in `node_pools`."
value = "${module.gke.service_account}"
}
2 changes: 1 addition & 1 deletion examples/simple_regional_private/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This example illustrates how to create a simple private cluster.
| network | |
| project\_id | |
| region | |
| service\_account | The email address of the service account to default running nodes as if not overridden in `node_pools`. |
| service\_account | The service account to default running nodes as if not overridden in `node_pools`. |
| subnetwork | |
| zones | List of zones in which the cluster resides |

Expand Down
2 changes: 1 addition & 1 deletion examples/simple_regional_private/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ output "ca_certificate" {
}

output "service_account" {
description = "The email address of the service account to default running nodes as if not overridden in `node_pools`."
description = "The service account to default running nodes as if not overridden in `node_pools`."
value = "${module.gke.service_account}"
}
2 changes: 1 addition & 1 deletion examples/simple_zonal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This example illustrates how to create a simple cluster.
| network | |
| project\_id | |
| region | |
| service\_account | The email address of the service account to default running nodes as if not overridden in `node_pools`. |
| service\_account | The service account to default running nodes as if not overridden in `node_pools`. |
| service\_account\_name | The name of the service account to default running nodes as if not overridden in `node_pools`. |
| subnetwork | |
| zones | List of zones in which the cluster resides |
Expand Down
7 changes: 1 addition & 6 deletions examples/simple_zonal/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ output "ca_certificate" {
}

output "service_account" {
description = "The email address of the service account to default running nodes as if not overridden in `node_pools`."
description = "The service account to default running nodes as if not overridden in `node_pools`."
value = "${module.gke.service_account}"
}

output "service_account_name" {
description = "The name of the service account to default running nodes as if not overridden in `node_pools`."
value = "${module.gke.service_account_name}"
}
2 changes: 1 addition & 1 deletion examples/simple_zonal_private/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ This example illustrates how to create a simple private cluster.
| network | |
| project\_id | |
| region | |
| service\_account | The email address of the service account to default running nodes as if not overridden in `node_pools`. |
| service\_account | The service account to default running nodes as if not overridden in `node_pools`. |
| subnetwork | |
| zones | List of zones in which the cluster resides |

Expand Down
2 changes: 1 addition & 1 deletion examples/simple_zonal_private/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ output "ca_certificate" {
}

output "service_account" {
description = "The email address of the service account to default running nodes as if not overridden in `node_pools`."
description = "The service account to default running nodes as if not overridden in `node_pools`."
value = "${module.gke.service_account}"
}
2 changes: 1 addition & 1 deletion examples/stub_domains/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ It will:
| network | |
| project\_id | |
| region | |
| service\_account | The email address of the service account to default running nodes as if not overridden in `node_pools`. |
| service\_account | The service account to default running nodes as if not overridden in `node_pools`. |
| subnetwork | |
| zones | List of zones in which the cluster resides |

Expand Down
2 changes: 1 addition & 1 deletion examples/stub_domains/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ output "ca_certificate" {
}

output "service_account" {
description = "The email address of the service account to default running nodes as if not overridden in `node_pools`."
description = "The service account to default running nodes as if not overridden in `node_pools`."
value = "${module.gke.service_account}"
}
5 changes: 2 additions & 3 deletions modules/private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| region | The region to host the cluster in (required) | string | n/a | yes |
| regional | Whether is a regional cluster (zonal cluster if set false. WARNING: changing this after cluster creation is destructive!) | string | `"true"` | no |
| remove\_default\_node\_pool | Remove default node pool while setting up the cluster | string | `"false"` | no |
| service\_account | The name of the service account to run nodes as if not overridden in `node_pools`. The default value will cause a cluster-specific service account to be created. | string | `"create"` | no |
| service\_account | The service account to run nodes as if not overridden in `node_pools`. The default value will cause a cluster-specific service account to be created. | string | `"create"` | no |
| stub\_domains | Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server | map | `<map>` | no |
| subnetwork | The subnetwork to host the cluster in (required) | string | n/a | yes |
| zones | The zones to host the cluster in (optional if regional cluster / required if zonal) | list | `<list>` | no |
Expand All @@ -168,8 +168,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| node\_pools\_names | List of node pools names |
| node\_pools\_versions | List of node pools versions |
| region | Cluster region |
| service\_account | The email address of the service account to default running nodes as if not overridden in `node_pools`. |
| service\_account\_name | The name of the service account to default running nodes as if not overridden in `node_pools`. |
| service\_account | The service account to default running nodes as if not overridden in `node_pools`. |
| type | Cluster type (regional / zonal) |
| zones | List of zones in which the cluster resides |

Expand Down
7 changes: 1 addition & 6 deletions modules/private-cluster/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ output "node_pools_versions" {
}

output "service_account" {
description = "The email address of the service account to default running nodes as if not overridden in `node_pools`."
description = "The service account to default running nodes as if not overridden in `node_pools`."
value = "${local.service_account}"
}

output "service_account_name" {
description = "The name of the service account to default running nodes as if not overridden in `node_pools`."
value = "projects/${var.project_id}/serviceAccounts/${local.service_account}"
}
2 changes: 1 addition & 1 deletion modules/private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ variable "monitoring_service" {
}

variable "service_account" {
description = "The name of the service account to run nodes as if not overridden in `node_pools`. The default value will cause a cluster-specific service account to be created."
description = "The service account to run nodes as if not overridden in `node_pools`. The default value will cause a cluster-specific service account to be created."
default = "create"
}
variable "enable_private_endpoint" {
Expand Down
7 changes: 1 addition & 6 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ output "node_pools_versions" {
}

output "service_account" {
description = "The email address of the service account to default running nodes as if not overridden in `node_pools`."
description = "The service account to default running nodes as if not overridden in `node_pools`."
value = "${local.service_account}"
}

output "service_account_name" {
description = "The name of the service account to default running nodes as if not overridden in `node_pools`."
value = "projects/${var.project_id}/serviceAccounts/${local.service_account}"
}
2 changes: 1 addition & 1 deletion test/fixtures/shared/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ output "ca_certificate" {
}

output "service_account" {
description = "The email address of the service account to default running nodes as if not overridden in `node_pools`."
description = "The service account to default running nodes as if not overridden in `node_pools`."
value = "${module.example.service_account}"
}
20 changes: 0 additions & 20 deletions test/fixtures/simple_zonal/unique_outputs.tf

This file was deleted.

14 changes: 12 additions & 2 deletions test/integration/simple_zonal/controls/gcp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,18 @@

control "gcp" do
title "Native InSpec Resources"
describe google_service_account name: attribute("service_account_name") do

service_account = attribute("service_account")
project_id = attribute("project_id")

if service_account.start_with? "projects/"
service_account_name = service_account
else
service_account_name = "projects/#{project_id}/serviceAccounts/#{service_account}"
end

describe google_service_account name: service_account_name do
its("display_name") { should eq "Terraform-managed service account for cluster #{attribute("cluster_name")}" }
its("project_id") { should eq attribute("project_id") }
its("project_id") { should eq project_id }
end
end
2 changes: 1 addition & 1 deletion test/integration/simple_zonal/inspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ attributes:
- name: service_account
required: true
type: string
- name: service_account_name
- name: service_account
required: true
type: string
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,6 @@ variable "monitoring_service" {
}

variable "service_account" {
description = "The name of the service account to run nodes as if not overridden in `node_pools`. The default value will cause a cluster-specific service account to be created."
description = "The service account to run nodes as if not overridden in `node_pools`. The default value will cause a cluster-specific service account to be created."
default = "create"
}

0 comments on commit 177991a

Please sign in to comment.