Skip to content

Commit

Permalink
api-gateway gcp
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesWoolfenden committed Jan 30, 2024
1 parent 9f15702 commit 384990e
Show file tree
Hide file tree
Showing 22 changed files with 261 additions and 14 deletions.
15 changes: 1 addition & 14 deletions src/coverage/google.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
# todo google

Resource percentage coverage 14.13
Resource percentage coverage 15.78
Datasource percentage coverage 91.35

./resource.ps1 google_access_context_manager_access_level_condition
./resource.ps1 google_access_context_manager_service_perimeter_resource
./resource.ps1 google_active_directory_domain
./resource.ps1 google_active_directory_domain_trust
./resource.ps1 google_active_directory_peering
./resource.ps1 google_api_gateway_api
./resource.ps1 google_api_gateway_api_config
./resource.ps1 google_api_gateway_api_config_iam_binding
./resource.ps1 google_api_gateway_api_config_iam_member
./resource.ps1 google_api_gateway_api_config_iam_policy
./resource.ps1 google_api_gateway_api_iam_binding
./resource.ps1 google_api_gateway_api_iam_member
./resource.ps1 google_api_gateway_api_iam_policy
./resource.ps1 google_api_gateway_gateway
./resource.ps1 google_api_gateway_gateway_iam_binding
./resource.ps1 google_api_gateway_gateway_iam_member
./resource.ps1 google_api_gateway_gateway_iam_policy
./resource.ps1 google_apigee_addons_config
./resource.ps1 google_apigee_endpoint_attachment
./resource.ps1 google_apigee_env_keystore
Expand Down Expand Up @@ -83,7 +71,6 @@ Datasource percentage coverage 91.35
./resource.ps1 google_bigquery_table_iam_binding
./resource.ps1 google_bigquery_table_iam_member
./resource.ps1 google_bigquery_table_iam_policy

./resource.ps1 google_billing_account_iam_binding
./resource.ps1 google_billing_account_iam_member
./resource.ps1 google_billing_account_iam_policy
Expand Down
18 changes: 18 additions & 0 deletions src/files_gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,21 @@ var googleBigtableAppProfile []byte

//go:embed mapping/google/resource/bigtable/google_bigtable_gc_policy.json
var googleBigtableGcPolicy []byte

//go:embed mapping/google/resource/apigateway/google_api_gateway_api.json
var googleApiGatewayApi []byte

//go:embed mapping/google/resource/apigateway/google_api_gateway_api_config.json
var googleApiGatewayApiConfig []byte

//go:embed mapping/google/resource/apigateway/google_api_gateway_api_config_iam.json
var googleApiGatewayApiConfigIam []byte

//go:embed mapping/google/resource/apigateway/google_api_gateway_api_iam.json
var googleApiGatewayApiIam []byte

//go:embed mapping/google/resource/apigateway/google_api_gateway_gateway.json
var googleApiGatewayGateway []byte

//go:embed mapping/google/resource/apigateway/google_api_gateway_gateway_iam.json
var googleApiGatewayGatewayIam []byte
12 changes: 12 additions & 0 deletions src/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,18 @@ func GCPLookup(result string) interface{} {
"google_firebaserules_ruleset": googleFirebaserulesRuleset,
"google_bigtable_app_profile": googleBigtableAppProfile,
"google_bigtable_gc_policy": googleBigtableGcPolicy,
"google_api_gateway_api": googleApiGatewayApi,
"google_api_gateway_api_config": googleApiGatewayApiConfig,
"google_api_gateway_api_config_iam_binding": googleApiGatewayApiConfigIam,
"google_api_gateway_api_config_iam_member": googleApiGatewayApiConfigIam,
"google_api_gateway_api_config_iam_policy": googleApiGatewayApiConfigIam,
"google_api_gateway_api_iam_binding": googleApiGatewayApiIam,
"google_api_gateway_api_iam_member": googleApiGatewayApiIam,
"google_api_gateway_api_iam_policy": googleApiGatewayApiIam,
"google_api_gateway_gateway": googleApiGatewayGateway,
"google_api_gateway_gateway_iam_binding": googleApiGatewayGatewayIam,
"google_api_gateway_gateway_iam_member": googleApiGatewayGatewayIam,
"google_api_gateway_gateway_iam_policy": googleApiGatewayGatewayIam,
}

return TFLookup[result]
Expand Down
21 changes: 21 additions & 0 deletions src/mapping/google/resource/apigateway/google_api_gateway_api.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[
{
"apply": [
"apigateway.apis.create",
"apigateway.apis.delete",
"apigateway.apis.update",
"apigateway.apis.get",
"apigateway.operations.get"
],
"attributes": {
"tags": []
},
"destroy": [
"apigateway.apis.delete"
],
"modify": [
"apigateway.apis.update"
],
"plan": []
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"apply": [
"apigateway.apiconfigs.get",
"apigateway.apiconfigs.create",
"apigateway.apiconfigs.delete",
"apigateway.apiconfigs.update"
],
"attributes": {
"tags": []
},
"destroy": [
"apigateway.apiconfigs.delete"
],
"modify": [
"apigateway.apiconfigs.update"
],
"plan": []
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"apply": [
"apigateway.apiconfigs.getIamPolicy",
"apigateway.apiconfigs.setIamPolicy"
],
"attributes": {
"tags": []
},
"destroy": [],
"modify": [],
"plan": []
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"apply": [
"apigateway.apis.setIamPolicy",
"apigateway.apis.getIamPolicy"
],
"attributes": {
"tags": []
},
"destroy": [],
"modify": [],
"plan": []
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"apply": [
"apigateway.gateways.create",
"apigateway.gateways.delete",
"apigateway.gateways.update",
"apigateway.gateways.get"
],
"attributes": {
"tags": []
},
"destroy": [
"apigateway.gateways.delete"
],
"modify": [
"apigateway.gateways.update"
],
"plan": []
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"apply": [
"apigateway.gateways.setIamPolicy",
"apigateway.gateways.getIamPolicy"
],
"attributes": {
"tags": []
},
"destroy": [],
"modify": [],
"plan": []
}
]
4 changes: 4 additions & 0 deletions terraform/google/backup/google_api_gateway_api.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "google_api_gateway_api" "pike" {
provider = google-beta
api_id = "pike"
}
13 changes: 13 additions & 0 deletions terraform/google/backup/google_api_gateway_api_config.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
resource "google_api_gateway_api_config" "pike" {
provider = google-beta
api = google_api_gateway_api.pike.api_id
openapi_documents {
document {
path = "spec.yaml"
contents = filebase64("spec2.0.yaml")
}
}
lifecycle {
create_before_destroy = true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resource "google_api_gateway_api_config_iam_binding" "pike" {
provider = google-beta
api = google_api_gateway_api_config.pike.api
api_config = google_api_gateway_api_config.pike.api_config_id
role = "roles/apigateway.viewer"
members = [
"user:crwoolfenden@gmail.com",
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "google_api_gateway_api_config_iam_member" "pike" {
provider = google-beta
api = google_api_gateway_api_config.pike.api
api_config = google_api_gateway_api_config.pike.api_config_id
role = "roles/apigateway.viewer"
member = "user:crwoolfenden@gmail.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "google_api_gateway_api_config_iam_policy" "pike" {
provider = google-beta
policy_data = data.google_iam_policy.admin.policy_data
api = google_api_gateway_api_config.pike.api
api_config = google_api_gateway_api_config.pike.api_config_id
}
8 changes: 8 additions & 0 deletions terraform/google/backup/google_api_gateway_api_iam_binding.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "google_api_gateway_api_iam_binding" "pike" {
provider = google-beta
api = google_api_gateway_api.pike.api_id
role = "roles/apigateway.viewer"
members = [
"user:crwoolfenden@gmail.com",
]
}
6 changes: 6 additions & 0 deletions terraform/google/backup/google_api_gateway_api_iam_member.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "google_api_gateway_api_iam_member" "pike" {
provider = google-beta
api = google_api_gateway_api.pike.api_id
role = "roles/apigateway.viewer"
member = "user:crwoolfenden@gmail.com"
}
15 changes: 15 additions & 0 deletions terraform/google/backup/google_api_gateway_api_iam_policy.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "google_api_gateway_api_iam_policy" "pike" {
provider = google-beta
policy_data = data.google_iam_policy.admin2.policy_data
api = google_api_gateway_api.pike.api_id
}

data "google_iam_policy" "admin2" {
provider = google-beta
binding {
role = "roles/apigateway.viewer"
members = [
"user:crwoolfenden@gmail.com",
]
}
}
5 changes: 5 additions & 0 deletions terraform/google/backup/google_api_gateway_gateway.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "google_api_gateway_gateway" "pike" {
provider = google-beta
api_config = google_api_gateway_api_config.pike.id
gateway_id = "pike"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "google_api_gateway_gateway_iam_binding" "pike" {
provider = google-beta
gateway = google_api_gateway_gateway.pike.id
role = "roles/apigateway.viewer"
members = [
"user:crwoolfenden@gmail.com",
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "google_api_gateway_gateway_iam_member" "pike" {
provider = google-beta
gateway = google_api_gateway_gateway.pike.id
role = "roles/apigateway.viewer"
member = "user:crwoolfenden@gmail.com"

}
15 changes: 15 additions & 0 deletions terraform/google/backup/google_api_gateway_gateway_iam_policy.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "google_api_gateway_gateway_iam_policy" "pike" {
provider = google-beta
gateway = google_api_gateway_gateway.pike.id
policy_data = data.google_iam_policy.admin.policy_data
}

data "google_iam_policy" "admin" {
provider = google-beta
binding {
role = "roles/apigateway.viewer"
members = [
"user:crwoolfenden@gmail.com",
]
}
}
24 changes: 24 additions & 0 deletions terraform/google/backup/spec2.0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# openapi2-functions.yaml
swagger: '2.0'
info:
title: test
description: Sample API on API Gateway with a Google Cloud Functions backend
version: 1.0.0
schemes:
- https
produces:
- application/json
#prefix after the static gateway URL. It tells the Gateway which function to call
paths:
/hello:
post:
summary: Greet a user
operationId: hello
#actual address of the cloud function where the request is supposed to be forwarded
x-google-backend:
address: https://GCP_REGION-PROJECT_ID.cloudfunctions.net/hello
responses:
'200':
description: A successful response
schema:
type: string

0 comments on commit 384990e

Please sign in to comment.