diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 2bca928879..89d4b4fef6 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -90,3 +90,5 @@ steps: echo "*******************************************************************************" fi # [END tf-apply] +options: + logging: CLOUD_LOGGING_ONLY \ No newline at end of file diff --git a/environments/dev/backend.tf b/environments/dev/backend.tf index 33a807a336..9583748527 100644 --- a/environments/dev/backend.tf +++ b/environments/dev/backend.tf @@ -15,7 +15,7 @@ terraform { backend "gcs" { - bucket = "PROJECT_ID-tfstate" + bucket = "aksgkelearning-tfstate" prefix = "env/dev" } } diff --git a/environments/dev/main.tf b/environments/dev/main.tf index a28b76be75..a9bc0bf940 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -21,20 +21,14 @@ provider "google" { project = "${var.project}" } -module "vpc" { - source = "../../modules/vpc" - project = "${var.project}" - env = "${local.env}" -} +# module "vpc" { +# source = "../../modules/vpc" +# project = "${var.project}" +# env = "${local.env}" +# } -module "http_server" { - source = "../../modules/http_server" - project = "${var.project}" - subnet = "${module.vpc.subnet}" -} - -module "firewall" { - source = "../../modules/firewall" - project = "${var.project}" - subnet = "${module.vpc.subnet}" -} +# module "gke_cluster" { +# source = "../../modules/gke" +# project = "${var.project}" +# subnet = "${module.vpc.subnet}" +# } \ No newline at end of file diff --git a/environments/dev/outputs.tf b/environments/dev/outputs.tf index 0ae139e4f7..f0b6effeb7 100644 --- a/environments/dev/outputs.tf +++ b/environments/dev/outputs.tf @@ -13,22 +13,10 @@ # limitations under the License. -output "network" { - value = "${module.vpc.network}" -} +# output "network" { +# value = "${module.vpc.network}" +# } -output "subnet" { - value = "${module.vpc.subnet}" -} - -output "firewall_rule" { - value = "${module.firewall.firewall_rule}" -} - -output "instance_name" { - value = "${module.http_server.instance_name}" -} - -output "external_ip" { - value = "${module.http_server.external_ip}" -} +# output "subnet" { +# value = "${module.vpc.subnet}" +# } diff --git a/environments/dev/terraform.tfvars b/environments/dev/terraform.tfvars index cb8a5a1bbc..2b71dc6eb4 100644 --- a/environments/dev/terraform.tfvars +++ b/environments/dev/terraform.tfvars @@ -1 +1 @@ -project="PROJECT_ID" \ No newline at end of file +project="aksgkelearning" \ No newline at end of file diff --git a/environments/prod/backend.tf b/environments/prod/backend.tf index 7ed343b1a2..02cbbf2ae8 100644 --- a/environments/prod/backend.tf +++ b/environments/prod/backend.tf @@ -15,7 +15,7 @@ terraform { backend "gcs" { - bucket = "PROJECT_ID-tfstate" + bucket = "aksgkelearning-tfstate" prefix = "env/prod" } } diff --git a/environments/prod/terraform.tfvars b/environments/prod/terraform.tfvars index cb8a5a1bbc..2b71dc6eb4 100644 --- a/environments/prod/terraform.tfvars +++ b/environments/prod/terraform.tfvars @@ -1 +1 @@ -project="PROJECT_ID" \ No newline at end of file +project="aksgkelearning" \ No newline at end of file diff --git a/modules/firewall/main.tf b/modules/firewall/main.tf index 5e40f7089f..1d2e549134 100644 --- a/modules/firewall/main.tf +++ b/modules/firewall/main.tf @@ -27,6 +27,6 @@ resource "google_compute_firewall" "allow-http" { ports = ["80"] } - target_tags = ["http-server2"] + target_tags = ["http-server"] source_ranges = ["0.0.0.0/0"] } diff --git a/modules/gke/main.tf b/modules/gke/main.tf new file mode 100644 index 0000000000..0b8250c061 --- /dev/null +++ b/modules/gke/main.tf @@ -0,0 +1,44 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +locals { + network = "${element(split("-", var.subnet), 0)}" + subnetwork= "${var.subnet[0]}" +} + +resource "google_container_cluster" "learning" { + name = "ken-gke-cluster" + location = "us-west1" + network = "${local.network}" + subnetwork="${local.subnetwork}" + remove_default_node_pool = true + initial_node_count = 1 +} + +# resource "google_container_node_pool" "learning_preemptible_nodes" { +# name = "ken-node-pool" +# location = "us-west1" +# cluster = google_container_cluster.learning.name +# node_count = 1 + +# node_config { +# preemptible = true +# machine_type = "e2-micro" +# service_account = "id-420039265868-ken@aksgkelearning.iam.gserviceaccount.com" +# oauth_scopes = [ +# "https://www.googleapis.com/auth/cloud-platform" +# ] +# } +# } diff --git a/modules/gke/outputs.tf b/modules/gke/outputs.tf new file mode 100644 index 0000000000..2c31d84ad0 --- /dev/null +++ b/modules/gke/outputs.tf @@ -0,0 +1,14 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + diff --git a/modules/gke/variables.tf b/modules/gke/variables.tf new file mode 100644 index 0000000000..2301355111 --- /dev/null +++ b/modules/gke/variables.tf @@ -0,0 +1,17 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +variable "project" {} +variable "subnet" {} diff --git a/modules/gke/versions.tf b/modules/gke/versions.tf new file mode 100644 index 0000000000..4cc81b29fa --- /dev/null +++ b/modules/gke/versions.tf @@ -0,0 +1,18 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +terraform { + required_version = "~> 1.0.0" +} diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 8fce4ab20d..f33ce25ebc 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -26,6 +26,11 @@ module "vpc" { subnet_ip = "10.${var.env == "dev" ? 10 : 20}.10.0/24" subnet_region = "us-west1" }, + { + subnet_name = "${var.env}-subnet-02" + subnet_ip = "10.${var.env == "dev" ? 10 : 20}.11.0/24" + subnet_region = "us-west1" + }, ] secondary_ranges = {