|
| 1 | +// Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. |
| 2 | +variable "ip_sec_connection_cpe_local_identifier" { |
| 3 | + default = "189.44.2.135" |
| 4 | +} |
| 5 | + |
| 6 | +variable "ip_sec_connection_cpe_local_identifier_type" { |
| 7 | + default = "IP_ADDRESS" |
| 8 | +} |
| 9 | + |
| 10 | +variable "ip_sec_connection_defined_tags_value" { |
| 11 | + default = "value" |
| 12 | +} |
| 13 | + |
| 14 | +variable "ip_sec_connection_display_name" { |
| 15 | + default = "MyIPSecConnection" |
| 16 | +} |
| 17 | + |
| 18 | +variable "ip_sec_connection_freeform_tags" { |
| 19 | + default = { |
| 20 | + "Department" = "Finance" |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +variable "ip_sec_connection_static_routes" { |
| 25 | + default = ["10.0.0.0/16"] |
| 26 | +} |
| 27 | + |
| 28 | +variable "ip_sec_connection_tunnel_configuration_bgp_session_config_customer_bgp_asn" { |
| 29 | + default = "1587232876" |
| 30 | +} |
| 31 | + |
| 32 | +variable "ip_sec_connection_tunnel_configuration_bgp_session_config_customer_interface_ip" { |
| 33 | + default = "10.0.0.16/31" |
| 34 | +} |
| 35 | + |
| 36 | +variable "ip_sec_connection_tunnel_configuration_bgp_session_config_oracle_interface_ip" { |
| 37 | + default = "10.0.0.17/31" |
| 38 | +} |
| 39 | + |
| 40 | +variable "ip_sec_connection_tunnel_configuration_display_name" { |
| 41 | + default = "MyIPSecConnection" |
| 42 | +} |
| 43 | + |
| 44 | +variable "ip_sec_connection_tunnel_configuration_routing" { |
| 45 | + default = "BGP" |
| 46 | +} |
| 47 | + |
| 48 | +variable "ip_sec_connection_tunnel_configuration_shared_secret" { |
| 49 | + default = "sharedSecret" |
| 50 | +} |
| 51 | + |
| 52 | +resource oci_core_cpe "test_cpe" { |
| 53 | + compartment_id = "${var.compartment_ocid}" |
| 54 | + display_name = "test_cpe" |
| 55 | + ip_address = "189.44.2.135" |
| 56 | +} |
| 57 | + |
| 58 | +resource oci_core_drg "test_drg" { |
| 59 | + compartment_id = "${var.compartment_ocid}" |
| 60 | + display_name = "test_drg" |
| 61 | +} |
| 62 | + |
| 63 | +resource "oci_core_ipsec" "test_ip_sec_connection" { |
| 64 | + #Required |
| 65 | + compartment_id = "${var.compartment_ocid}" |
| 66 | + cpe_id = "${oci_core_cpe.test_cpe.id}" |
| 67 | + drg_id = "${oci_core_drg.test_drg.id}" |
| 68 | + static_routes = "${var.ip_sec_connection_static_routes}" |
| 69 | + |
| 70 | + #Optional |
| 71 | + cpe_local_identifier = "${var.ip_sec_connection_cpe_local_identifier}" |
| 72 | + cpe_local_identifier_type = "${var.ip_sec_connection_cpe_local_identifier_type}" |
| 73 | + defined_tags = "${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "${var.ip_sec_connection_defined_tags_value}")}" |
| 74 | + display_name = "${var.ip_sec_connection_display_name}" |
| 75 | + freeform_tags = "${var.ip_sec_connection_freeform_tags}" |
| 76 | + |
| 77 | + tunnel_configuration { |
| 78 | + #Optional |
| 79 | + bgp_session_config { |
| 80 | + #Optional |
| 81 | + customer_bgp_asn = "${var.ip_sec_connection_tunnel_configuration_bgp_session_config_customer_bgp_asn}" |
| 82 | + customer_interface_ip = "${var.ip_sec_connection_tunnel_configuration_bgp_session_config_customer_interface_ip}" |
| 83 | + oracle_interface_ip = "${var.ip_sec_connection_tunnel_configuration_bgp_session_config_oracle_interface_ip}" |
| 84 | + } |
| 85 | + |
| 86 | + display_name = "${var.ip_sec_connection_tunnel_configuration_display_name}" |
| 87 | + routing = "${var.ip_sec_connection_tunnel_configuration_routing}" |
| 88 | + shared_secret = "${var.ip_sec_connection_tunnel_configuration_shared_secret}" |
| 89 | + } |
| 90 | +} |
| 91 | + |
| 92 | +data "oci_core_ipsec_connections" "test_ip_sec_connections" { |
| 93 | + #Required |
| 94 | + compartment_id = "${var.compartment_ocid}" |
| 95 | + |
| 96 | + #Optional |
| 97 | + cpe_id = "${oci_core_cpe.test_cpe.id}" |
| 98 | + drg_id = "${oci_core_drg.test_drg.id}" |
| 99 | +} |
| 100 | + |
| 101 | +data "oci_core_ipsec_connection_tunnels" "test_ip_sec_connection_tunnels" { |
| 102 | + ipsec_id = "${oci_core_ipsec.test_ip_sec_connection.id}" |
| 103 | + |
| 104 | + # tunnel_id = "" |
| 105 | +} |
| 106 | + |
| 107 | +data "oci_core_ipsec_connection_tunnel" "test_ipsec_connection_tunnel" { |
| 108 | + ipsec_id = "${oci_core_ipsec.test_ip_sec_connection.id}" |
| 109 | + tunnel_id = "${data.oci_core_ipsec_connection_tunnels.test_ip_sec_connection_tunnels.ip_sec_connection_tunnels.0.id}" |
| 110 | +} |
0 commit comments