Skip to content

Commit

Permalink
Add apikeys key resource (#5637)
Browse files Browse the repository at this point in the history
* Add apikeys key resource

* Update branch

* Update go.mod & sum for required fields
  • Loading branch information
slevenick authored Mar 9, 2022
1 parent c0f2424 commit 7edb8ba
Show file tree
Hide file tree
Showing 29 changed files with 1,047 additions and 14 deletions.
2 changes: 1 addition & 1 deletion mmv1/third_party/terraform/go.mod.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module github.com/hashicorp/terraform-provider-google<%= "-" + version unless ve
require (
cloud.google.com/go/bigtable v1.10.1
cloud.google.com/go/iam v0.1.1 // indirect
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220225200700-e76d50f1e637
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220304175357-35332d17a512
github.com/apparentlymart/go-cidr v1.1.0
github.com/client9/misspell v0.3.4
github.com/davecgh/go-spew v1.1.1
Expand Down
4 changes: 3 additions & 1 deletion mmv1/third_party/terraform/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1530,4 +1530,6 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220225200700-e76d50f1e637 h1:+s2wWcAciNo96AT+Ci9pwXuWm9qlY/ubLFWRaqE0tZg=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220225200700-e76d50f1e637/go.mod h1:UJoDYx6t3+xCOd+dZX8+NrEB+Y/eW1pQlvxh2Gt7y5E=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220225200700-e76d50f1e637/go.mod h1:UJoDYx6t3+xCOd+dZX8+NrEB+Y/eW1pQlvxh2Gt7y5E=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220304175357-35332d17a512 h1:8/Sn9pDdk/RxECtLUh4xum2eyUvf0h7bpx8h+lYvE+Q=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220304175357-35332d17a512/go.mod h1:UJoDYx6t3+xCOd+dZX8+NrEB+Y/eW1pQlvxh2Gt7y5E=
1 change: 1 addition & 0 deletions mmv1/third_party/terraform/utils/config.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ type Config struct {
NetworkConnectivityBasePath string
OrgPolicyBasePath string
RecaptchaEnterpriseBasePath string
ApikeysBasePath string
<% if version == 'private' -%>
VmwareBasePath string
<% end -%>
Expand Down
3 changes: 3 additions & 0 deletions mmv1/third_party/terraform/utils/provider.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ func Provider() *schema.Provider {
RecaptchaEnterpriseEndpointEntryKey: RecaptchaEnterpriseEndpointEntry,
ContainerAwsCustomEndpointEntryKey: ContainerAwsCustomEndpointEntry,
ContainerAzureCustomEndpointEntryKey: ContainerAzureCustomEndpointEntry,
ApikeysEndpointEntryKey: ApikeysEndpointEntry,

<% if version == "private" -%>
VmwareEndpointEntryKey: VmwareEndpointEntry,
Expand Down Expand Up @@ -465,6 +466,7 @@ end # products.each do
},
// resources implemented within tpgtools
map[string]*schema.Resource{
"google_apikeys_key": resourceApikeysKey(),
"google_assured_workloads_workload": resourceAssuredWorkloadsWorkload(),
"google_cloudbuild_worker_pool": resourceCloudbuildWorkerPool(),
"google_compute_firewall_policy_association": resourceComputeFirewallPolicyAssociation(),
Expand Down Expand Up @@ -665,6 +667,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
config.BigtableAdminBasePath = d.Get(BigtableAdminCustomEndpointEntryKey).(string)

// dcl
config.ApikeysBasePath = d.Get(ApikeysEndpointEntryKey).(string)
config.AssuredWorkloadsBasePath = d.Get(AssuredWorkloadsEndpointEntryKey).(string)
config.CloudResourceManagerBasePath = d.Get(CloudResourceManagerEndpointEntryKey).(string)
config.EventarcBasePath = d.Get(EventarcEndpointEntryKey).(string)
Expand Down
Empty file.
21 changes: 21 additions & 0 deletions tpgtools/api/apikeys/samples/android.key.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "{{key}}",
"project": "{{ref:basic.cloudresourcemanager.project.json:name}}",
"displayName": "sample-key",
"restrictions": {
"androidKeyRestrictions": {
"allowedApplications": [
{
"packageName": "com.example.app123",
"sha1Fingerprint": "1699466a142d4682a5f91b50fdf400f2358e2b0b"
}
]
},
"apiTargets": [
{
"service": "translate.googleapis.com",
"methods": ["GET*"]
}
]
}
}
34 changes: 34 additions & 0 deletions tpgtools/api/apikeys/samples/android_key.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: android_key
description: A basic example of a android api keys key
type: key
versions:
- ga
resource: samples/android.key.json
dependencies:
- samples/basic.cloudresourcemanager.project.json
updates:
- resource: samples/android_update.key.json
dependencies:
- samples/basic.cloudresourcemanager.project.json
variables:
- name: app
type: resource_name
- name: billing_account
type: billing_account
- name: key
type: resource_name
- name: org_id
type: org_id
21 changes: 21 additions & 0 deletions tpgtools/api/apikeys/samples/android_update.key.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "{{key}}",
"project": "{{ref:basic.cloudresourcemanager.project.json:name}}",
"displayName": "sample-key",
"restrictions": {
"androidKeyRestrictions": {
"allowedApplications": [
{
"packageName": "com.example.app124",
"sha1Fingerprint": "1cf89aa28625da86a7e5a7550cf7fd33d611f6fd"
}
]
},
"apiTargets": [
{
"service": "translate.googleapis.com",
"methods": ["GET*"]
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "apikeys.googleapis.com",
"project": "{{ref:basic.cloudresourcemanager.project.json:name}}",
"state": "ENABLED"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "{{ref:basic.cloudresourcemanager.project.json:name}}",
"billingAccountName": "{{billing_account}}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "{{app}}",
"parent": "organizations/{{org_id}}"
}
16 changes: 16 additions & 0 deletions tpgtools/api/apikeys/samples/basic.key.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "{{key}}",
"project": "{{ref:basic.cloudresourcemanager.project.json:name}}",
"displayName": "sample-key",
"restrictions": {
"browserKeyRestrictions": {
"allowedReferrers": [".*"]
},
"apiTargets": [
{
"service": "translate.googleapis.com",
"methods": ["GET*"]
}
]
}
}
34 changes: 34 additions & 0 deletions tpgtools/api/apikeys/samples/basic_key.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: basic_key
description: A basic example of a api keys key
type: key
versions:
- ga
resource: samples/basic.key.json
dependencies:
- samples/basic.cloudresourcemanager.project.json
updates:
- resource: samples/update.key.json
dependencies:
- samples/basic.cloudresourcemanager.project.json
variables:
- name: app
type: resource_name
- name: billing_account
type: billing_account
- name: key
type: resource_name
- name: org_id
type: org_id
16 changes: 16 additions & 0 deletions tpgtools/api/apikeys/samples/ios.key.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "{{key}}",
"project": "{{ref:basic.cloudresourcemanager.project.json:name}}",
"displayName": "sample-key",
"restrictions": {
"iosKeyRestrictions": {
"allowedBundleIds": ["com.google.app.macos"]
},
"apiTargets": [
{
"service": "translate.googleapis.com",
"methods": ["GET*"]
}
]
}
}
34 changes: 34 additions & 0 deletions tpgtools/api/apikeys/samples/ios_key.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: ios_key
description: A basic example of a ios api keys key
type: key
versions:
- ga
resource: samples/ios.key.json
dependencies:
- samples/basic.cloudresourcemanager.project.json
updates:
- resource: samples/ios_update.key.json
dependencies:
- samples/basic.cloudresourcemanager.project.json
variables:
- name: app
type: resource_name
- name: billing_account
type: billing_account
- name: key
type: resource_name
- name: org_id
type: org_id
16 changes: 16 additions & 0 deletions tpgtools/api/apikeys/samples/ios_update.key.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "{{key}}",
"project": "{{ref:basic.cloudresourcemanager.project.json:name}}",
"displayName": "sample-key",
"restrictions": {
"iosKeyRestrictions": {
"allowedBundleIds": ["com.google.alex.ios"]
},
"apiTargets": [
{
"service": "translate.googleapis.com",
"methods": ["GET*"]
}
]
}
}
5 changes: 5 additions & 0 deletions tpgtools/api/apikeys/samples/minimal.key.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "{{key}}",
"project": "{{ref:basic.cloudresourcemanager.project.json:name}}",
"displayName": "sample-key"
}
30 changes: 30 additions & 0 deletions tpgtools/api/apikeys/samples/minimal_key.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: minimal_key
description: A minimal example of a api keys key
type: key
versions:
- ga
resource: samples/minimal.key.json
dependencies:
- samples/basic.cloudresourcemanager.project.json
variables:
- name: app
type: resource_name
- name: billing_account
type: billing_account
- name: key
type: resource_name
- name: org_id
type: org_id
16 changes: 16 additions & 0 deletions tpgtools/api/apikeys/samples/server.key.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "{{key}}",
"project": "{{ref:basic.cloudresourcemanager.project.json:name}}",
"displayName": "sample-key",
"restrictions": {
"serverKeyRestrictions": {
"allowedIps": ["127.0.0.1"]
},
"apiTargets": [
{
"service": "translate.googleapis.com",
"methods": ["GET*"]
}
]
}
}
34 changes: 34 additions & 0 deletions tpgtools/api/apikeys/samples/server_key.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: server_key
description: A basic example of a server api keys key
type: key
versions:
- ga
resource: samples/server.key.json
dependencies:
- samples/basic.cloudresourcemanager.project.json
updates:
- resource: samples/server_update.key.json
dependencies:
- samples/basic.cloudresourcemanager.project.json
variables:
- name: app
type: resource_name
- name: billing_account
type: billing_account
- name: key
type: resource_name
- name: org_id
type: org_id
16 changes: 16 additions & 0 deletions tpgtools/api/apikeys/samples/server_update.key.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "{{key}}",
"project": "{{ref:basic.cloudresourcemanager.project.json:name}}",
"displayName": "sample-key",
"restrictions": {
"serverKeyRestrictions": {
"allowedIps": ["127.0.0.2", "192.168.1.1"]
},
"apiTargets": [
{
"service": "translate.googleapis.com",
"methods": ["GET*"]
}
]
}
}
16 changes: 16 additions & 0 deletions tpgtools/api/apikeys/samples/update.key.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name":"{{key}}",
"project": "{{ref:basic.cloudresourcemanager.project.json:name}}",
"displayName": "sample-key-update",
"restrictions": {
"browserKeyRestrictions": {
"allowedReferrers": [".*com"]
},
"apiTargets": [
{
"service": "maps.googleapis.com",
"methods": ["POST*"]
}
]
}
}
2 changes: 1 addition & 1 deletion tpgtools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.16

require (
bitbucket.org/creachadair/stringset v0.0.9
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220225200700-e76d50f1e637
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20220304175357-35332d17a512
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/hashicorp/errwrap v1.0.0
github.com/hashicorp/hcl v1.0.0
Expand Down
Loading

0 comments on commit 7edb8ba

Please sign in to comment.