Skip to content

Commit 6445e47

Browse files
Add deploymentType and apiProxyType to ApigeeEnvironment (#5884) (#11405)
Signed-off-by: Modular Magician <[email protected]>
1 parent bc2b47d commit 6445e47

File tree

4 files changed

+186
-0
lines changed

4 files changed

+186
-0
lines changed

.changelog/5884.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
Add deploymentType and apiProxyType to ApigeeEnvironment.
3+
```

google/resource_apigee_environment.go

+69
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,29 @@ func resourceApigeeEnvironment() *schema.Resource {
5353
ForceNew: true,
5454
Description: `The Apigee Organization associated with the Apigee environment,
5555
in the format 'organizations/{{org_name}}'.`,
56+
},
57+
"api_proxy_type": {
58+
Type: schema.TypeString,
59+
Computed: true,
60+
Optional: true,
61+
ForceNew: true,
62+
ValidateFunc: validateEnum([]string{"API_PROXY_TYPE_UNSPECIFIED", "PROGRAMMABLE", "CONFIGURABLE", ""}),
63+
Description: `Optional. API Proxy type supported by the environment. The type can be set when creating
64+
the Environment and cannot be changed. Possible values: ["API_PROXY_TYPE_UNSPECIFIED", "PROGRAMMABLE", "CONFIGURABLE"]`,
65+
},
66+
"deployment_type": {
67+
Type: schema.TypeString,
68+
Computed: true,
69+
Optional: true,
70+
ForceNew: true,
71+
ValidateFunc: validateEnum([]string{"DEPLOYMENT_TYPE_UNSPECIFIED", "PROXY", "ARCHIVE", ""}),
72+
Description: `Optional. Deployment type supported by the environment. The deployment type can be
73+
set when creating the environment and cannot be changed. When you enable archive
74+
deployment, you will be prevented from performing a subset of actions within the
75+
environment, including:
76+
Managing the deployment of API proxy or shared flow revisions;
77+
Creating, updating, or deleting resource files;
78+
Creating, updating, or deleting target servers. Possible values: ["DEPLOYMENT_TYPE_UNSPECIFIED", "PROXY", "ARCHIVE"]`,
5679
},
5780
"description": {
5881
Type: schema.TypeString,
@@ -97,6 +120,18 @@ func resourceApigeeEnvironmentCreate(d *schema.ResourceData, meta interface{}) e
97120
} else if v, ok := d.GetOkExists("description"); !isEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) {
98121
obj["description"] = descriptionProp
99122
}
123+
deploymentTypeProp, err := expandApigeeEnvironmentDeploymentType(d.Get("deployment_type"), d, config)
124+
if err != nil {
125+
return err
126+
} else if v, ok := d.GetOkExists("deployment_type"); !isEmptyValue(reflect.ValueOf(deploymentTypeProp)) && (ok || !reflect.DeepEqual(v, deploymentTypeProp)) {
127+
obj["deploymentType"] = deploymentTypeProp
128+
}
129+
apiProxyTypeProp, err := expandApigeeEnvironmentApiProxyType(d.Get("api_proxy_type"), d, config)
130+
if err != nil {
131+
return err
132+
} else if v, ok := d.GetOkExists("api_proxy_type"); !isEmptyValue(reflect.ValueOf(apiProxyTypeProp)) && (ok || !reflect.DeepEqual(v, apiProxyTypeProp)) {
133+
obj["apiProxyType"] = apiProxyTypeProp
134+
}
100135

101136
url, err := replaceVars(d, config, "{{ApigeeBasePath}}{{org_id}}/environments")
102137
if err != nil {
@@ -184,6 +219,12 @@ func resourceApigeeEnvironmentRead(d *schema.ResourceData, meta interface{}) err
184219
if err := d.Set("description", flattenApigeeEnvironmentDescription(res["description"], d, config)); err != nil {
185220
return fmt.Errorf("Error reading Environment: %s", err)
186221
}
222+
if err := d.Set("deployment_type", flattenApigeeEnvironmentDeploymentType(res["deploymentType"], d, config)); err != nil {
223+
return fmt.Errorf("Error reading Environment: %s", err)
224+
}
225+
if err := d.Set("api_proxy_type", flattenApigeeEnvironmentApiProxyType(res["apiProxyType"], d, config)); err != nil {
226+
return fmt.Errorf("Error reading Environment: %s", err)
227+
}
187228

188229
return nil
189230
}
@@ -216,6 +257,18 @@ func resourceApigeeEnvironmentUpdate(d *schema.ResourceData, meta interface{}) e
216257
} else if v, ok := d.GetOkExists("description"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) {
217258
obj["description"] = descriptionProp
218259
}
260+
deploymentTypeProp, err := expandApigeeEnvironmentDeploymentType(d.Get("deployment_type"), d, config)
261+
if err != nil {
262+
return err
263+
} else if v, ok := d.GetOkExists("deployment_type"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, deploymentTypeProp)) {
264+
obj["deploymentType"] = deploymentTypeProp
265+
}
266+
apiProxyTypeProp, err := expandApigeeEnvironmentApiProxyType(d.Get("api_proxy_type"), d, config)
267+
if err != nil {
268+
return err
269+
} else if v, ok := d.GetOkExists("api_proxy_type"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, apiProxyTypeProp)) {
270+
obj["apiProxyType"] = apiProxyTypeProp
271+
}
219272

220273
url, err := replaceVars(d, config, "{{ApigeeBasePath}}{{org_id}}/environments/{{name}}")
221274
if err != nil {
@@ -344,6 +397,14 @@ func flattenApigeeEnvironmentDescription(v interface{}, d *schema.ResourceData,
344397
return v
345398
}
346399

400+
func flattenApigeeEnvironmentDeploymentType(v interface{}, d *schema.ResourceData, config *Config) interface{} {
401+
return v
402+
}
403+
404+
func flattenApigeeEnvironmentApiProxyType(v interface{}, d *schema.ResourceData, config *Config) interface{} {
405+
return v
406+
}
407+
347408
func expandApigeeEnvironmentName(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
348409
return v, nil
349410
}
@@ -355,3 +416,11 @@ func expandApigeeEnvironmentDisplayName(v interface{}, d TerraformResourceData,
355416
func expandApigeeEnvironmentDescription(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
356417
return v, nil
357418
}
419+
420+
func expandApigeeEnvironmentDeploymentType(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
421+
return v, nil
422+
}
423+
424+
func expandApigeeEnvironmentApiProxyType(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
425+
return v, nil
426+
}

google/resource_apigee_environment_generated_test.go

+97
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,103 @@ resource "google_apigee_environment" "apigee_environment" {
118118
`, context)
119119
}
120120

121+
func TestAccApigeeEnvironment_apigeeEnvironmentBasicDeploymentApiproxyTypeTestExample(t *testing.T) {
122+
skipIfVcr(t)
123+
t.Parallel()
124+
125+
context := map[string]interface{}{
126+
"org_id": getTestOrgFromEnv(t),
127+
"billing_account": getTestBillingAccountFromEnv(t),
128+
"random_suffix": randString(t, 10),
129+
}
130+
131+
vcrTest(t, resource.TestCase{
132+
PreCheck: func() { testAccPreCheck(t) },
133+
Providers: testAccProviders,
134+
CheckDestroy: testAccCheckApigeeEnvironmentDestroyProducer(t),
135+
Steps: []resource.TestStep{
136+
{
137+
Config: testAccApigeeEnvironment_apigeeEnvironmentBasicDeploymentApiproxyTypeTestExample(context),
138+
},
139+
{
140+
ResourceName: "google_apigee_environment.apigee_environment",
141+
ImportState: true,
142+
ImportStateVerify: true,
143+
ImportStateVerifyIgnore: []string{"org_id"},
144+
},
145+
},
146+
})
147+
}
148+
149+
func testAccApigeeEnvironment_apigeeEnvironmentBasicDeploymentApiproxyTypeTestExample(context map[string]interface{}) string {
150+
return Nprintf(`
151+
resource "google_project" "project" {
152+
project_id = "tf-test%{random_suffix}"
153+
name = "tf-test%{random_suffix}"
154+
org_id = "%{org_id}"
155+
billing_account = "%{billing_account}"
156+
}
157+
158+
resource "google_project_service" "apigee" {
159+
project = google_project.project.project_id
160+
service = "apigee.googleapis.com"
161+
}
162+
163+
resource "google_project_service" "servicenetworking" {
164+
project = google_project.project.project_id
165+
service = "servicenetworking.googleapis.com"
166+
depends_on = [google_project_service.apigee]
167+
}
168+
169+
resource "google_project_service" "compute" {
170+
project = google_project.project.project_id
171+
service = "compute.googleapis.com"
172+
depends_on = [google_project_service.servicenetworking]
173+
}
174+
175+
resource "google_compute_network" "apigee_network" {
176+
name = "apigee-network"
177+
project = google_project.project.project_id
178+
depends_on = [google_project_service.compute]
179+
}
180+
181+
resource "google_compute_global_address" "apigee_range" {
182+
name = "apigee-range"
183+
purpose = "VPC_PEERING"
184+
address_type = "INTERNAL"
185+
prefix_length = 16
186+
network = google_compute_network.apigee_network.id
187+
project = google_project.project.project_id
188+
}
189+
190+
resource "google_service_networking_connection" "apigee_vpc_connection" {
191+
network = google_compute_network.apigee_network.id
192+
service = "servicenetworking.googleapis.com"
193+
reserved_peering_ranges = [google_compute_global_address.apigee_range.name]
194+
depends_on = [google_project_service.servicenetworking]
195+
}
196+
197+
resource "google_apigee_organization" "apigee_org" {
198+
analytics_region = "us-central1"
199+
project_id = google_project.project.project_id
200+
authorized_network = google_compute_network.apigee_network.id
201+
depends_on = [
202+
google_service_networking_connection.apigee_vpc_connection,
203+
google_project_service.apigee,
204+
]
205+
}
206+
207+
resource "google_apigee_environment" "apigee_environment" {
208+
org_id = google_apigee_organization.apigee_org.id
209+
name = "tf-test%{random_suffix}"
210+
description = "Apigee Environment"
211+
display_name = "environment-1"
212+
deployment_type = "PROXY"
213+
api_proxy_type = "PROGRAMMABLE"
214+
}
215+
`, context)
216+
}
217+
121218
func testAccCheckApigeeEnvironmentDestroyProducer(t *testing.T) func(s *terraform.State) error {
122219
return func(s *terraform.State) error {
123220
for name, rs := range s.RootModule().Resources {

website/docs/r/apigee_environment.html.markdown

+17
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,23 @@ The following arguments are supported:
9696
(Optional)
9797
Description of the environment.
9898

99+
* `deployment_type` -
100+
(Optional)
101+
Optional. Deployment type supported by the environment. The deployment type can be
102+
set when creating the environment and cannot be changed. When you enable archive
103+
deployment, you will be prevented from performing a subset of actions within the
104+
environment, including:
105+
Managing the deployment of API proxy or shared flow revisions;
106+
Creating, updating, or deleting resource files;
107+
Creating, updating, or deleting target servers.
108+
Possible values are `DEPLOYMENT_TYPE_UNSPECIFIED`, `PROXY`, and `ARCHIVE`.
109+
110+
* `api_proxy_type` -
111+
(Optional)
112+
Optional. API Proxy type supported by the environment. The type can be set when creating
113+
the Environment and cannot be changed.
114+
Possible values are `API_PROXY_TYPE_UNSPECIFIED`, `PROGRAMMABLE`, and `CONFIGURABLE`.
115+
99116

100117
## Attributes Reference
101118

0 commit comments

Comments
 (0)