-
Notifications
You must be signed in to change notification settings - Fork 547
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
Allow project name to be changed separately from project ID #154
Allow project name to be changed separately from project ID #154
Conversation
02542e6
to
e0d5c4c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The project_id
interface needs to be added to the gsuite_enabled
module.
We should test these changes against the minimal suite converged from the master branch. Are there any unexpected consequences just from updating? Can the name be changed without destroying resources?
I think you are referring to this change?
https://gist.github.com/thefirstofthe300/d72f2d563196e1fce1ab36b734e64fdb The minimal test converges properly. The full test suite recreates the project because the project ID changes. The precondition being rebuilt is due to an old container version being used and causing the shell command to fail. I'm going to be submitting a PR tomorrow to update the container and make targets since the targets themselves fail right now. |
Apologies: I missed the changes to With respect to testing the full suite, can you verify the impact of changing only the name? |
e0d5c4c
to
039dd58
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looks good except dropping local.project_id
.
s_account_fmt = "${format("serviceAccount:%s", google_service_account.default_service_account.email)}" | ||
api_s_account = "${format("%[email protected]", local.project_number)}" | ||
api_s_account = "${format("%[email protected]", google_project.main.number)}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't this continue to reference project_number
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The net effect of this change is a no-op. It removes a level of indirection since local.project_number
is referring to google_project.main.number
. I see no purpose for continuing to use local.project_number
. It makes things a bit more difficult to read so I would much prefer to remove it.
@@ -26,18 +26,17 @@ resource "random_id" "random_project_id_suffix" { | |||
*****************************************/ | |||
locals { | |||
group_id = "${var.manage_group ? format("group:%s", var.group_email) : ""}" | |||
project_id = "${google_project.main.project_id}" | |||
project_number = "${google_project.main.number}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why drop local.project_number
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The local here is a level of indirection that is unnecessary, IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's easier to manage this in one place instead of having to update it on every resource.
modules/core_project_factory/main.tf
Outdated
project_org_id = "${var.folder_id != "" ? "" : var.org_id}" | ||
project_folder_id = "${var.folder_id != "" ? var.folder_id : ""}" | ||
temp_project_id = "${var.random_project_id ? format("%s-%s",var.name,random_id.random_project_id_suffix.hex) : var.name}" | ||
project_id = "${var.project_id == "" ? var.name : var.project_id}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should continue to have project_id
reference the actual project created.
We can move the conditional check into the project ID itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This local doesn't necessarily refer to the value that will be used to set the project's ID. I'll rename these variables to make the naming a bit more sane.
@@ -104,7 +103,7 @@ resource "google_resource_manager_lien" "lien" { | |||
resource "google_project_service" "project_services" { | |||
count = "${length(var.activate_apis)}" | |||
|
|||
project = "${local.project_id}" | |||
project = "${google_project.main.project_id}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep local.project_id
unless there's a reason we can't, similarly for all cases of this replacement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am of the opinion that the project_id local should be removed or repurposed to make the project_id generation more clear. It also adds a layer of redirection that seems unnecessary so my comments on dropping the project_number
local applies as well.
039dd58
to
1fbfbdd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made a couple of tweaks around local naming.
I'm not sold on the idea of using locals that are equivalent to resource outputs. We should be using the resource outputs directly and avoid declaring those locals.
@@ -26,18 +26,17 @@ resource "random_id" "random_project_id_suffix" { | |||
*****************************************/ | |||
locals { | |||
group_id = "${var.manage_group ? format("group:%s", var.group_email) : ""}" | |||
project_id = "${google_project.main.project_id}" | |||
project_number = "${google_project.main.number}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The local here is a level of indirection that is unnecessary, IMHO.
s_account_fmt = "${format("serviceAccount:%s", google_service_account.default_service_account.email)}" | ||
api_s_account = "${format("%[email protected]", local.project_number)}" | ||
api_s_account = "${format("%[email protected]", google_project.main.number)}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The net effect of this change is a no-op. It removes a level of indirection since local.project_number
is referring to google_project.main.number
. I see no purpose for continuing to use local.project_number
. It makes things a bit more difficult to read so I would much prefer to remove it.
@@ -104,7 +103,7 @@ resource "google_resource_manager_lien" "lien" { | |||
resource "google_project_service" "project_services" { | |||
count = "${length(var.activate_apis)}" | |||
|
|||
project = "${local.project_id}" | |||
project = "${google_project.main.project_id}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am of the opinion that the project_id local should be removed or repurposed to make the project_id generation more clear. It also adds a layer of redirection that seems unnecessary so my comments on dropping the project_number
local applies as well.
1fbfbdd
to
a2f818d
Compare
a2f818d
to
6b3182c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can merge, but I'm unconvinced that spreading ${google_project.main.project_id}
into a dozen locations instead of referencing ${local.project_id}
everywhere is superior.
6b3182c
to
07a4a56
Compare
@@ -51,10 +63,6 @@ | |||
end | |||
end | |||
|
|||
it "includes the Google App Engine API service account user" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thefirstofthe300 Please do not introduce completely unrelated changes into a different PR. Is this somehow related to the other functionality in this PR and I missed it?
8326d7e
to
07a4a56
Compare
Fixes #132.