-
Notifications
You must be signed in to change notification settings - Fork 526
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
infrasys: create TUF infra in AWS using cargo make create-infra
#1723
Conversation
6ea4f47
to
788eebc
Compare
cargo make create-infra
.context(error::MissingConfig { | ||
missing: "config field for a kms key", | ||
})? | ||
.create_kms_keys() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decided to make create_kms_keys a trait of the config so users aren't surprised when config fields are changed. We also considered passing a mutable reference to config to create_kms_keys(), but thought this way was more clear.
); | ||
} | ||
|
||
// Set key_id using a publication key (if one is not already provided) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided to set key_id in this method as it's the only one that differentiates roles (we only want key_id to be set for publication keys, not root keys)
79b3377
to
1504ebd
Compare
Pushes above add some extra tests and make minor changes to existing ones:
|
Push above addresses warnings raised by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we talked about this at some point and now is a good time to do it:
In addition to just setting up the Infrastructure, we should also test out whether we're able to use said infrastructure to actually update a live Bottlerocket host with a custom TUF repository. We should include that in the testing description since that's the ultimate goal.
Push above addresses etungsten's comments (and includes a small fix for default prefixes) |
Push above makes a small change to bucket policy tests |
Push above adds a new commit that checks if a lock file exists or not (signaling users to clean up resources and re-run infrasys accordingly) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only made it through main.rs today. It looks good. Most of what I have are little things not impacting correctness/design.
Push above adds further pubsys integration for InfraConfig::from_path_or_default usage (not just InfraConfig::from_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Publishing what I have for now.
tools/infrasys/src/error.rs
Outdated
}, | ||
|
||
#[snafu(display("Failed to get parent of path: {}", path.display()))] | ||
Parent { path: PathBuf }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least in practice - this seems to crossover with the Path
error variant above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking that if there's an issue with the parent() method in specific, might be nice to know where the error is coming from instead of a general "invalid path"?
For some reason if rust's parent() method breaks, we would be able to catch it here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having a separate error variant for this makes sense. The path itself isn't necessarily invalid, it's just that it doesn't have a parent (e.g. it might be /
).
tools/infrasys/src/main.rs
Outdated
} | ||
|
||
async fn check_infra_lock(toml_path: &Path) -> Result<()> { | ||
let lock_path = toml_path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels odd to me to have a function that's checking for the existence of a file, but the argument is a different file. Perhaps we can determine lock_path
beforehand, and pass it to this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We wanted to make sure that users weren't able to change where the lock file lived (should always live next to Infra.toml). If we pass it in via commandline, we would do this path splicing in the Makefile. We were thinking it would be easier to do via code inside main.rs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still have a lot left to get through!
But the main theme of this pass is that there is some duplicate code involving the loading of either Infra.toml
or Infra.lock
.
It's great when files in a PR have more red than green and there is an opportunity to make that happen here in all the files that need to load either toml
or lock
.
4476a6f
to
a381871
Compare
Push above addresses initial webern and zmrow comments |
a381871
to
b6a72eb
Compare
Push above addresses webern code duplication concerns with pubsys-integration code |
b6a72eb
to
6c03125
Compare
Push above removes |
6c03125
to
fd13108
Compare
Push above adds KMSClient code to pubsys-integration commit |
fd13108
to
a716b48
Compare
Push above adds webern's code to clean up tools/pubsys-setup/src/main.rs diff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's getting close, Nice work!
Adds binary (and supporting files) to automatically spin up TUF infra (S3 Bucket+Policy, KMS Keys, and populated root.json) across multiple regions in a single account. Edits pubsys-config (and supporting files) to accomodate new infrasys fields in Infra.toml.
6ded81d
to
ce71a76
Compare
Push addresses webern comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
Issue number:
N/A
Description of changes:
create-infra
andcheck-infra-lock
. This PR is the implementation ofcreate-infra
.main.rs
, which uses helper methods from other modules (keys.rs
[creating keys],s3.rs
[creating s3 bucket, adding bucket policy, uploading objects],shared.rs
[helper methods used in all files],errors.rs
[a single error file shared by all files], androot.rs
[creating root, adding keys to it, signing it]).main.rs
reads from Infra.toml using pubsys-config (thus edits to a few files under pubsys-config and pubsys were required) and outputs Infra.lock in yaml (we used yaml to serialize the config because we were unable to serialize enums with structs within them in toml).Testing done:
Added a unit test for for struct -> toml -> struct -> yaml -> struct conversion (main.rs), prefix format checking (s3.rs), and bucket policy insertion (s3.rs)
Created several test Infra.toml files with various combinations of configurations and ensured that errors were thrown / the resources showed up in the correct region, with the correct settings, in my account
Example of a test where we're creating a root + signing keys
Infra.toml
cargo make create-infra output
Infra.lock
root.json
Resources show up correctly in my account (root.json populated in s3 bucket, all public access off for s3 bucket, correct bucket policy, kms keys present)
Completed E2E testing (cargo make, cargo make repo, cargo make ami, pulling updates)
Draft Review:
Here are some initial reviews that etungsten left and were addressed: aashnasheth#9
Next PR:
check-infra-lock
(which will check the existence of the lock file and advise users to clean up resources if needed)Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.