terraform-google-modules / terraform-example-foundation

Shows how the CFT modules can be composed to build a secure cloud foundation
https://cloud.google.com/architecture/security-foundations
Apache License 2.0
1.21k stars 708 forks source link

Running terraform vet runs into 404 errors #1322

Open tlcncptv opened 1 month ago

tlcncptv commented 1 month ago

TL;DR

google_folder.bootstrap: converting TF resource to CAI: getting resource ancestry or parent failed: googleapi: got HTTP response code 404 with body

The instructions say to run the plan. I run the plan, get the json output with terraform show, then run vet. Vet fails because the resource for the parent folder does not exist. I go into the console and create it and the same thing happens. Now I am confused. It appears vet only works if the changes are applied.

For terraform vet to pass, the folder id needs to be in the parent folder.

Expected behavior

I would expect the documentation to reflect the parent folder id, not a parent folder name.

Observed behavior

If I put the folder id, it passes vet $? == 0.

Terraform Configuration

parent_folder = "XXXXXXXXXXXX"

Terraform Version

Terraform v1.8.2
on darwin_arm64
+ provider registry.terraform.io/hashicorp/google v5.40.0
+ provider registry.terraform.io/hashicorp/google-beta v5.40.0
+ provider registry.terraform.io/hashicorp/null v3.2.2
+ provider registry.terraform.io/hashicorp/random v3.6.2
+ provider registry.terraform.io/hashicorp/time v0.12.0
+ provider registry.terraform.io/integrations/github v5.34.0

Additional information

No response

daniel-cit commented 1 month ago

Hi @tlcncptv as stated in the example terraform.tfvars file,

# Optional - for an organization with existing projects or for development/validation.
# Uncomment this variable to place all the example foundation resources under
# the provided folder instead of the root organization.
# The variable value is the numeric folder ID
# The folder must already exist.
# parent_folder = "01234567890"

and in the input variable

variable "parent_folder" {
  description = "Optional - for an organization with existing projects or for development/validation. It will place all the example foundation resources under the provided folder instead of the root organization. The value is the numeric folder ID. The folder must already exist."
  type        = string
  default     = ""
}

the parent folder must be created before starting the deployment of the foundation, and the value must be the numeric folder ID, not the display name

tlcncptv commented 1 month ago

The issue is the example is 'dev_NNNNNNN' or something similar. So I spent time looking for the path name, as opposed to just the id. And yes, I did not read the comments. The only real issue here is the exemplar parent folder should be similar to the numeric id examples for things like project id.

On Wed, Aug 7, 2024 at 11:32 AM Daniel Andrade @.***> wrote:

Hi @tlcncptv https://github.com/tlcncptv as stated here, the parent folder must be created before starting the deployment of the foundation, and the value must be the numeric folder ID, not the display name

https://github.com/terraform-google-modules/terraform-example-foundation/blob/028f85f51dcc06a879a07f1f88758d139d10287b/0-bootstrap/terraform.example.tfvars#L47C3-L52C32

Optional - for an organization with existing projects or for development/validation.

Uncomment this variable to place all the example foundation resources under

the provided folder instead of the root organization.

The variable value is the numeric folder ID

The folder must already exist.

parent_folder = "01234567890"

— Reply to this email directly, view it on GitHub https://github.com/terraform-google-modules/terraform-example-foundation/issues/1322#issuecomment-2274085987, or unsubscribe https://github.com/notifications/unsubscribe-auth/BGWX4VLS2GIU42MQKACKXR3ZQJR4JAVCNFSM6AAAAABMDDV2OSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZUGA4DKOJYG4 . You are receiving this because you were mentioned.Message ID: <terraform-google-modules/terraform-example-foundation/issues/1322/2274085987 @github.com>

daniel-cit commented 1 month ago

