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

NAP-275/looker config #41

Merged
merged 4 commits into from
Aug 18, 2021
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
14 changes: 9 additions & 5 deletions experimental/cloudbuild/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ steps:

echo "bigquery_region = \"${_FOURKEYS_BIGQUERY_REGION}\"" >> environment.auto.tfvars
echo "cloud_build_branch = \"${_FOURKEYS_CLOUD_BUILD_BRANCH}\"" >> environment.auto.tfvars
echo "google_domain_mapping_region = \"${_FOURKEYS_DOMAIN_MAPPING_REGION}\"" >> environment.auto.tfvars
echo "google_gcr_domain = \"${_FOURKEYS_GCR_DOMAIN}\"" >> environment.auto.tfvars
echo "google_project_id = \"${PROJECT_ID}\"" >> environment.auto.tfvars
echo "google_region = \"${_FOURKEYS_REGION}\"" >> environment.auto.tfvars
echo "google_gcr_domain = \"${_FOURKEYS_GCR_DOMAIN}\"" >> environment.auto.tfvars
echo "google_domain_mapping_region = \"${_FOURKEYS_DOMAIN_MAPPING_REGION}\"" >> environment.auto.tfvars
echo "looker_service_account = ${_FOURKEYS_LOOKER_SERVICE_ACCOUNT}" >> environment.auto.tfvars
echo "mapped_domain = \"${_FOURKEYS_MAPPED_DOMAIN}\"" >> environment.auto.tfvars
echo "parsers = [ ${_FOURKEYS_PARSERS} ]" >> environment.auto.tfvars
echo "owner = \"${_FOURKEYS_OWNER}\"" >> environment.auto.tfvars
echo "parsers = [ ${_FOURKEYS_PARSERS} ]" >> environment.auto.tfvars
echo "repository = \"$REPO_NAME\"" >> environment.auto.tfvars
echo "service_account_keys_policy_override = ${_FOURKEYS_SERVICE_ACCOUNT_KEYS}" >> environment.auto.tfvars

terraform init
else
Expand Down Expand Up @@ -125,11 +127,13 @@ options:
substitutions:
_FOURKEYS_BIGQUERY_REGION: 'US'
_FOURKEYS_CLOUD_BUILD_BRANCH: 'main'
_FOURKEYS_DOMAIN_MAPPING_REGION: 'us-central1'
_FOURKEYS_GCR_DOMAIN: 'gcr.io'
_FOURKEYS_LOOKER_SERVICE_ACCOUNT: 'true'
_FOURKEYS_MAPPED_DOMAIN: ''
_FOURKEYS_OWNER: 'GoogleCloudPlatform'
_FOURKEYS_PARSERS: '\"cloud-build\", \"github\", \"gitlab\", \"tekton\"'
_FOURKEYS_PROVISION_BRANCH: 'main'
_FOURKEYS_REGION: 'us-central1'
_FOURKEYS_DOMAIN_MAPPING_REGION: 'us-central1'
_FOURKEYS_MAPPED_DOMAIN: ''
_FOURKEYS_SERVICE_ACCOUNT_KEYS: 'true'
timeout: 3600s # Same as token now, i.e. 1hr.
4 changes: 4 additions & 0 deletions experimental/terraform/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ output "event_handler_secret" {
value = google_secret_manager_secret_version.event_handler.secret_data
sensitive = true
}

output "looker_service_account_email" {
value = try(module.service_account_for_looker[0].email, null)
}
26 changes: 26 additions & 0 deletions experimental/terraform/resource_looker.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module "service_account_for_looker" {
source = "terraform-google-modules/service-accounts/google"
version = "~> 3.0"
count = var.looker_service_account ? 1 : 0

display_name = "Looker"
description = "Looker accessor account (managed by Terraform)"
project_id = var.google_project_id
names = ["looker"]
project_roles = [
"${var.google_project_id}=>roles/bigquery.user",
]
}

resource "google_project_organization_policy" "service_account_keys_policy" {
count = var.service_account_keys_policy_override ? 1 : 0

project = var.google_project_id
constraint = "iam.disableServiceAccountKeyCreation"

list_policy {
allow {
all = false
}
}
}
12 changes: 12 additions & 0 deletions experimental/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ variable "google_gcr_domain" {
default = "gcr.io"
}

variable "looker_service_account" {
description = "To create a service account for Looker (dashboard)"
default = false
type = bool
}

variable "mapped_domain" {
type = string
description = "Domain name which is mapped on cloud run."
Expand Down Expand Up @@ -95,6 +101,12 @@ variable "repository" {
description = "The name of the git repository"
}

variable "service_account_keys_policy_override" {
description = "To override organisation service account keys creation policy for project"
default = false
type = bool
}

variable "subdomain" {
description = "The prefix added to the `mapped_domain`, of event handler, use to create a record within Google Cloud DNS."
default = "dora"
Expand Down