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

Adding new App Engine support #4

Conversation

lilithmooncohen
Copy link
Contributor

See hashicorp/terraform-provider-google#1503 for context.

Merge after: #3

@morgante
Copy link
Contributor

@ryanckoch Can you please add a test to check that an app is actually created on the project?

@lilithmooncohen
Copy link
Contributor Author

@morgante Done

app_engine_enabled = "${length(keys(var.app_engine)) > 0 ? true : false}"

app_engine_config = {
enabled = "${list(var.app_engine)}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this actually work? var.app_engine is a map, not a list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It gets the length of keys in app_engine which is a list

Copy link
Contributor

@morgante morgante Jul 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local.app_engine_config is a map of lists with keys enabled and disabled. Line 86 is referencing that list by key depending if local.app_engine_enabled is true or false. If local.app_engine_enabled is true, it sets app_engine to the enabled list which is the users config, otherwise it uses the disabled list which is empty. It is a dirty hack, but the only way I could see to pass a completely empty list to app_engine and still be able to accept the app_engine variable as a map in our module. Otherwise, it would set app_engine = [{}] which isnt an empty list and tells the provider to setill enable app_engine.

main.tf Outdated
@@ -119,6 +127,23 @@ resource "null_resource" "delete_default_compute_service_account" {
depends_on = ["google_project_service.project_services"]
}

/******************************************
Default app engine service account deletion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryanckoch We should not delete the app engine service account—deleting it will break App Engine.

@@ -76,6 +82,8 @@ resource "google_project" "project" {
auto_create_network = "${var.auto_create_network}"

labels = "${var.labels}"

app_engine = "${local.app_engine_config["${local.app_engine_enabled ? "enabled" : "disabled"}"]}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryanckoch This is hard to parse and somewhat confusing.

Wouldn't app_engine = "${local.app_engine_enabled ? var.app_engine : list()}" work just as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wont allow for a list in a conditional. That would definitely be much cleaner, but that is the reason for the hack app_engine_config map.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "${local.app_engine_enabled ? local.app_engine_config["enabled"] : local.app_engine_config["disabled"]}"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same:

Error: module.project-factory.google_project.project: 1 error(s) occurred:

* module.project-factory.google_project.project: At column 3, line 1: conditional operator cannot be used with list values in:

${local.app_engine_enabled ? local.app_engine_config["enabled"] : local.app_engine_config["disabled"]}

@@ -76,6 +82,8 @@ resource "google_project" "project" {
auto_create_network = "${var.auto_create_network}"

labels = "${var.labels}"

app_engine = "${local.app_engine_config["${local.app_engine_enabled ? "enabled" : "disabled"}"]}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also worth noting, that although the examples in the documentation show app_engine as accepting a map, it accepts a list with a max length of 1.
https://github.com/terraform-providers/terraform-provider-google/blob/master/google/resource_google_project.go#L95

Have created an issue on the provider: hashicorp/terraform-provider-google#1821

@morgante
Copy link
Contributor

Please address this comment and improve the app engine integration test by using (a) a different region + (b) an additional non-default app_engine flag + verifying both are set corectly.

@lilithmooncohen
Copy link
Contributor Author

@morgante The above comment has been addressed. It is worth noting that setting custom feature_settings requires multiple applies: hashicorp/terraform-provider-google#1826

@morgante morgante merged commit b2cef1c into terraform-google-modules:master Jul 30, 2018
morgante pushed a commit that referenced this pull request Sep 21, 2018
merging with project factory master
kopachevsky pushed a commit to kopachevsky/terraform-google-project-factory that referenced this pull request Oct 8, 2019
…odules/aaron-lane-v0.1.0

Add CHANGELOG entry for 0.1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants