Skip to content

Commit c92357c

Browse files
authored
add resources to support apigee proxy deployments (#15126)
1 parent 505d0c1 commit c92357c

File tree

3 files changed

+208
-0
lines changed

3 files changed

+208
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Copyright 2025 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
---
15+
name: 'ApiDeployment'
16+
description: |
17+
Manages a deployment of an API proxy.
18+
references:
19+
guides:
20+
'QUICKSTART_TITLE': 'https://cloud.google.com/apigee/docs/api-platform/deploy/ui-deploy-overview'
21+
api: 'https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations.environments.apis.revisions.deployments'
22+
base_url: 'organizations/{{org_id}}/environments/{{environment}}/apis/{{proxy_id}}/revisions/{{revision}}/deployments'
23+
self_link: 'organizations/{{org_id}}/environments/{{environment}}/apis/{{proxy_id}}/revisions/{{revision}}/deployments'
24+
import_format:
25+
- 'organizations/{{org_id}}/environments/{{environment}}/apis/{{proxy_id}}/revisions/{{revision}}/deployments'
26+
- 'organizations/{{org_id}}/environments/{{environment}}/apis/{{proxy_id}}/revisions/{{revision}}'
27+
- '{{org_id}}/{{environment}}/{{proxy_id}}/{{revision}}/deployments'
28+
- '{{org_id}}/{{environment}}/{{proxy_id}}/{{revision}}'
29+
immutable: true
30+
31+
create_url: 'organizations/{{org_id}}/environments/{{environment}}/apis/{{proxy_id}}/revisions/{{revision}}/deployments'
32+
33+
update_verb: 'POST'
34+
update_mask: false
35+
36+
parameters:
37+
- name: 'org_id'
38+
type: String
39+
required: true
40+
immutable: true
41+
url_param_only: true
42+
description: |
43+
The Apigee Organization associated with the Apigee API deployment.
44+
- name: 'environment'
45+
type: String
46+
required: true
47+
immutable: true
48+
url_param_only: true
49+
description: |
50+
The Apigee Environment associated with the Apigee API deployment.
51+
- name: 'proxy_id'
52+
type: String
53+
required: true
54+
immutable: true
55+
url_param_only: true
56+
description: |
57+
The Apigee API associated with the Apigee API deployment.
58+
- name: 'revision'
59+
type: String
60+
required: true
61+
immutable: true
62+
url_param_only: true
63+
description: |
64+
The revision of the API proxy to be deployed.
65+
66+
properties:
67+
- name: 'id'
68+
type: String
69+
description: |
70+
The ID of the API deployment in the format `organizations/{{org_id}}/environments/{{environment}}/apis/{{proxy_id}}/revisions/{{revision}}/deployments`.
71+
output: true
72+
73+
examples:
74+
- name: 'apigee_api_deployment_basic'
75+
primary_resource_id: 'api_deployment_test'
76+
test_env_vars:
77+
org_id: 'ORG_ID'
78+
billing_account: 'BILLING_ACCT'
79+
skip_vcr: true
80+
exclude_test: true
81+
- name: 'apigee_api_deployment_basic_test'
82+
primary_resource_id: 'api_deployment_test'
83+
test_env_vars:
84+
org_id: 'ORG_ID'
85+
billing_account: 'BILLING_ACCT'
86+
external_providers: ['time']
87+
skip_vcr: true
88+
exclude_docs: true
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
resource "google_apigee_organization" "apigee_org" {
2+
analytics_region = "us-central1"
3+
project_id = google_project.project.project_id
4+
authorized_network = google_compute_network.apigee_network.id
5+
depends_on = [
6+
google_service_networking_connection.apigee_vpc_connection,
7+
google_project_service.apigee,
8+
]
9+
}
10+
11+
resource "google_apigee_environment" "apigee_environment" {
12+
org_id = google_apigee_organization.apigee_org.id
13+
name = "apigee-env"
14+
description = "Apigee Environment"
15+
display_name = "environment-1"
16+
}
17+
18+
data "archive_file" "bundle" {
19+
type = "zip"
20+
source_dir = "${path.module}/bundle"
21+
output_path = "${path.module}/bundle.zip"
22+
output_file_mode = "0644"
23+
}
24+
25+
26+
resource "google_apigee_api" "test_apigee_api" {
27+
name = "apigee-proxy"
28+
org_id = google_project.project.project_id
29+
config_bundle = data.archive_file.bundle.output_path
30+
depends_on = [google_apigee_organization.apigee_org]
31+
}
32+
33+
resource "google_apigee_api_deployment" "test_apigee_api_deployment" {
34+
environment = google_apigee_environment.apigee_environment.name
35+
org_id = google_apigee_api.test_apigee_api.org_id
36+
revision = google_apigee_api.test_apigee_api.latest_revision_id
37+
proxy_id = google_apigee_api.test_apigee_api.name
38+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
resource "google_project" "project" {
2+
project_id = "tf-test%{random_suffix}"
3+
name = "tf-test%{random_suffix}"
4+
org_id = "{{index $.TestEnvVars "org_id"}}"
5+
billing_account = "{{index $.TestEnvVars "billing_account"}}"
6+
deletion_policy = "DELETE"
7+
}
8+
9+
resource "google_project_service" "apigee" {
10+
project = google_project.project.project_id
11+
service = "apigee.googleapis.com"
12+
}
13+
14+
resource "google_project_service" "servicenetworking" {
15+
project = google_project.project.project_id
16+
service = "servicenetworking.googleapis.com"
17+
depends_on = [google_project_service.apigee]
18+
}
19+
20+
resource "google_project_service" "compute" {
21+
project = google_project.project.project_id
22+
service = "compute.googleapis.com"
23+
depends_on = [google_project_service.servicenetworking]
24+
}
25+
26+
resource "time_sleep" "wait_120_seconds" {
27+
create_duration = "120s"
28+
depends_on = [google_project_service.compute]
29+
}
30+
31+
resource "google_compute_network" "apigee_network" {
32+
name = "apigee-network"
33+
project = google_project.project.project_id
34+
depends_on = [time_sleep.wait_120_seconds]
35+
}
36+
37+
resource "google_compute_global_address" "apigee_range" {
38+
name = "tf-test-apigee-range%{random_suffix}"
39+
purpose = "VPC_PEERING"
40+
address_type = "INTERNAL"
41+
prefix_length = 16
42+
network = google_compute_network.apigee_network.id
43+
project = google_project.project.project_id
44+
}
45+
46+
resource "google_service_networking_connection" "apigee_vpc_connection" {
47+
network = google_compute_network.apigee_network.id
48+
service = "servicenetworking.googleapis.com"
49+
reserved_peering_ranges = [google_compute_global_address.apigee_range.name]
50+
depends_on = [google_project_service.servicenetworking]
51+
}
52+
53+
resource "google_apigee_organization" "apigee_org" {
54+
analytics_region = "us-central1"
55+
project_id = google_project.project.project_id
56+
authorized_network = google_compute_network.apigee_network.id
57+
depends_on = [
58+
google_service_networking_connection.apigee_vpc_connection,
59+
google_project_service.apigee,
60+
]
61+
}
62+
63+
resource "google_apigee_environment" "apigee_environment" {
64+
org_id = google_apigee_organization.apigee_org.id
65+
name = "test-env"
66+
description = "Apigee Environment"
67+
display_name = "environment-1"
68+
}
69+
70+
resource "google_apigee_api" "test_apigee_api" {
71+
name = "test-proxy"
72+
org_id = google_project.project.project_id
73+
config_bundle = "./test-fixtures/apigee_api_bundle.zip"
74+
depends_on = [google_apigee_organization.apigee_org]
75+
}
76+
77+
resource "google_apigee_api_deployment" "{{$.PrimaryResourceId}}" {
78+
environment = google_apigee_environment.apigee_environment.name
79+
org_id = google_apigee_api.test_apigee_api.org_id
80+
revision = google_apigee_api.test_apigee_api.latest_revision_id
81+
proxy_id = google_apigee_api.test_apigee_api.name
82+
}

0 commit comments

Comments
 (0)