googleApikeysKey
The Apikeys Key resource
Example Usage - android_key
A basic example of a android api keys key
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleProjectBasic = new google.project.Project(this, "basic", {
name: "app",
org_id: "123456789",
project_id: "app",
});
new google.apikeysKey.ApikeysKey(this, "primary", {
display_name: "sample-key",
name: "key",
project: googleProjectBasic.name,
restrictions: [
{
android_key_restrictions: [
{
allowed_applications: [
{
package_name: "com.example.app123",
sha1_fingerprint: "1699466a142d4682a5f91b50fdf400f2358e2b0b",
},
],
},
],
api_targets: [
{
methods: ["GET*"],
service: "translate.googleapis.com",
},
],
},
],
});
Example Usage - basic_key
A basic example of a api keys key
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleProjectBasic = new google.project.Project(this, "basic", {
name: "app",
org_id: "123456789",
project_id: "app",
});
new google.apikeysKey.ApikeysKey(this, "primary", {
display_name: "sample-key",
name: "key",
project: googleProjectBasic.name,
restrictions: [
{
api_targets: [
{
methods: ["GET*"],
service: "translate.googleapis.com",
},
],
browser_key_restrictions: [
{
allowed_referrers: [".*"],
},
],
},
],
});
Example Usage - ios_key
A basic example of a ios api keys key
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleProjectBasic = new google.project.Project(this, "basic", {
name: "app",
org_id: "123456789",
project_id: "app",
});
new google.apikeysKey.ApikeysKey(this, "primary", {
display_name: "sample-key",
name: "key",
project: googleProjectBasic.name,
restrictions: [
{
api_targets: [
{
methods: ["GET*"],
service: "translate.googleapis.com",
},
],
ios_key_restrictions: [
{
allowed_bundle_ids: ["com.google.app.macos"],
},
],
},
],
});
Example Usage - minimal_key
A minimal example of a api keys key
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleProjectBasic = new google.project.Project(this, "basic", {
name: "app",
org_id: "123456789",
project_id: "app",
});
new google.apikeysKey.ApikeysKey(this, "primary", {
display_name: "sample-key",
name: "key",
project: googleProjectBasic.name,
});
Example Usage - server_key
A basic example of a server api keys key
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleProjectBasic = new google.project.Project(this, "basic", {
name: "app",
org_id: "123456789",
project_id: "app",
});
new google.apikeysKey.ApikeysKey(this, "primary", {
display_name: "sample-key",
name: "key",
project: googleProjectBasic.name,
restrictions: [
{
api_targets: [
{
methods: ["GET*"],
service: "translate.googleapis.com",
},
],
server_key_restrictions: [
{
allowed_ips: ["127.0.0.1"],
},
],
},
],
});
Argument Reference
The following arguments are supported:
name
- (Required) The resource name of the key. The name must be unique within the project, must conform with RFC-1034, is restricted to lower-cased letters, and has a maximum length of 63 characters. In another word, the name must match the regular expression:[aZ]([aZ09-]{0,61}[aZ09])?
.
The allowedApplications
block supports:
-
packageName
- (Required) The package name of the application. -
sha1Fingerprint
- (Required) The SHA1 fingerprint of the application. For example, both sha1 formats are acceptable : DA:39:A3:EE:5E:6B:4B:0D:32:55:BF:EF:95:60:18:90:AF:D8:07:09 or DA39A3EE5E6B4B0D3255BFEF95601890AFD80709. Output format is the latter.
-
displayName
- (Optional) Human-readable display name of this API key. Modifiable by user. -
project
- (Optional) The project for the resource -
restrictions
- (Optional) Key restrictions.
The restrictions
block supports:
-
androidKeyRestrictions
- (Optional) The Android apps that are allowed to use the key. -
apiTargets
- (Optional) A restriction for a specific service and optionally one or more specific methods. Requests are allowed if they match any of these restrictions. If no restrictions are specified, all targets are allowed. -
browserKeyRestrictions
- (Optional) The HTTP referrers (websites) that are allowed to use the key. -
iosKeyRestrictions
- (Optional) The iOS apps that are allowed to use the key. -
serverKeyRestrictions
- (Optional) The IP addresses of callers that are allowed to use the key.
The androidKeyRestrictions
block supports:
allowedApplications
- (Required) A list of Android applications that are allowed to make API calls with this key.
The apiTargets
block supports:
-
methods
- (Optional) Optional. List of one or more methods that can be called. If empty, all methods for the service are allowed. A wildcard (*) can be used as the last symbol. Valid examples:googleCloudTranslateV2TranslateServiceGetSupportedLanguage
translateText
get*
translateGoogleapisComGet*
-
service
- (Required) The service for this restriction. It should be the canonical service name, for example:translateGoogleapisCom
. You can usegcloudServicesList
to get a list of services that are enabled in the project.
The browserKeyRestrictions
block supports:
allowedReferrers
- (Required) A list of regular expressions for the referrer URLs that are allowed to make API calls with this key.
The iosKeyRestrictions
block supports:
allowedBundleIds
- (Required) A list of bundle IDs that are allowed when making API calls with this key.
The serverKeyRestrictions
block supports:
allowedIps
- (Required) A list of the caller IP addresses that are allowed to make API calls with this key.
Attributes Reference
In addition to the arguments listed above, the following computed attributes are exported:
-
id
- an identifier for the resource with formatprojects/{{project}}/locations/global/keys/{{name}}
-
keyString
- Output only. An encrypted and signed value held by this key. This field can be accessed only through thegetKeyString
method. -
uid
- Output only. Unique id in UUID4 format.
Timeouts
This resource provides the following Timeouts configuration options:
create
- Default is 20 minutes.update
- Default is 20 minutes.delete
- Default is 20 minutes.
Import
Key can be imported using any of these accepted formats: