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

Complete instructions to deploy Tessera GCP #86

Merged
merged 8 commits into from
Jul 25, 2024

Conversation

phbnf
Copy link
Contributor

@phbnf phbnf commented Jul 24, 2024

This PR also changes the base name from "example-gcp" to "trillian-tessera" since I think it makes more sense as a default value. I'd rather fix this sooner rather than later, but happy to revert this change if you think it's too disruptive.

@phbnf phbnf requested review from mhutchinson and AlCutter July 24, 2024 16:26
@codecov-commenter
Copy link

codecov-commenter commented Jul 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 34.11%. Comparing base (46ec9c2) to head (57bfc12).
Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #86      +/-   ##
==========================================
- Coverage   35.80%   34.11%   -1.69%     
==========================================
  Files          16       16              
  Lines        1363     1407      +44     
==========================================
- Hits          488      480       -8     
- Misses        801      855      +54     
+ Partials       74       72       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -20,6 +20,18 @@ the project:
gcloud auth application-default login
```

Then, specify your Google Cloud project ID:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This GCP specific stuff should probably go into a README in the live/example-gcp directory (my fault - I accidentally put the gcloud line in above)

@@ -20,6 +20,18 @@ the project:
gcloud auth application-default login
```

Then, specify your Google Cloud project ID:
```bash
export GOOGLE_PROJECT={VALUE}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could use this:

export GOOGLE_PROJECT=$(gcloud config get-value project 2> /dev/null)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe that works if you run this command after you've ran gcloud auth from a VM inside a project, but that might not always be the case. Otherwise, how can gcloud know which project it should select? When you authenticate via a web link, it doesn't give you the option to select the project.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sadness :(

Eventually, customize the region (defaults to "us-east1"), and bucket name prefix
(defaults to "tessera"):
```bash
export GOOGLE_REGION={VALUE}
Copy link
Collaborator

Choose a reason for hiding this comment

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

It feels a bit weird to me to have the behaviour of terragrunt be affected by environment vars (I think it's a niggle from "hermetic config as code & checked in" being violated), but:
a) I'm far from a TF/TG expert, and
b) I suppose this is meant to be an easily runnable example and having folks edit config files in a repo is a bit of an anti pattern.

@phbnf phbnf force-pushed the gcloudinstructions branch from 922d679 to 739081d Compare July 24, 2024 16:53

Then, specify your Google Cloud project ID:
```bash
export GOOGLE_PROJECT={VALUE}
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the advantage of doing this with environment variables? It moves away from the the deployment files being fully declarative, which means that two people can check out the same repo and then create different deployments because of inconsistencies in the env naming. It's also more work each time you set up a shell to get back to the same state. The obvious workaround is to create a shell script that sets these values, but then you've just put them in a file, which this change moves away from.

Copy link
Contributor

Choose a reason for hiding this comment

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

Huh, I just saw Al's comments which only appear at the overview screen and not on the "files changed" view. Looks like these comments are somewhat redundant!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moving the conversation here since I looked at this with Al yesterday, and the goal was specifically to get your opinion on it given that you've spent a lot of time looking at Terraform already.

which means that two people can check out the same repo and then create different deployments because of inconsistencies in the env naming.: I think this is a feature, I have my own dev GCP project and I'd like to deploy tessera there. Alternatively, I might want to play around with a deployment in the trillian-tessera project with a CT log, without impacting other folks working on the current existing deployment.

The current setup is already affected by environment variables, the deployment files as they are do not work without setting GOOGLE_PROJECT:

╷
│ Error: Failed to retrieve project, pid: , err: project: required field is not set
│
│   with google_spanner_instance.log_spanner,
│   on main.tf line 52, in resource "google_spanner_instance" "log_spanner":
│   52: resource "google_spanner_instance" "log_spanner" {

This PR doesn't change this behavior, but it's a improvement because now you only have to set your project ID once, and not both in GOOGLE_PROJECT and in terragrunt.hcl. I think it's the smallest change we can make to allow to:

  • fix the current deployment setup
  • have customizations in a single place
  • allow easy customizations for folks no using the default values in this file

I tried two alternatives before sending this PR:

  • not using environment variables, in which case modules/gcs/main.tf needs to be edited to specify the provider and project (which can be passed from terragrunt.hcl). That would allow to have all the config declarative, but folks would have to make sure not to add this file edits to their commits. Al wasn't supper keen on modifying modules/gcs/main.tf nor on making folks edit a config file for running quick examples.
  • using non "reserved" environment variable instead of GOOGLE_PROJECT and GOOGLE_REGION. I thought I'd stick to the defaults ones before customizing things.

I think that another alternative is to use terragrunt to generate the provider config, either with or without making use of environment variables.

What do you recommend?

deployment/live/example-gcp/README.md Outdated Show resolved Hide resolved
project_id = "trillian-tessera"
location = "us-central1"
base_name = "example-gcp"
project_id = get_env("GOOGLE_PROJECT", "trillian-example")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this supposed to be trillian-tessera to match the old version? I think this name is particularly confusing given we have a repo with (almost) this name which is for the old trillian!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Duh. Done, thanks.

@phbnf phbnf force-pushed the gcloudinstructions branch 3 times, most recently from 6003ce4 to 11a3f9c Compare July 25, 2024 14:10
@phbnf phbnf force-pushed the gcloudinstructions branch from 11a3f9c to 57bfc12 Compare July 25, 2024 14:11
deployment/live/example-gcp/README.md Outdated Show resolved Hide resolved
@phbnf phbnf merged commit cf69091 into transparency-dev:main Jul 25, 2024
5 checks passed
@phbnf phbnf deleted the gcloudinstructions branch July 29, 2024 17:48
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