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

when using WLIF getting error : "missing field client_id" #28

Open
rojomisin opened this issue Nov 17, 2023 · 1 comment
Open

when using WLIF getting error : "missing field client_id" #28

rojomisin opened this issue Nov 17, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@rojomisin
Copy link

I'm running gcs-rsync from an ec2 instance which auth's w/ gcp via workload identity.

How would I set the GOOGLE_CLIENT_ID or client_id?

gcs-rsync -u gs://bucket-name/file.test /tmp

Error: StorageError(GcsTokenError(HttpError(reqwest::Error { kind: Request, url: Url { scheme: "http", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("metadata.google.internal")), port: None, path: "/computeMetadata/v1/instance/service-accounts/default/token", query: None, fragment: None }, source: hyper::Error(Connect, ConnectError("dns error", Custom { kind: Uncategorized, error: "failed to lookup address information: Name or service not known" })) })))

gcs-rsync -u gs://bucket-name/file.test /tmp

Error: StorageError(GcsTokenError(EnvVarError { key: "GOOGLE_APPLICATION_CREDENTIALS", error: NotPresent }))
[ec2-user@ip-10-50-5-146 ~]$ export GOOGLE_APPLICATION_CREDENTIALS=/home/ec2-user/credentials.json
You have new mail in /var/spool/mail/ec2-user

gcs-rsync -u gs://bucket-name/file.test /tmp

Error: StorageError(GcsTokenError(DeserializationError { expected_type: "gcs_rsync::gcp::oauth2::token::AuthorizedUserCredentials", error: Error("missing field `client_id`", line: 14, column: 1) }))

cat credentials.json

{
  "type": "external_account",
  "audience": "//iam.googleapis.com/projects/<my-project-id-number>/locations/global/workloadIdentityPools/amzn/providers/aws-provider",
  "subject_token_type": "urn:ietf:params:aws:token-type:aws4_request",
  "token_url": "https://sts.googleapis.com/v1/token",
  "credential_source": {
    "environment_id": "aws1",
    "region_url": "http://169.254.169.254/latest/meta-data/placement/availability-zone",
    "url": "http://169.254.169.254/latest/meta-data/iam/security-credentials",
    "regional_cred_verification_url": "https://sts.{region}.amazonaws.com?Action=GetCallerIdentity&Version=2011-06-15",
    "imdsv2_session_token_url": "http://169.254.169.254/latest/api/token"
  },
  "service_account_impersonation_url": "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/[email protected]:generateAccessToken"
}
@cboudereau
Copy link
Owner

cboudereau commented Nov 21, 2023

Hi.

Thank you for the quality of that issue.

You can use authorized user or service account json.
Those methods work on CI and local box for instance.

According to gcp doc, it seems that your aws ec2 is running out of gcp.

This is why the Google Metadata api is not available (ec2 is on aws).

Actually, gcp Metadata api, authorized user and service account auth are available. So do not use the -u flag instead use the env var
GOOGLE_APPLICATION_CREDENTIALS=./credentials.json

To create the credentials.json file, you can follow this setup:
https://github.com/cboudereau/gcs-rsync/tree/main/src/gcp/oauth2

In my previous experience, we were using vault or secret manager.

I am gonna check how to use the oauth external_account (from your json files) to plan a new oauth integration in the future.

@cboudereau cboudereau self-assigned this Dec 3, 2023
@cboudereau cboudereau added the enhancement New feature or request label Dec 3, 2023
@cboudereau cboudereau added enhancement New feature or request and removed enhancement New feature or request labels Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants