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

Private ca ga #4919

Merged
merged 16 commits into from
Jun 30, 2021
Merged

Private ca ga #4919

merged 16 commits into from
Jun 30, 2021

Conversation

slevenick
Copy link
Contributor

Fixes: hashicorp/terraform-provider-google#8979

If this PR is for Terraform, I acknowledge that I have:

  • Searched through the issue tracker for an open issue that this either resolves or contributes to, commented on it to claim it, and written "fixes {url}" or "part of {url}" in this PR description. If there were no relevant open issues, I opened one and commented that I would like to work on it (not necessary for very small changes).
  • Generated Terraform, and ran make test and make lint to ensure it passes unit and linter tests.
  • Ensured that all new fields I added that can be set by a user appear in at least one example (for generated resources) or third_party test (for handwritten resources or update tests).
  • Ran relevant acceptance tests (If the acceptance tests do not yet pass or you are unable to run them, please let your reviewer know).
  • Read the Release Notes Guide before writing my release note below.

Release Note Template for Downstream PRs (will be copied)

google_privateca_certificate
google_privateca_certificate_authority
google_privateca_ca_pool
privateca: existing beta resources will no longer function

@google-cla google-cla bot added the cla: yes label Jun 25, 2021
@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 ( 17 files changed, 9137 insertions(+), 234 deletions(-))
Terraform Beta: Diff ( 20 files changed, 6023 insertions(+), 1359 deletions(-))
TF Conversion: Diff ( 7 files changed, 2691 insertions(+))
TF OiCS: Diff ( 11 files changed, 239 insertions(+), 59 deletions(-))

@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 ( 18 files changed, 9376 insertions(+), 234 deletions(-))
Terraform Beta: Diff ( 20 files changed, 6261 insertions(+), 1358 deletions(-))
TF Conversion: Diff ( 7 files changed, 2691 insertions(+))
TF OiCS: Diff ( 11 files changed, 239 insertions(+), 59 deletions(-))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccPrivatecaCaPoolIamBindingGenerated|TestAccPrivatecaCaPoolIamMemberGenerated|TestAccPrivatecaCaPoolIamPolicyGenerated|TestAccPrivatecaCaPool_privatecaCapoolUpdate|TestAccCloudbuildWorkerPool_withNetwork|TestAccContainerNodePool_withGPU|TestAccEventarcTrigger_basic|TestAccEventarcTrigger_transport You can view the result here: https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=193745

@modular-magician
Copy link
Collaborator

Tests failed during RECORDING mode: TestAccPrivatecaCaPoolIamPolicyGenerated|TestAccPrivatecaCaPoolIamMemberGenerated|TestAccPrivatecaCaPoolIamBindingGenerated|TestAccCloudbuildWorkerPool_withNetwork|TestAccContainerNodePool_withGPU Please fix these to complete your PR

@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 ( 18 files changed, 9376 insertions(+), 234 deletions(-))
Terraform Beta: Diff ( 21 files changed, 6262 insertions(+), 1359 deletions(-))
TF Conversion: Diff ( 7 files changed, 2691 insertions(+))
TF OiCS: Diff ( 11 files changed, 239 insertions(+), 59 deletions(-))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccPrivatecaCaPoolIamBindingGenerated|TestAccPrivatecaCaPoolIamMemberGenerated|TestAccPrivatecaCaPoolIamPolicyGenerated|TestAccCloudbuildWorkerPool_withNetwork|TestAccContainerNodePool_withGPU|TestAccPrivatecaCaPool_privatecaCapoolAllFieldsExample|TestAccPrivatecaCaPool_privatecaCapoolBasicExample|TestAccTags You can view the result here: https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=194075

@modular-magician
Copy link
Collaborator

Tests failed during RECORDING mode: TestAccContainerNodePool_withGPU Please fix these to complete your PR

@slevenick slevenick requested review from rileykarson and removed request for rileykarson June 28, 2021 18:32
Copy link
Member

@rileykarson rileykarson left a comment

Choose a reason for hiding this comment

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

I haven't run through the fields to see how well the tests cover them, but I've done a general pass on the resource. Interim comments inline, none of them big.

description: |
Describes values that are relevant in a CA certificate.
properties:
- !ruby/object:Api::Type::Boolean
Copy link
Member

Choose a reason for hiding this comment

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

We can't AtLeastOneOf these, right? Both expect to be able to be omitted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could add Required on is_ca in all cases I think. It would only be settable to false in most cases, except when creating a CertificateAuthority, but that is due to API validation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And setting false explicitly is the same to the API as not sending the value at all