The issue is the example is 'dev_NNNNNNN' or something similar. So I spent time looking for the path name, as opposed to just the id. And yes, I did not read the comments. The only real issue here is the exemplar parent folder should be similar to the numeric id examples for things like project id. On Wed, Aug 7, 2024 at 11:32 AM Daniel Andrade @.***> wrote: Hi @tlcncptv https://github.com/tlcncptv as stated here, the parent folder must be created before starting the deployment of the foundation, and the value must be the numeric folder ID, not the display name https://github.com/terraform-google-modules/terraform-example-foundation/blob/028f85f51dcc06a879a07f1f88758d139d10287b/0-bootstrap/terraform.example.tfvars#L47C3-L52C32 # Optional - for an organization with existing projects or for development/validation. # Uncomment this variable to place all the example foundation resources under # the provided folder instead of the root organization. # The variable value is the numeric folder ID # The folder must already exist. # parent_folder = "01234567890" — Reply to this email directly, view it on GitHub <#1322 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/BGWX4VLS2GIU42MQKACKXR3ZQJR4JAVCNFSM6AAAAABMDDV2OSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZUGA4DKOJYG4 . You are receiving this because you were mentioned.Message ID: <terraform-google-modules/terraform-example-foundation/issues/1322/2274085987 @github.com>

@tlcncptv can you help finding the example you used that is in the format of dev_NNNNNNN?

The one in the file is in the format: parent_folder = "01234567890"

tlcncptv commented 1 month ago

parent_folder = "01234567890"

I am so sorry. I must have fat fingered it at some point giving myself my own confusion as a bonus.

I think a format comment might still help: org_id = "REPLACE_ME" # format "000000000000". But, clearly i am more of my own problem than anything else here.

Tim

On Wed, Aug 7, 2024 at 12:59 PM Daniel Andrade @.***> wrote:

The issue is the example is 'dev_NNNNNNN' or something similar. So I spent time looking for the path name, as opposed to just the id. And yes, I did not read the comments. The only real issue here is the exemplar parent folder should be similar to the numeric id examples for things like project id. … <#m5704538879677161464> On Wed, Aug 7, 2024 at 11:32 AM Daniel Andrade @.***> wrote: Hi @tlcncptv https://github.com/tlcncptv https://github.com/tlcncptv as stated here, the parent folder must be created before starting the deployment of the foundation, and the value must be the numeric folder ID, not the display name https://github.com/terraform-google-modules/terraform-example-foundation/blob/028f85f51dcc06a879a07f1f88758d139d10287b/0-bootstrap/terraform.example.tfvars#L47C3-L52C32

Optional - for an organization with existing projects or for

development/validation. # Uncomment this variable to place all the example foundation resources under # the provided folder instead of the root organization. # The variable value is the numeric folder ID # The folder must already exist. # parent_folder = "01234567890" — Reply to this email directly, view it on GitHub <#1322 (comment) https://github.com/terraform-google-modules/terraform-example-foundation/issues/1322#issuecomment-2274085987>, or unsubscribe https://github.com/notifications/unsubscribe-auth/BGWX4VLS2GIU42MQKACKXR3ZQJR4JAVCNFSM6AAAAABMDDV2OSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZUGA4DKOJYG4 . You are receiving this because you were mentioned.Message ID: < /issues/1322 https://github.com/terraform-google-modules/terraform-example-foundation/issues/1322/2274085987 @github.com>

@tlcncptv https://github.com/tlcncptv can you help finding the example you used that is in the format of dev_NNNNNNN?

The one in the file is in the format: parent_folder = "01234567890"

— Reply to this email directly, view it on GitHub https://github.com/terraform-google-modules/terraform-example-foundation/issues/1322#issuecomment-2274247528, or unsubscribe https://github.com/notifications/unsubscribe-auth/BGWX4VJMGMBKL5O6YXAQSY3ZQJ4C7AVCNFSM6AAAAABMDDV2OSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZUGI2DONJSHA . You are receiving this because you were mentioned.Message ID: <terraform-google-modules/terraform-example-foundation/issues/1322/2274247528 @github.com>