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

Create KMS and service account resources for TUF-on-CI #944

Merged
merged 2 commits into from
Jan 17, 2024

Conversation

haydentherapper
Copy link
Contributor

This adds a service account (which will be granted access to a workload identity pool in the private repo), a KMS keyring and key, and grants signerVerifier to the service account.

Summary

Release Note

Documentation

This adds a service account (which will be granted access to a workload
identity pool in the private repo), a KMS keyring and key, and grants
signerVerifier to the service account.

Signed-off-by: Hayden Blauzvern <[email protected]>
@@ -0,0 +1,40 @@
/**
* Copyright 2023 The Sigstore Authors
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
* Copyright 2023 The Sigstore Authors
* Copyright 2024 The Sigstore Authors

@@ -0,0 +1,21 @@
/**
* Copyright 2023 The Sigstore Authors
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
* Copyright 2023 The Sigstore Authors
* Copyright 2024 The Sigstore Authors

Copy link
Member

@cpanato cpanato left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@jku jku left a comment

Choose a reason for hiding this comment

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

Looks good to me. I'm ok with merging this but I have two potential suggestions for consideration:

  • are the variables useful (What's the advantage of choosing non-default sa name or keyring name) ? I left some specific suggestions in code
  • this one I can do in a future PR, no need to include in this PR: It would be useful to add public key viewer permissions, something like
    resource "google_kms_key_ring_iam_member" "tuf-everyone-key-iam" {
      key_ring_id = google_kms_key_ring.tuf-keyring.id
      role        = "roles/cloudkms.publicKeyViewer"
      member      = "allUsers"
      depends_on  = [google_kms_key_ring.tuf-keyring]
    }
    
    (member could be limited to all project members if there's a group like that, but I think allUsers should be fine too...)

*/

resource "google_service_account" "tuf-sa" {
account_id = var.tuf_service_account_name
Copy link
Member

Choose a reason for hiding this comment

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

can we get rid of the variable and parametrize on cluster_name like rekor does:
account_id = format("%s-tuf-sa", var.cluster_name)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cluster_name is related to GKE. I'm not sure what we could parameterize on beyond project name. I decided to add variables for all new fields just in case someone was opinionated on names, but there's a default value for each so no configuration is needed.

Comment on lines +67 to +71
tuf_service_account_name = var.tuf_service_account_name

tuf_keyring_name = var.tuf_keyring_name
tuf_key_name = var.tuf_key_name
kms_location = var.tuf_kms_location
Copy link
Member

@jku jku Jan 17, 2024

Choose a reason for hiding this comment

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

Could we simplify and not expose any of these as variables (except kms_location that seems potentially useful)?

  • service account can be parametrized on cluster name (see other comment)
  • key and keyring name could just be hard coded -- at least I can't see the value of changing them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Given that there's defaults for these, most deployers won't have to think about setting the variables. My thought is that this is just in case someone is opinionated.

Comment on lines +35 to +40
resource "google_kms_key_ring_iam_member" "tuf-sa-key-iam" {
key_ring_id = google_kms_key_ring.tuf-keyring.id
role = "roles/cloudkms.signerVerifier"
member = format("serviceAccount:%s@%s.iam.gserviceaccount.com", var.tuf_service_account_name, var.project_id)
depends_on = [google_kms_key_ring.tuf-keyring, google_service_account.tuf-sa]
}
Copy link
Member

Choose a reason for hiding this comment

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

this looks good to me.

If you decide to remove the service account variable as suggested in other comment, member here would need changing to something like
member = "serviceAccount:${google_service_account.tuf-sa.email}"

@jku
Copy link
Member

jku commented Jan 17, 2024

Some details for others following this:

  • this configuration is added to enable https://github.com/sigstore/root-signing-staging right now. Previously this was done either manually or in the private repository
  • the goal is to have contained configuration that manages the GCP resources that a "root-signing" installation (staging or not) requires.
  • as this is now in a reusable module this config will be usable by (production) root-signing itself later on, but making that happen will require changes in root-signing: currently the equivalent parts in root-signing use several different service accounts and are configured partly manually because historical reasons
  • There's more to do in follow up PRs (like using the new service account for the GCS bucket access too)

@haydentherapper
Copy link
Contributor Author

are the variables useful (What's the advantage of choosing non-default sa name or keyring name) ? I left some specific suggestions in code

Left comments in line, not a must to have, just was easy to add in case someone wants to customize names

this one I can do in a future PR, no need to include in this PR: It would be useful to add public key viewer permissions, something like

For opening up viewer permissions on the key, I've added a variable to specify members who can view the key.

Signed-off-by: Hayden Blauzvern <[email protected]>
@haydentherapper haydentherapper merged commit 18c8742 into sigstore:main Jan 17, 2024
9 checks passed
@haydentherapper haydentherapper deleted the tuf-terraform branch January 17, 2024 23:15
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.

4 participants