js-route-optimization-app icon indicating copy to clipboard operation
js-route-optimization-app copied to clipboard

Create Maps API Key with Terraform

Open cmorabito-woolpert opened this issue 1 year ago • 0 comments

API Keys can now be managed with Terraform via API Keys API. This could eliminate the need to manually create an API Key during project setup.

Reference: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/apikeys_key

  • Enable API Keys API (apikeys.googleapis.com)
  • Define a new google_apikeys_key resource
    • Restrict the key's api_targets to the following:
      • Geocoding API
      • Maps JavaScript API
      • Places API
      • Static Maps API
    • Do not set any other restrictions
  • Store the key_string output value in the existing maps_api_key secret

After defining an google_apikeys_key resource:

  • Remove the manual "Create a Google Maps API Key" step in Project Setup doc
  • Remove the maps_api_key input variable from Terraform and Deployment doc
  • Include upgrade note that after deploying this version, users can delete their previous manually-created key

cmorabito-woolpert avatar Apr 04 '24 17:04 cmorabito-woolpert