winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
4.77k stars 189 forks source link

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

Open garysassano opened 9 months ago

garysassano commented 9 months ago

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

github-actions[bot] commented 7 months ago

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

github-actions[bot] commented 5 months ago

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

github-actions[bot] commented 1 month ago

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!