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

fix(VPCSC): enable dryrun mode #1210

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

eeaton
Copy link
Collaborator

@eeaton eeaton commented Apr 29, 2024

Address issue #1209 .
CI tests have high flaky failure rate due in part to propagation delays with VPCSC perimeter. Changing this to dry mode better adheres to best practices for enablement and will avoid this issue in CI tests.

@eeaton eeaton requested review from rjerrems, gtsorbo and a team as code owners April 29, 2024 09:56
@eeaton eeaton enabled auto-merge (squash) April 29, 2024 09:57
restricted_services = var.restricted_services
vpc_accessible_services = ["RESTRICTED-SERVICES"]
# configurations for a perimeter in dry run mode.
resources_dry_run = [var.project_number]
Copy link
Contributor

Choose a reason for hiding this comment

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

the way the projects are added to the perimeter in step 4-projects also needs to be updated.

  vpc_service_control_attach_enabled = var.vpc_service_control_attach_enabled
  vpc_service_control_perimeter_name = var.vpc_service_control_perimeter_name
  vpc_service_control_sleep_duration = var.vpc_service_control_sleep_duration

https://github.com/terraform-google-modules/terraform-example-foundation/blob/master/4-projects/modules/single_project/main.tf#L62C1-L64C78

This cloud be a new flag like how it is coded in the project factory module

https://github.com/terraform-google-modules/terraform-google-project-factory/blob/master/modules/core_project_factory/main.tf#L347C1-L365C2

Copy link
Contributor

Choose a reason for hiding this comment

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

hey Eliot, just wondering if this change could be done with a flag instead of comment/uncomment the code, export in outputs to be read by other steps, like 4-projects as Daniel mentioned. It would also be less tricky for others blueprints that have documentation of how to deploy on top of foundation.

Copy link
Contributor

@daniel-cit daniel-cit left a comment

Choose a reason for hiding this comment

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

  • This fix also needs to be implemented in the hub and spoke flow
  • and also in the simple project module in step 4-projects
  • It would be helpful for the user to have a note on the main README and the READMEs from step 3 that the perimeter is created in dry mode and that it need to be updated to start enforcing the rules.

is it possible to have a flag vcp_sc_dry_run that could be set to true in the test instead of editing the code?

…trol.tf

Co-authored-by: Daniel Andrade <dandrade@ciandt.com>
Copy link
Contributor

@fmichaelobrien fmichaelobrien left a comment

Choose a reason for hiding this comment

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

/lgtm
either with/without dryrun flag - will be usefull

@eeaton
Copy link
Collaborator Author

eeaton commented Apr 30, 2024

Thanks Daniel & Amanda for the input.

ACK to add the changes consistently across step 4-projects, simple project module, and hub-and-spoke flow
Will add directions on the Readme about what to set for VPCSC.

re: the flag, like our discussion over chat I realize now we need separate input variables, because it is a valid use case for customers to set the enforced perimeter and dryrun perimeter to separate configurations (they are two different resources managed by the same CFT module). I'll draft this proposal and update the PR.

@eeaton
Copy link
Collaborator Author

eeaton commented May 2, 2024

Quick update: I'm blocked by a provider error on CFT.
terraform-google-modules/terraform-google-project-factory#904

The project factory module has partially designed support for an argument vpc_service_control_attach_dry_run but doesn't complete the implementation, it's not actually exposed to the Terraform Google Provider.

I've experimented locally with a few different patterns consistently that set the perimeter to dry_run mode in the 3-networks and 4-projects stage, but until the provider is fixed I don't think I can implement it using the current project factory module.

@daniel-cit
Copy link
Contributor

Quick update: I'm blocked by a provider error on CFT. terraform-google-modules/terraform-google-project-factory#904

The project factory module has partially designed support for an argument vpc_service_control_attach_dry_run but doesn't complete the implementation, it's not actually exposed to the Terraform Google Provider.

I've experimented locally with a few different patterns consistently that set the perimeter to dry_run mode in the 3-networks and 4-projects stage, but until the provider is fixed I don't think I can implement it using the current project factory module.

@eeaton new release for the project factory module v15.0.0

@eeaton
Copy link
Collaborator Author

eeaton commented May 3, 2024

I've made a few new commits, but no need to do a full review yet. I've got a working version of configuring the dry-run perimeter in my local environment for the dualsvpc pattern, but haven't tested it fully for hub-and-spoke (just copied off the key differences manually). I want to run the full CI tests to identify any configuration errors I might have introduced.

Once that is working well I'll add the readme changes and then ask for a review

@eeaton eeaton marked this pull request as draft May 24, 2024 15:01
auto-merge was automatically disabled May 24, 2024 15:01

Pull request was converted to draft

@daniel-cit
Copy link
Contributor

Dual Shared VPC build

Step #17 - "verify-networks":         	Error:      	Received unexpected error:
Step #17 - "verify-networks":         	            	FatalError{Underlying: error while running command: exit status 1; 
Step #17 - "verify-networks":         	            	Error: Output "restricted_access_level_name" not found
Step #17 - "verify-networks":         	            	
Step #17 - "verify-networks":         	            	The output variable requested could not be found in the state file. If you
Step #17 - "verify-networks":         	            	recently added this to your configuration, be sure to run `terraform apply`,
Step #17 - "verify-networks":         	            	since the state won't be updated with new output variables until that command
Step #17 - "verify-networks":         	            	is run.}
Step #17 - "verify-networks":         	Test:       	TestNetworks/nonproduction

@eeaton
Copy link
Collaborator Author

eeaton commented Jun 3, 2024

Thanks for helping identify the issue Daniel. I've fixed the tests to check for the correct variable name (I hadtweaked a few variables in code that I found to be misleading variable names but didn't apply the same changes to variables that the tests expected)

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.

None yet

4 participants