Skip to content

Commit

Permalink
modify example, fixture, obj for healthchecks
Browse files Browse the repository at this point in the history
  • Loading branch information
bharathkkb authored and SKozlovsky committed Dec 20, 2019
1 parent 44b1919 commit cc60299
Show file tree
Hide file tree
Showing 11 changed files with 177 additions and 41 deletions.
5 changes: 5 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ suites:
name: terraform
command_timeout: 1800
root_module_directory: test/fixtures/fabric_project
- name: app_engine
driver:
name: terraform
command_timeout: 1800
root_module_directory: test/fixtures/app_engine
# Disabled due to issue #275
# (https://github.com/terraform-google-modules/terraform-google-project-factory/issues/275)
# - name: full
Expand Down
15 changes: 8 additions & 7 deletions examples/app_engine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@ Expected variables:

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| auth\_domain | The domain to authenticate users with when using App Engine's User API. | string | n/a | yes |
| feature\_settings | A list of maps of optional settings to configure specific App Engine features. | list | `<list>` | no |
| location\_id | The location to serve the app from. | string | `"us-central"` | no |
| project\_id | The project to enable app engine on. | string | n/a | yes |
| serving\_status | The serving status of the app. | string | `"SERVING"` | no |
| billing\_account | The ID of the billing account to associate this project with | string | n/a | yes |
| folder\_id | The ID of a folder to host this project. | string | `""` | no |
| location\_id | The location to serve the app from. | string | `"us-east4"` | no |
| org\_id | The organization ID. | string | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| code\_bucket | The GCS bucket code is being stored in for this app. |
| name | Unique name of the app, usually apps/{PROJECT_ID}. |
| app\_name | Unique name of the app, usually apps/{PROJECT_ID}. |
| default\_hostname | The default hostname for this app. |
| location\_id | The location app engine is serving from |
| project\_id | The project ID where app engine is created |

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
42 changes: 33 additions & 9 deletions examples/app_engine/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,42 @@
* limitations under the License.
*/

/******************************************
Provider configuration
*****************************************/
provider "google" {
version = "~> 2.18.1"
}

provider "google-beta" {
version = "~> 2.18.1"
}

provider "null" {
version = "~> 2.1"
}

provider "random" {
version = "~> 2.2"
}

resource "random_string" "suffix" {
length = 4
special = false
upper = false
}

module "app-engine-project" {
source = "../../"
name = "appeng-${random_string.suffix.result}"
random_project_id = "true"
org_id = var.org_id
folder_id = var.folder_id
billing_account = var.billing_account
activate_apis = [
"appengine.googleapis.com",
]
}

module "app-engine" {
source = "../../modules/app_engine"
location_id = var.location_id
auth_domain = var.auth_domain
serving_status = var.serving_status
feature_settings = [{ enabled = true }]
project_id = "example-project"
source = "../../modules/app_engine"
project_id = module.app-engine-project.project_id
location_id = var.location_id
}
18 changes: 14 additions & 4 deletions examples/app_engine/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,23 @@
* limitations under the License.
*/

output "name" {
output "project_id" {
description = "The project ID where app engine is created"
value = module.app-engine-project.project_id
}

output "app_name" {
description = "Unique name of the app, usually apps/{PROJECT_ID}."
value = module.app-engine.name
}

output "code_bucket" {
description = "The GCS bucket code is being stored in for this app."
value = module.app-engine.code_bucket
output "default_hostname" {
description = "The default hostname for this app."
value = module.app-engine.default_hostname
}

output "location_id" {
description = "The location app engine is serving from"
value = var.location_id
}

29 changes: 13 additions & 16 deletions examples/app_engine/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,23 @@
* limitations under the License.
*/

variable "project_id" {
description = "The project to enable app engine on."
variable "org_id" {
description = "The organization ID."
type = string
}

variable "location_id" {
description = "The location to serve the app from."
default = "us-central"
}

variable "auth_domain" {
description = "The domain to authenticate users with when using App Engine's User API."
variable "folder_id" {
description = "The ID of a folder to host this project."
type = string
default = ""
}

variable "serving_status" {
description = "The serving status of the app."
default = "SERVING"
variable "billing_account" {
description = "The ID of the billing account to associate this project with"
type = string
}

variable "feature_settings" {
description = "A list of maps of optional settings to configure specific App Engine features."
type = list
default = [{ enabled = true }]
variable "location_id" {
description = "The location to serve the app from."
default = "us-east4"
}
4 changes: 2 additions & 2 deletions modules/app_engine/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ variable "serving_status" {

variable "feature_settings" {
description = "A list of maps of optional settings to configure specific App Engine features."
type = list
default = [{ enabled = true }]
type = list(object({ split_health_checks = bool }))
default = [{ split_health_checks = true }]
}

22 changes: 22 additions & 0 deletions test/fixtures/app_engine/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* 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
*
* http://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.
*/

module "app-eng" {
source = "../../../examples/app_engine"
org_id = var.org_id
folder_id = var.folder_id
billing_account = var.billing_account
}
35 changes: 35 additions & 0 deletions test/fixtures/app_engine/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* 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
*
* http://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.
*/

output "project_id" {
description = "The project ID where app engine is created"
value = module.app-eng.project_id
}

output "app_name" {
description = "Unique name of the app, usually apps/{PROJECT_ID}."
value = module.app-eng.app_name
}

output "default_hostname" {
description = "The default hostname for this app."
value = module.app-eng.default_hostname
}

output "region" {
description = "The location app engine is serving from"
value = module.app-eng.location_id
}
33 changes: 33 additions & 0 deletions test/fixtures/app_engine/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* 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
*
* http://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 "org_id" {
description = "The organization ID."
type = string
}

variable "folder_id" {
description = "The ID of a folder to host this project."
type = string
default = ""
}

variable "billing_account" {
description = "The ID of the billing account to associate this project with"
type = string
}


Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

domain = attribute('domain')
project_id = attribute('project_id')
region = attribute('region')
app_name = attribute('app_name')

control 'project-factory-app-engine' do
title "Project Factory App Engine configuration"
Expand All @@ -31,10 +31,9 @@
end
end

it { expect(metadata).to include(authDomain: domain) }
it { expect(metadata[:featureSettings]).to include({splitHealthChecks: true}) }
it { expect(metadata).to include(id: project_id) }
it { expect(metadata).to include(name: "apps/#{project_id}") }
it { expect(metadata).to include(name: app_name) }
it { expect(metadata).to include(locationId: region) }
it { expect(metadata).to include(servingStatus: 'SERVING') }
end
Expand Down
10 changes: 10 additions & 0 deletions test/integration/app_engine/inspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: app_engine
attributes:
- name: project_id
required: true
type: string
- name: region
required: true
- name: app_name
required: true

0 comments on commit cc60299

Please sign in to comment.