Skip to content

Commit

Permalink
Add terraform configuration for account management
Browse files Browse the repository at this point in the history
  • Loading branch information
Artemmkin committed Jan 13, 2018
1 parent 9a7005e commit e7e0083
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
24 changes: 24 additions & 0 deletions accounts/service-accounts/main.tf
@@ -0,0 +1,24 @@
resource "google_service_account" "gitlab_ci" {
account_id = "gitlab-ci"
display_name = "Gitlab CI"
}

resource "google_service_account_key" "gitlab_ci" {
service_account_id = "${google_service_account.gitlab_ci.id}"
public_key_type = "TYPE_X509_PEM_FILE"
}

resource "google_project_iam_policy" "gitlab_policy" {
project = "${var.project_id}"
policy_data = "${data.google_iam_policy.gitlab_ci.policy_data}"
}

data "google_iam_policy" "gitlab_ci" {
binding {
role = "roles/container.developer"

members = [
"serviceAccount:${google_service_account.gitlab_ci.email}",
]
}
}
3 changes: 3 additions & 0 deletions accounts/service-accounts/outputs.tf
@@ -0,0 +1,3 @@
output "gitlab_sa_key" {
value = "${google_service_account_key.gitlab_ci.private_key}"
}
5 changes: 5 additions & 0 deletions accounts/service-accounts/providers.tf
@@ -0,0 +1,5 @@
provider "google" {
version = "~> 1.4.0"
project = "${var.project_id}"
region = "${var.region}"
}
2 changes: 2 additions & 0 deletions accounts/service-accounts/terraform.tfvars.example
@@ -0,0 +1,2 @@
project_id = "example-123456"
region = "europe-west1"
10 changes: 10 additions & 0 deletions accounts/service-accounts/variables.tf
@@ -0,0 +1,10 @@
## ---------------------
## Provider configuration
## ---------------------
variable "project_id" {
description = "Project ID in GCP"
}

variable "region" {
description = "Region in which to manage GCP resources"
}

0 comments on commit e7e0083

Please sign in to comment.