js-route-optimization-app
js-route-optimization-app copied to clipboard
Create Maps API Key with Terraform
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_keyresource- Restrict the key's
api_targetsto the following:- Geocoding API
- Maps JavaScript API
- Places API
- Static Maps API
- Do not set any other restrictions
- Restrict the key's
- Store the
key_stringoutput value in the existingmaps_api_keysecret
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_keyinput variable from Terraform and Deployment doc - Include upgrade note that after deploying this version, users can delete their previous manually-created key