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

feat: Add encrypted .env creds #475

Merged
merged 3 commits into from
Nov 16, 2022
Merged

feat: Add encrypted .env creds #475

merged 3 commits into from
Nov 16, 2022

Conversation

kgpayne
Copy link
Contributor

@kgpayne kgpayne commented Nov 7, 2022

@kgpayne kgpayne temporarily deployed to test November 7, 2022 16:34 Inactive
@kgpayne kgpayne temporarily deployed to test November 7, 2022 16:34 Inactive
@kgpayne kgpayne temporarily deployed to test November 7, 2022 16:34 Inactive
@kgpayne kgpayne temporarily deployed to test November 7, 2022 16:41 Inactive
@kgpayne kgpayne temporarily deployed to test November 7, 2022 16:41 Inactive
@kgpayne kgpayne temporarily deployed to test November 7, 2022 16:41 Inactive
@kgpayne kgpayne temporarily deployed to test November 7, 2022 16:41 Inactive
@kgpayne kgpayne temporarily deployed to test November 7, 2022 16:41 Inactive
@kgpayne kgpayne temporarily deployed to test November 7, 2022 16:41 Inactive
@kgpayne kgpayne temporarily deployed to test November 7, 2022 16:41 Inactive
@kgpayne kgpayne temporarily deployed to test November 7, 2022 16:41 Inactive
@kgpayne
Copy link
Contributor Author

kgpayne commented Nov 7, 2022

@aaronsteers I have tested this with a publickey from the sandbox account and, as expected, our Google Analytics credentials are too long to fit into one ciphertext. I have created this issue to track chunking long plaintext into arrays of ciphertexts in secrets.yml, but we need not necessarily block on it.

@kgpayne kgpayne temporarily deployed to test November 7, 2022 16:48 Inactive
@kgpayne kgpayne temporarily deployed to test November 7, 2022 17:04 Inactive
@aaronsteers
Copy link
Contributor

aaronsteers commented Nov 8, 2022

Confirmed:

  • We don't have a critical dependency on google analytics data as of now, so we can ignore the GA creds issue as of now.

Related:

Still TBD/TODO:

  • How to deliver the public key (.pem file or similar) to the project owner. @magreenbaum - any thoughts on this?
  • Even if using a short-term approach, can we get Ken a public key for the squared project today or tomorrow?

cc @magreenbaum, @WillDaSilva

@magreenbaum
Copy link

magreenbaum commented Nov 8, 2022

How to deliver the public key (.pem file or similar) to the project owner. @magreenbaum - any thoughts on this?

Maybe a meltano command that downloads it. I would just need to add kms:GetPublicKey permissions for the container. https://docs.aws.amazon.com/kms/latest/APIReference/API_GetPublicKey.html

@magreenbaum
Copy link

Even if using a short-term approach, can we get Ken a public key for the squared project today or tomorrow?

We can manually generate a KMS key for now or we can deploy the infra off https://github.com/meltano/dragon-infra/pull/91 and see how it goes in the new staging account. Right now nothing is deployed in staging.

@magreenbaum
Copy link

I've got this PR deployed into our new staging account. If it looks good to everyone, I'll merge it and share the public key with @kgpayne. cc @aaronsteers

@kgpayne kgpayne temporarily deployed to test November 15, 2022 16:37 Inactive
@kgpayne kgpayne temporarily deployed to test November 15, 2022 16:37 Inactive
@kgpayne kgpayne temporarily deployed to test November 15, 2022 16:37 Inactive
@kgpayne kgpayne marked this pull request as ready for review November 15, 2022 16:38
pnadolny13
pnadolny13 previously approved these changes Nov 15, 2022
Copy link
Contributor

@pnadolny13 pnadolny13 left a comment

Choose a reason for hiding this comment

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

@kgpayne this looks great!

As a side not since I'm curious - are we expecting to have one of these secrets.yml files for each meltano environment? It would be really helpful in CI to just pull secrets from KMS vs storing them in GitHubs secret store. Having a secrets key attached to each meltano env seems super useful, each slightly different than each other.

@@ -85,3 +85,7 @@ environments:
AIRFLOW__SCHEDULER__DAG_DIR_LIST_INTERVAL: '30'
AIRFLOW_VAR_MELTANO_ENVIRONMENT: userdev
AIRFLOW_VAR_OPERATOR_TYPE: bash
# Secrets via KMS
Copy link
Contributor

Choose a reason for hiding this comment

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

@kgpayne are these env variables required in the other meltano environments (cicd/staging/prod) as well?

data/secrets.yml Show resolved Hide resolved
@pnadolny13
Copy link
Contributor

@aaronsteers I have tested this with a publickey from the sandbox account and, as expected, our Google Analytics credentials are too long to fit into one ciphertext. I have created meltano/kms-ext#1 to track chunking long plaintext into arrays of ciphertexts in secrets.yml, but we need not necessarily block on it.

@kgpayne I'm not sure what the size limit is exactly but fwiw we could split the TAP_GOOGLE_ANALYTICS_CLIENT_SECRETS secret into its parts using the dot syntax so they live in the meltano.yml file since most of them arent sensitive, like:

      client_secrets:
        type: service_account
        token_uri: https://oauth2.googleapis.com/token

and only leave the truly secret sections like private_key and private_key_id? The private key in that GA credentials json is almost 1800 characters in itself so thats mostly the problem.

Co-authored-by: Will Da Silva <[email protected]>
@aaronsteers aaronsteers temporarily deployed to test November 16, 2022 19:18 Inactive
@aaronsteers aaronsteers temporarily deployed to test November 16, 2022 19:18 Inactive
@aaronsteers aaronsteers temporarily deployed to test November 16, 2022 19:18 Inactive
@aaronsteers
Copy link
Contributor

https://github.com/meltano/squared/actions/runs/3482409891/jobs/5824784907

2022-11-16T19:28:26.430364Z [info     ] 19:28:26  Database Error in test source_unique_tap_spreadsheets_anywhere_azure_ips_id (snapshots/spreadsheets_anywhere/sources.yml) cmd_type=command name=dbt-snowflake stdio=stderr
2022-11-16T19:28:26.431071Z [info     ] 19:28:26    002003 (42S02): SQL compilation error: cmd_type=command name=dbt-snowflake stdio=stderr
2022-11-16T19:28:26.431896Z [info     ] 19:28:26    Object 'CICD_RAW.BFBC13D0FB1F7549736BC8FFF3A544484D893C035_TAP_SPREADSHEETS_ANYWHERE.AZURE_IPS' does not exist or not authorized. cmd_type=command name=dbt-snowflake stdio=stderr

@pnadolny13
Copy link
Contributor

pnadolny13 commented Nov 16, 2022

@aaronsteers related to the failing test I created #480 that should fix it, once thats pulled in this PR should pass. Optionally since this is high priority we can force merge since this PR doesnt affect anything thats being tested anyways.

#354 is the actual issue that periodically causes the test to fail since we dont have a way to dynamically generate the url yet.

@aaronsteers aaronsteers merged commit 9f1fb04 into main Nov 16, 2022
@aaronsteers aaronsteers deleted the kgpayne/issue463 branch November 16, 2022 21:57
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.

Add encrypted .env creds
5 participants