|
| 1 | +// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. |
| 2 | +// Licensed under the Mozilla Public License v2.0 |
| 3 | + |
| 4 | +variable "tenancy_ocid" {} |
| 5 | +variable "user_ocid" {} |
| 6 | +variable "fingerprint" {} |
| 7 | +variable "private_key_path" {} |
| 8 | +variable "region" {} |
| 9 | +variable "compartment_ocid" {} |
| 10 | + |
| 11 | +variable "gateway_defined_tags_value" { |
| 12 | + default = "value" |
| 13 | +} |
| 14 | + |
| 15 | +variable "gateway_display_name" { |
| 16 | + default = "displayName" |
| 17 | +} |
| 18 | + |
| 19 | +variable "gateway_endpoint_type" { |
| 20 | + default = "PUBLIC" |
| 21 | +} |
| 22 | + |
| 23 | +variable "gateway_freeform_tags" { |
| 24 | + default = { "Department" = "Finance" } |
| 25 | +} |
| 26 | + |
| 27 | +variable "gateway_response_cache_details_authentication_secret_id" {} |
| 28 | + |
| 29 | +variable "gateway_response_cache_details_authentication_secret_version_number" { |
| 30 | + default = 1 |
| 31 | +} |
| 32 | + |
| 33 | +variable "gateway_response_cache_details_connect_timeout_in_ms" { |
| 34 | + default = 1000 |
| 35 | +} |
| 36 | + |
| 37 | +variable "gateway_response_cache_details_is_ssl_enabled" { |
| 38 | + default = false |
| 39 | +} |
| 40 | + |
| 41 | +variable "gateway_response_cache_details_is_ssl_verify_disabled" { |
| 42 | + default = false |
| 43 | +} |
| 44 | + |
| 45 | +variable "gateway_response_cache_details_read_timeout_in_ms" { |
| 46 | + default = 1000 |
| 47 | +} |
| 48 | + |
| 49 | +variable "gateway_response_cache_details_send_timeout_in_ms" { |
| 50 | + default = 1000 |
| 51 | +} |
| 52 | + |
| 53 | +variable "gateway_response_cache_details_servers_host" { |
| 54 | + default = "host" |
| 55 | +} |
| 56 | + |
| 57 | +variable "gateway_response_cache_details_servers_port" { |
| 58 | + default = 6379 |
| 59 | +} |
| 60 | + |
| 61 | +variable "gateway_response_cache_details_type" { |
| 62 | + default = "EXTERNAL_RESP_CACHE" |
| 63 | +} |
| 64 | + |
| 65 | +variable "gateway_state" { |
| 66 | + default = "ACTIVE" |
| 67 | +} |
| 68 | + |
| 69 | +variable "deployment_state" { |
| 70 | + default = "ACTIVE" |
| 71 | +} |
| 72 | + |
| 73 | +variable "deployment_path_prefix" { |
| 74 | + default = "/v1" |
| 75 | +} |
| 76 | + |
| 77 | +variable "deployment_specification_routes_backend_type" { |
| 78 | + default = "HTTP_BACKEND" |
| 79 | +} |
| 80 | + |
| 81 | +variable "deployment_specification_routes_backend_url" { |
| 82 | + default = "https://api.weather.gov" |
| 83 | +} |
| 84 | + |
| 85 | +variable "deployment_specification_routes_methods" { |
| 86 | + default = ["GET"] |
| 87 | +} |
| 88 | + |
| 89 | +variable "deployment_specification_routes_path" { |
| 90 | + default = "/hello" |
| 91 | +} |
| 92 | + |
| 93 | +variable "deployment_specification_routes_response_policies_response_cache_store_time_to_live_in_seconds" { |
| 94 | + default = 10 |
| 95 | +} |
| 96 | + |
| 97 | +variable "deployment_specification_routes_response_policies_response_cache_store_type" { |
| 98 | + default = "FIXED_TTL_STORE_POLICY" |
| 99 | +} |
| 100 | + |
| 101 | +variable "deployment_specification_routes_request_policies_response_cache_lookup_cache_key_additions" { |
| 102 | + default = ["request.headers[Accept]"] |
| 103 | +} |
| 104 | + |
| 105 | +variable "deployment_specification_routes_request_policies_response_cache_lookup_is_enabled" { |
| 106 | + default = false |
| 107 | +} |
| 108 | + |
| 109 | +variable "deployment_specification_routes_request_policies_response_cache_lookup_is_private_caching_enabled" { |
| 110 | + default = false |
| 111 | +} |
| 112 | + |
| 113 | +variable "deployment_specification_routes_request_policies_response_cache_lookup_type" { |
| 114 | + default = "SIMPLE_LOOKUP_POLICY" |
| 115 | +} |
| 116 | + |
| 117 | + |
| 118 | + |
| 119 | +provider "oci" { |
| 120 | + tenancy_ocid = var.tenancy_ocid |
| 121 | + user_ocid = var.user_ocid |
| 122 | + fingerprint = var.fingerprint |
| 123 | + private_key_path = var.private_key_path |
| 124 | + region = var.region |
| 125 | +} |
| 126 | + |
| 127 | +resource "oci_core_subnet" "regional_subnet" { |
| 128 | + cidr_block = "10.0.1.0/24" |
| 129 | + display_name = "regionalSubnet" |
| 130 | + dns_label = "regionalsubnet" |
| 131 | + compartment_id = var.compartment_ocid |
| 132 | + vcn_id = oci_core_vcn.vcn1.id |
| 133 | + security_list_ids = [oci_core_vcn.vcn1.default_security_list_id] |
| 134 | + route_table_id = oci_core_vcn.vcn1.default_route_table_id |
| 135 | + dhcp_options_id = oci_core_vcn.vcn1.default_dhcp_options_id |
| 136 | +} |
| 137 | + |
| 138 | +data "oci_identity_availability_domain" "ad" { |
| 139 | + compartment_id = var.tenancy_ocid |
| 140 | + ad_number = 1 |
| 141 | +} |
| 142 | + |
| 143 | +resource "oci_core_vcn" "vcn1" { |
| 144 | + cidr_block = "10.0.0.0/16" |
| 145 | + compartment_id = var.compartment_ocid |
| 146 | + display_name = "exampleVCN" |
| 147 | + dns_label = "tfexamplevcn" |
| 148 | +} |
| 149 | + |
| 150 | +resource "oci_apigateway_gateway" "test_gateway" { |
| 151 | + #Required |
| 152 | + compartment_id = var.compartment_ocid |
| 153 | + endpoint_type = var.gateway_endpoint_type |
| 154 | + subnet_id = oci_core_subnet.regional_subnet.id |
| 155 | + |
| 156 | + #Optional |
| 157 | + display_name = var.gateway_display_name |
| 158 | + freeform_tags = var.gateway_freeform_tags |
| 159 | + response_cache_details { |
| 160 | + #Required |
| 161 | + type = var.gateway_response_cache_details_type |
| 162 | + |
| 163 | + #Optional |
| 164 | + authentication_secret_id = var.gateway_response_cache_details_authentication_secret_id |
| 165 | + authentication_secret_version_number = var.gateway_response_cache_details_authentication_secret_version_number |
| 166 | + connect_timeout_in_ms = var.gateway_response_cache_details_connect_timeout_in_ms |
| 167 | + is_ssl_enabled = var.gateway_response_cache_details_is_ssl_enabled |
| 168 | + is_ssl_verify_disabled = var.gateway_response_cache_details_is_ssl_verify_disabled |
| 169 | + read_timeout_in_ms = var.gateway_response_cache_details_read_timeout_in_ms |
| 170 | + send_timeout_in_ms = var.gateway_response_cache_details_send_timeout_in_ms |
| 171 | + servers { |
| 172 | + |
| 173 | + #Optional |
| 174 | + host = var.gateway_response_cache_details_servers_host |
| 175 | + port = var.gateway_response_cache_details_servers_port |
| 176 | + } |
| 177 | + } |
| 178 | +} |
| 179 | + |
| 180 | +resource "oci_apigateway_deployment" "test_deployment" { |
| 181 | + #Required |
| 182 | + compartment_id = var.compartment_ocid |
| 183 | + gateway_id = oci_apigateway_gateway.test_gateway.id |
| 184 | + path_prefix = var.deployment_path_prefix |
| 185 | + |
| 186 | + specification { |
| 187 | + routes { |
| 188 | + #Required |
| 189 | + backend { |
| 190 | + #Required |
| 191 | + type = var.deployment_specification_routes_backend_type |
| 192 | + url = var.deployment_specification_routes_backend_url |
| 193 | + } |
| 194 | + path = var.deployment_specification_routes_path |
| 195 | + methods = var.deployment_specification_routes_methods |
| 196 | + request_policies { |
| 197 | + response_cache_lookup { |
| 198 | + #Required |
| 199 | + type = var.deployment_specification_routes_request_policies_response_cache_lookup_type |
| 200 | + |
| 201 | + #Optional |
| 202 | + cache_key_additions = var.deployment_specification_routes_request_policies_response_cache_lookup_cache_key_additions |
| 203 | + is_enabled = var.deployment_specification_routes_request_policies_response_cache_lookup_is_enabled |
| 204 | + is_private_caching_enabled = var.deployment_specification_routes_request_policies_response_cache_lookup_is_private_caching_enabled |
| 205 | + } |
| 206 | + } |
| 207 | + response_policies { |
| 208 | + response_cache_store { |
| 209 | + #Required |
| 210 | + time_to_live_in_seconds = var.deployment_specification_routes_response_policies_response_cache_store_time_to_live_in_seconds |
| 211 | + type = var.deployment_specification_routes_response_policies_response_cache_store_type |
| 212 | + } |
| 213 | + } |
| 214 | + } |
| 215 | + } |
| 216 | +} |
| 217 | + |
| 218 | +data "oci_apigateway_gateways" "test_gateways" { |
| 219 | + #Required |
| 220 | + compartment_id = var.compartment_ocid |
| 221 | + |
| 222 | + #Optional |
| 223 | + display_name = oci_apigateway_gateway.test_gateway.display_name |
| 224 | + state = var.gateway_state |
| 225 | +} |
| 226 | + |
| 227 | +data "oci_apigateway_deployments" "test_deployments" { |
| 228 | + #Required |
| 229 | + compartment_id = var.compartment_ocid |
| 230 | + |
| 231 | + #Optional |
| 232 | + gateway_id = oci_apigateway_gateway.test_gateway.id |
| 233 | + state = var.deployment_state |
| 234 | +} |
0 commit comments