- !ruby/object:Api::Type::NestedObject
name: 'keyUsage'
description: |
Optional. Indicates the intended use for keys that correspond to a certificate.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Optional. Indicates the intended use for keys that correspond to a certificate.
Indicates the intended use for keys that correspond to a certificate.

nit: Implied by the field being optional

name: 'keyUsage'
description: |
Optional. Indicates the intended use for keys that correspond to a certificate.
properties:
Copy link
Member

Choose a reason for hiding this comment

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

Are these subobjects not required when the parent is set? Same w/ their subfields

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not technically, but due to API behavior not returning these when all sub-values are set to false I have added a custom flattener & marked all of these subobjects as required.

I think this is a reasonable way to handle the tricky situation where these fields have slightly different behaviors between the 3 PrivateCA resources although the structure of the objects is almost exactly identical. We could also look into customizediffs, or not allowing objects with all-false values to prevent this in the future without marking these as required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, some of them are actually required depending on the resource.

For example, caOptions.isCa must be set to true for a CertificateAuthority resource.

mmv1/products/privateca/api.yaml Outdated Show resolved Hide resolved
mmv1/products/privateca/api.yaml Show resolved Hide resolved
mmv1/products/privateca/terraform.yaml Show resolved Hide resolved
mmv1/products/privateca/terraform.yaml Outdated Show resolved Hide resolved
mmv1/third_party/terraform/tests/privateca_capool_test.go Outdated Show resolved Hide resolved
mmv1/third_party/terraform/tests/privateca_capool_test.go Outdated Show resolved Hide resolved
mmv1/third_party/terraform/tests/privateca_capool_test.go Outdated Show resolved Hide resolved
@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 ( 19 files changed, 9119 insertions(+), 233 deletions(-))
Terraform Beta: Diff ( 22 files changed, 5901 insertions(+), 1254 deletions(-))
TF Conversion: Diff ( 7 files changed, 2691 insertions(+))
TF OiCS: Diff ( 11 files changed, 244 insertions(+), 59 deletions(-))

@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 ( 19 files changed, 9127 insertions(+), 233 deletions(-))
Terraform Beta: Diff ( 22 files changed, 5909 insertions(+), 1254 deletions(-))
TF Conversion: Diff ( 7 files changed, 2691 insertions(+))
TF OiCS: Diff ( 11 files changed, 244 insertions(+), 59 deletions(-))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccContainerNodePool_withGPU|TestAccPrivatecaCaPool_privatecaCapoolEmptyBaseline|TestAccPrivatecaCertificate_privatecaCertificateNoAuthorityExample|TestAccPrivatecaCertificate_privatecaCertificateConfigExample|TestAccPrivatecaCertificateAuthority_privatecaCertificateAuthorityBasicExample|TestAccPrivatecaCertificate_privatecaCertificateCsrExample You can view the result here: https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=194301

@modular-magician
Copy link
Collaborator

Tests failed during RECORDING mode: TestAccPrivatecaCertificate_privatecaCertificateNoAuthorityExample|TestAccContainerNodePool_withGPU Please fix these to complete your PR

@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 ( 19 files changed, 9207 insertions(+), 233 deletions(-))
Terraform Beta: Diff ( 22 files changed, 5990 insertions(+), 1254 deletions(-))
TF Conversion: Diff ( 7 files changed, 2691 insertions(+))
TF OiCS: Diff ( 11 files changed, 244 insertions(+), 59 deletions(-))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccContainerNodePool_withGPU|TestAccPrivatecaCaPool_privatecaCapoolEmptyBaseline|TestAccPrivatecaCertificate_privatecaCertificateNoAuthorityExample|TestAccPrivatecaCertificate_privatecaCertificateConfigExample|TestAccPrivatecaCertificateAuthority_privatecaCertificateAuthorityBasicExample|TestAccPrivatecaCaPool_privatecaCapoolUpdate|TestAccPrivatecaCertificate_privatecaCertificateCsrExample You can view the result here: https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=194303

@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 ( 19 files changed, 9211 insertions(+), 233 deletions(-))
Terraform Beta: Diff ( 23 files changed, 5995 insertions(+), 1255 deletions(-))
TF Conversion: Diff ( 7 files changed, 2691 insertions(+))
TF OiCS: Diff ( 11 files changed, 244 insertions(+), 59 deletions(-))

@modular-magician
Copy link
Collaborator

Tests failed during RECORDING mode: TestAccPrivatecaCertificate_privatecaCertificateNoAuthorityExample|TestAccContainerNodePool_withGPU Please fix these to complete your PR

