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

Update terraform validator version and add policy-library #263

Conversation

daniel-cit
Copy link
Contributor

In this PR:

  • Update of terraform-validator version, for both Jenkins and Cloud Build
  • Scorecard bundle of the policy-library added
  • Browser role added to Jenkins and Cloud Build service accounts
  • Cloud build yaml files and Jenkinsfile updated for location of policy-library and a default project
  • Updates to the READMEs

@morgante @rjerrems @bharathkkb this PR added the bundle created by kpt as is.
Is this approach OK or should we remove files not related to the execution (bundler, cloudbuild, docs, scripts, ...) ?

0-bootstrap/main.tf Outdated Show resolved Hide resolved
policy-library/LICENSE Outdated Show resolved Hide resolved
policy-library/Kptfile Outdated Show resolved Hide resolved
policy-library/README.md Outdated Show resolved Hide resolved
@daniel-cit
Copy link
Contributor Author

The gcp_storage_bucket_policy_only_v1.yam policy is using the deprecated argument bucketPolicyOnly

https://github.com/daniel-cit/terraform-example-foundation/blob/0aad98a3c7aaf5b9526839c6a98e78f4b05ba73b/policy-library/policies/templates/gcp_storage_bucket_policy_only_v1.yaml

        bucket_policy_enabled(bucket) = bucket_policy_enabled {
        	iam_configuration := lib.get_default(bucket, "iamConfiguration", {})
        	bucket_policy_only := lib.get_default(iam_configuration, "bucketPolicyOnly", {})
        	bucket_policy_enabled := lib.get_default(bucket_policy_only, "enabled", null)
        }

which generates a false positive for the bucket created for the logs sink

uniform_bucket_level_access = true

Related issues:

@bharathkkb
Copy link
Member

@daniel-cit could we remove that policy and track it in an issue?

@comment-bot-dev
Copy link

comment-bot-dev commented Jan 25, 2021

Thanks for the PR! 🚀
Unfortunately it looks like some of our CI checks failed. See the Contributing Guide for details.

  • ⚠️check_terraform
    Failed Terraform check. More details below.
Attempting to download /workspace/test/bundle.hcl bundle.
/tmp/bundler /workspace
Fetching Terraform 0.13.5 core package...
Local plugin directory ".plugins" found; scanning for provider binaries.
No ".plugins" directory found, skipping local provider discovery.
Creating terraform_0.13.5-bundle2021012812_linux_amd64.zip ...
All done!
Archive:  terraform_0.13.5-bundle2021012812_linux_amd64.zip
/workspace
Running terraform fmt
Running terraform validate
terraform_validate ./0-bootstrap 
Success!
The configuration is valid.
terraform_validate ./0-bootstrap/modules/jenkins-agent 
Success!
The configuration is valid.
terraform_validate ./1-org/envs/shared 
Success!
The configuration is valid.
terraform_validate ./2-environments/envs/development 
Success!
The configuration is valid.
terraform_validate ./2-environments/envs/non-production 
Success!
The configuration is valid.
terraform_validate ./2-environments/envs/production 
Success!
The configuration is valid.
terraform_validate ./2-environments/modules/env_baseline 
Success!
The configuration is valid.
terraform_validate ./3-networks/envs/development 
Success!
The configuration is valid.
terraform_validate ./3-networks/envs/non-production 
Success!
The configuration is valid.
terraform_validate ./3-networks/envs/production 
Success!
The configuration is valid.
terraform_validate ./3-networks/envs/shared 
Success!
The configuration is valid.
terraform_validate ./3-networks/modules/base_shared_vpc 
Success!
The configuration is valid.
terraform_validate ./3-networks/modules/dedicated_interconnect 
Success!
The configuration is valid.
terraform_validate ./3-networks/modules/restricted_shared_vpc 
Success!
The configuration is valid.
terraform_validate ./3-networks/modules/vpn-ha 
Success!
The configuration is valid.
terraform_validate ./4-projects/business_unit_1/development 
Success!
The configuration is valid.
terraform_validate ./4-projects/business_unit_1/non-production 
Success!
The configuration is valid.
terraform_validate ./4-projects/business_unit_1/production 
Success!
The configuration is valid.
terraform_validate ./4-projects/business_unit_2/development 
Success!
The configuration is valid.
terraform_validate ./4-projects/business_unit_2/non-production 
Success!
The configuration is valid.
terraform_validate ./4-projects/business_unit_2/production 
Success!
The configuration is valid.
terraform_validate ./4-projects/modules/single_project 
Success!
The configuration is valid.
terraform_validate ./test/fixtures/bootstrap 
Success!
The configuration is valid.
terraform_validate ./test/fixtures/envs 
Success!
The configuration is valid.
terraform_validate ./test/fixtures/networks 
There are some problems with the configuration, described below.
The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.
Error: 
Module does not support depends_on
 on main.tf line 30, in module "non-production":
 30:   source                           = 
"../../../3-networks/envs/non-production"
Module "non-production" cannot be used with depends_on because it contains a
nested provider configuration for "google.impersonate", at
../../../3-networks/envs/non-production/providers.tf:21,10-18.
This module can be made compatible with depends_on by changing it to receive
all of its provider configurations from the calling module, by using the
"providers" argument in the calling module block.
Error: 
Module does not support depends_on
 on main.tf line 30, in module "non-production":
 30:   source                           = 
"../../../3-networks/envs/non-production"
Module "non-production" cannot be used with depends_on because it contains a
nested provider configuration for "google", at
../../../3-networks/envs/non-production/providers.tf:40,10-18.
This module can be made compatible with depends_on by changing it to receive
all of its provider configurations from the calling module, by using the
"providers" argument in the calling module block.
Error: 
Module does not support depends_on
 on main.tf line 30, in module "non-production":
 30:   source                           = 
"../../../3-networks/envs/non-production"
Module "non-production" cannot be used with depends_on because it contains a
nested provider configuration for "google-beta", at
../../../3-networks/envs/non-production/providers.tf:45,10-23.
This module can be made compatible with depends_on by changing it to receive
all of its provider configurations from the calling module, by using the
"providers" argument in the calling module block.
Error: 
Module does not support depends_on
 on main.tf line 43, in module "production":
 43:   source                           = 
"../../../3-networks/envs/production"
Module "production" cannot be used with depends_on because it contains a
nested provider configuration for "google.impersonate", at
../../../3-networks/envs/production/providers.tf:21,10-18.
This module can be made compatible with depends_on by changing it to receive
all of its provider configurations from the calling module, by using the
"providers" argument in the calling module block.
Error: 
Module does not support depends_on
 on main.tf line 43, in module "production":
 43:   source                           = 
"../../../3-networks/envs/production"
Module "production" cannot be used with depends_on because it contains a
nested provider configuration for "google", at
../../../3-networks/envs/production/providers.tf:40,10-18.
This module can be made compatible with depends_on by changing it to receive
all of its provider configurations from the calling module, by using the
"providers" argument in the calling module block.
Error: 
Module does not support depends_on
 on main.tf line 43, in module "production":
 43:   source                           = 
"../../../3-networks/envs/production"
Module "production" cannot be used with depends_on because it contains a
nested provider configuration for "google-beta", at
../../../3-networks/envs/production/providers.tf:45,10-23.
This module can be made compatible with depends_on by changing it to receive
all of its provider configurations from the calling module, by using the
"providers" argument in the calling module block.
terraform_validate ./test/fixtures/org 
Success!
The configuration is valid.
terraform_validate ./test/fixtures/projects 
Success!
The configuration is valid.
terraform_validate ./test/setup 
Success!
The configuration is valid.

@rjerrems
Copy link
Collaborator

Hi @amandakarina - it looks like there are some merge conflicts for bootstrap,

Copy link
Collaborator

@rjerrems rjerrems left a comment

Choose a reason for hiding this comment

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

Thanks @amandakarina - it LGTM.. Has this been tested with the foundation end to end?

@bharathkkb - should we consider adding some automated tests to ensure that this is working as expected? (can be done in another PR)

@rjerrems
Copy link
Collaborator

Also lets make sure we squash and merge as there are a tonne of commits

@morgante
Copy link
Contributor

morgante commented Feb 2, 2021

@rjerrems @daniel-cit @bharathkkb Is this ready to merge?

@rjerrems
Copy link
Collaborator

rjerrems commented Feb 3, 2021

I think we can merge @morgante - we will inevitably need to test more thoroughly as a part of the release anyway.

@rjerrems rjerrems merged commit eea9416 into terraform-google-modules:develop Feb 3, 2021
@bharathkkb
Copy link
Member

@rjerrems opened #321 to keep track of testing as part of CI.

bharathkkb pushed a commit that referenced this pull request Mar 30, 2021
Co-authored-by: Amanda Karina Lopes de Oliveira <amandak@ciandt.com>
Co-authored-by: Amanda Karina Lopes de Oliveira <55760933+amandakarina@users.noreply.github.com>
bharathkkb pushed a commit that referenced this pull request Mar 30, 2021
Co-authored-by: Amanda Karina Lopes de Oliveira <amandak@ciandt.com>
Co-authored-by: Amanda Karina Lopes de Oliveira <55760933+amandakarina@users.noreply.github.com>
bharathkkb pushed a commit that referenced this pull request Mar 30, 2021
Co-authored-by: Amanda Karina Lopes de Oliveira <amandak@ciandt.com>
Co-authored-by: Amanda Karina Lopes de Oliveira <55760933+amandakarina@users.noreply.github.com>
bharathkkb pushed a commit that referenced this pull request Mar 31, 2021
Co-authored-by: Amanda Karina Lopes de Oliveira <amandak@ciandt.com>
Co-authored-by: Amanda Karina Lopes de Oliveira <55760933+amandakarina@users.noreply.github.com>
@daniel-cit daniel-cit deleted the update-terrafor-validator-version branch September 2, 2022 23:09
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

6 participants