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

Add new resource google_folder_iam_audit_config. #3698

Merged
merged 3 commits into from
Jun 26, 2020

Conversation

xingao267
Copy link
Member

Release Note Template for Downstream PRs (will be copied)

google_folder_iam_audit_config

@modular-magician
Copy link
Collaborator

Hello! I am a robot who works on Magic Modules PRs.

I have detected that you are a community contributor, so your PR will be assigned to someone with a commit-bit on this repo for initial review.

Thanks for your contribution! A human will be with you soon.

@slevenick, please review this PR or find an appropriate assignee.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 6 files changed, 510 insertions(+), 7 deletions(-))
Terraform Beta: Diff ( 6 files changed, 510 insertions(+), 7 deletions(-))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=122254"

)

func folderIamAuditConfigImportStep(t *testing.T, resourceName, fname, service string) resource.TestStep {
name, err := getFolderNameByParentAndDisplayName("organizations/"+getTestOrgFromEnv(t), fname, googleProviderConfig(t))
Copy link
Member Author

Choose a reason for hiding this comment

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

It's complaining the *Config returned by googleProviderConfig(t) is {}, but I'm not sure why or how I can get the *Config and use it to retrieve the folder ID and use it in the Import check.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, so what is happening here is that there is a little confusion on the context that this is being evaluated in.

Generally googleProviderConfig(t) gives you the *Config that is being used for the test context that you are in. If you call it outside of a go test it will return {} because the *Config is only instantiated at the beginning of the test run, when vcrTest(...) is called. So you'll notice that all of the uses of googleProviderConfig(t) only exist in functions that are called from within the terraform process under test.

For example: https://github.com/terraform-providers/terraform-provider-google/blob/master/google/resource_google_folder_iam_policy_test.go#L89

The call to googleProviderConfig(t) is within a resource.TestCheckFunc, so it gets evaluated within the vcrTest call.

In your code, folderIamAuditConfigImportStep is evaluated before vcrTest is called, and passed as an argument to it. This causes an issue because:
The config doesn't exist
The folder doesn't exist, as no steps have run yet

I don't believe creating the import steps like this will work because of these issues.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you have any recommendation around how to test this? I was trying to getting the folder ID from the display name and parent as for folder, the folder ID is needed in the terraform import. It seems it's not easy to get that piece of information.

Copy link
Member Author

@xingao267 xingao267 Jun 24, 2020

Choose a reason for hiding this comment

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

I removed the import state check for now. @slevenick

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 6 files changed, 510 insertions(+), 7 deletions(-))
Terraform Beta: Diff ( 6 files changed, 510 insertions(+), 7 deletions(-))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=122254"

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 6 files changed, 510 insertions(+), 7 deletions(-))
Terraform Beta: Diff ( 6 files changed, 510 insertions(+), 7 deletions(-))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=122254"

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 6 files changed, 510 insertions(+), 7 deletions(-))
Terraform Beta: Diff ( 6 files changed, 510 insertions(+), 7 deletions(-))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=122254"

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 6 files changed, 474 insertions(+), 7 deletions(-))
Terraform Beta: Diff ( 6 files changed, 474 insertions(+), 7 deletions(-))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=122669"

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 462 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 5 files changed, 462 insertions(+), 2 deletions(-))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=122671"

@xingao267
Copy link
Member Author

@slevenick could you take another look? Thanks!

Copy link
Contributor

@slevenick slevenick left a comment

Choose a reason for hiding this comment

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

Thanks for the addition!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants