winglang / winglang/wing

Use Application Default Credentials to compile to `tf-gcp` target

Open
#4,359 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

⌨️ cli ☁️ gcp ✨ enhancement needs-discussion
Dominant language
TypeScript
Stars
5.4k
Forks
215
Avg merge
2h 9m
Merged PRs (30d)
27

Description

Feature Spec

Currently Wing allows you to compile to tf-gcp target by manually exporting two env variables called GOOGLE_PROJECT_ID and GOOGLE_REGION, which is not ideal. We should instead follow the standard way to interact with the Google Cloud APIs, which is by using Application Default Credentials (ADC). This is also what HashiCorp docs recommend for the google provider.

The way it works is quite similar to AWS. You have two main options to set up credentials for your project:

  1. You save a JSON file with your credentials locally and then export the GOOGLE_APPLICATION_CREDENTIALS env variable with the path to the file as its value. This is slightly different from AWS where you instead export AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION env variables.

  2. You use the gcloud CLI to generate a JSON credentials file using the gcloud auth application-default login command. This file gets stored at ~/.config/gcloud/application_default_credentials.json. This is practically identical to what the AWS CLI does when using the aws configure command. This would generate a file at the ~/.aws/credentials location.

ADC searches for credentials in the following order:

  1. Check if GOOGLE_APPLICATION_CREDENTIALS env variable is set.
  2. Check if gcloud CLI credentials file exist at ~/.config/gcloud/application_default_credentials.json.
Use Cases

Follow the standard way to interact with Google Cloud APIs.

Implementation Notes

No response

Component

No response

Community Notes
  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the tf-gcp compilation path and the handling of GOOGLE_PROJECT_ID and GOOGLE_REGION. Check the existing tf-gcp tests, if present, and trace how Google Cloud or Terraform provider configuration is assembled. Done means compilation supports GOOGLE_APPLICATION_CREDENTIALS and the gcloud ADC file location instead of requiring the two manual environment variables.

Written by the indexing model from the issue text.

Assessment

Tech stack
google-cloud, terraform
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.