@slevenick slevenick requested a review from rileykarson June 29, 2021 21:50
Copy link
Member

@rileykarson rileykarson left a comment

Choose a reason for hiding this comment

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

Did my best at cross-referencing the fields w/ the tests, but really only did a good job @ the first one. Three resources is a lot and +- 2k is pretty hefty! Couple extra comments.

mmv1/products/privateca/api.yaml Show resolved Hide resolved
@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 ( 19 files changed, 9226 insertions(+), 314 deletions(-))
Terraform Beta: Diff ( 23 files changed, 6123 insertions(+), 1449 deletions(-))
TF Conversion: Diff ( 7 files changed, 2691 insertions(+))
TF OiCS: Diff ( 11 files changed, 244 insertions(+), 59 deletions(-))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccContainerNodePool_withGPU|TestAccPrivatecaCertificate_privatecaCertificateNoAuthorityExample|TestAccPrivatecaCaPool_privatecaCapoolUpdate You can view the result here: https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=194306

@modular-magician
Copy link
Collaborator

Tests failed during RECORDING mode: TestAccContainerNodePool_withGPU Please fix these to complete your PR

@modular-magician
Copy link
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccContainerNodePool_withGPU|TestAccPrivatecaCertificate_privatecaCertificateNoAuthorityExample|TestAccPrivatecaCaPool_privatecaCapoolUpdate You can view the result here: https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=194399

@slevenick slevenick requested a review from rileykarson June 30, 2021 17:58
@slevenick
Copy link
Contributor Author

PrivateCA tests pass in VCR!

Copy link

@pmansour pmansour 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 putting this together! sorry for the delay, but I left a bunch of comments

mmv1/products/privateca/terraform.yaml Show resolved Hide resolved
encoder: templates/terraform/encoders/certificate_authority.go.erb
pre_delete: templates/terraform/pre_delete/privateca_certificate_authority.go.erb
decoder: templates/terraform/decoders/treat_deleted_state_as_gone.go.erb
post_create: templates/terraform/post_create/privateca_authority_enable.go.erb

Choose a reason for hiding this comment

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

not sure if this is always going to be a good thing, since CAs are (by default) created in the STAGED state to allow for pre-production validation, and it's not possible to get back to this state after enabling a CA.

Can this auto-enablement behavior be gated by a flag, so that customers who want to keep it STAGED can do so?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a little complicated as it would require manual steps outside of Terraform to enable the CA, or somewhat complicated state management within Terraform itself. It should be possible in the future to enable this via Terraform, but I believe this is a reasonable default behavior at the moment

examples:
- !ruby/object:Provider::Terraform::Examples
name: "privateca_certificate_config"
min_version: "beta"
primary_resource_id: "default"
vars:
certificate_authority_id: "my-certificate-authority"

Choose a reason for hiding this comment

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

in the new v1 resource model it's uncommon to require a CA ID for a certificate, since certificates are nested directly under CaPool resources (not CAs) and the idea is to decouple certs from their specific issuing CAs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This field isn't required, and there is a test that tests this behavior. I think this fits with the new model by allowing the option

description: The name of the CaPool this Certificate Authority belongs to.
required: true
input: true
url_param_only: true
- !ruby/object:Api::Type::String
name: 'name'
description: |
Copy link

Choose a reason for hiding this comment

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

(misplaced comment, should be on line 110)

'tier' is no longer an input field on a CA. it gets set on the CaPool resource and the service copies it to an OUTPUT_ONLY field on each CA within that pool.

description: |
Types of public keys that are supported. At a minimum, we support RSA and ECDSA, for the key sizes or curves listed: https://cloud.google.com/kms/docs/algorithms#asymmetric_signing_algorithms
Types of public keys that are supported. At a minimum, we support RSA, for the key sizes or curves listed: https://cloud.google.com/kms/docs/algorithms#asymmetric_signing_algorithms
Copy link

Choose a reason for hiding this comment

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

perhaps a more accurate description is "the key formats that are supported".

also, FWIW, we still support ECDSA keys. do you know if the "ECDSA" part was dropped from the API or here?

(and same for publicKey.format below)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't look present in the REST API docs, which is why I removed it here


log.Printf("[DEBUG] Enabling CertificateAuthority: %#v", obj)

res, err = sendRequest(config, "POST", billingProject, url, userAgent, nil)
Copy link

Choose a reason for hiding this comment

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

this returns a LongRunningOperation object and doesn't always finish immediately. Do you need to await these operations anywhere before doing something else?

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

Successfully merging this pull request may close these issues.

Rewrite PrivateCA to use GA API
4 participants