|
1 | | -# Copyright 2017, 2021 Oracle Corporation and/or affiliates. All rights reserved. |
2 | | -# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ |
3 | | - |
4 | | -# operator nsg and rule |
5 | | -resource "oci_core_network_security_group" "operator" { |
6 | | - compartment_id = var.compartment_id |
7 | | - display_name = "${var.label_prefix}-operator" |
8 | | - vcn_id = var.vcn_id |
9 | | -} |
10 | | - |
11 | | -resource "oci_core_network_security_group_security_rule" "operator_egress_anywhere" { |
12 | | - network_security_group_id = oci_core_network_security_group.operator.id |
13 | | - description = "allow operator to egress to anywhere" |
14 | | - destination = local.anywhere |
15 | | - destination_type = "CIDR_BLOCK" |
16 | | - direction = "EGRESS" |
17 | | - protocol = local.all_protocols |
18 | | - stateless = false |
19 | | - |
20 | | - lifecycle { |
21 | | - ignore_changes = [direction, protocol, source, source_type, tcp_options] |
22 | | - } |
23 | | -} |
24 | | - |
25 | | -resource "oci_core_network_security_group_security_rule" "operator_egress_osn" { |
26 | | - network_security_group_id = oci_core_network_security_group.operator.id |
27 | | - description = "allow operator to egress to osn" |
28 | | - destination = local.osn |
29 | | - destination_type = "SERVICE_CIDR_BLOCK" |
30 | | - direction = "EGRESS" |
31 | | - protocol = local.all_protocols |
32 | | - stateless = false |
33 | | - |
34 | | - lifecycle { |
35 | | - ignore_changes = [direction, protocol, source, source_type, tcp_options] |
36 | | - } |
37 | | -} |
38 | | - |
39 | | -resource "oci_core_network_security_group_security_rule" "operator_ingress" { |
40 | | - network_security_group_id = oci_core_network_security_group.operator.id |
41 | | - description = "allow ssh access to operator from within vcn" |
42 | | - direction = "INGRESS" |
43 | | - protocol = local.tcp_protocol |
44 | | - source = local.vcn_cidr |
45 | | - source_type = "CIDR_BLOCK" |
46 | | - stateless = false |
47 | | - |
48 | | - tcp_options { |
49 | | - destination_port_range { |
50 | | - min = local.ssh_port |
51 | | - max = local.ssh_port |
52 | | - } |
53 | | - } |
54 | | - |
55 | | - lifecycle { |
56 | | - ignore_changes = [direction, protocol, source, source_type, tcp_options] |
57 | | - } |
58 | | -} |
59 | | - |
60 | | -resource "oci_core_security_list" "operator" { |
61 | | - compartment_id = var.compartment_id |
62 | | - display_name = var.label_prefix == "none" ? "operator" : "${var.label_prefix}-operator" |
63 | | - freeform_tags = var.freeform_tags |
64 | | - |
65 | | - # egress rule to the same subnet to allow users to use OCI Bastion service to connect to the operator |
66 | | - egress_security_rules { |
67 | | - protocol = local.tcp_protocol |
68 | | - destination = local.operator_subnet |
69 | | - |
70 | | - tcp_options { |
71 | | - min = local.ssh_port |
72 | | - max = local.ssh_port |
73 | | - } |
74 | | - } |
75 | | - |
76 | | - vcn_id = var.vcn_id |
77 | | -} |
| 1 | +# Copyright 2017, 2021 Oracle Corporation and/or affiliates. All rights reserved. |
| 2 | +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ |
| 3 | + |
| 4 | +# operator nsg and rule |
| 5 | +resource "oci_core_network_security_group" "operator" { |
| 6 | + compartment_id = var.compartment_id |
| 7 | + display_name = "${var.label_prefix}-operator" |
| 8 | + vcn_id = var.vcn_id |
| 9 | +} |
| 10 | + |
| 11 | +resource "oci_core_network_security_group_security_rule" "operator_egress_anywhere" { |
| 12 | + network_security_group_id = oci_core_network_security_group.operator.id |
| 13 | + description = "allow operator to egress to anywhere" |
| 14 | + destination = local.anywhere |
| 15 | + destination_type = "CIDR_BLOCK" |
| 16 | + direction = "EGRESS" |
| 17 | + protocol = local.all_protocols |
| 18 | + stateless = false |
| 19 | + |
| 20 | + lifecycle { |
| 21 | + ignore_changes = [direction, protocol, source, source_type, tcp_options] |
| 22 | + } |
| 23 | +} |
| 24 | + |
| 25 | +resource "oci_core_network_security_group_security_rule" "operator_egress_osn" { |
| 26 | + network_security_group_id = oci_core_network_security_group.operator.id |
| 27 | + description = "allow operator to egress to osn" |
| 28 | + destination = local.osn |
| 29 | + destination_type = "SERVICE_CIDR_BLOCK" |
| 30 | + direction = "EGRESS" |
| 31 | + protocol = local.all_protocols |
| 32 | + stateless = false |
| 33 | + |
| 34 | + lifecycle { |
| 35 | + ignore_changes = [direction, protocol, source, source_type, tcp_options] |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +resource "oci_core_network_security_group_security_rule" "operator_ingress" { |
| 40 | + network_security_group_id = oci_core_network_security_group.operator.id |
| 41 | + description = "allow ssh access to operator from within vcn" |
| 42 | + direction = "INGRESS" |
| 43 | + protocol = local.tcp_protocol |
| 44 | + source = local.vcn_cidr |
| 45 | + source_type = "CIDR_BLOCK" |
| 46 | + stateless = false |
| 47 | + |
| 48 | + tcp_options { |
| 49 | + destination_port_range { |
| 50 | + min = local.ssh_port |
| 51 | + max = local.ssh_port |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + lifecycle { |
| 56 | + ignore_changes = [direction, protocol, source, source_type, tcp_options] |
| 57 | + } |
| 58 | +} |
| 59 | + |
| 60 | +resource "oci_core_security_list" "operator" { |
| 61 | + compartment_id = var.compartment_id |
| 62 | + display_name = var.label_prefix == "none" ? "operator" : "${var.label_prefix}-operator" |
| 63 | + freeform_tags = var.freeform_tags |
| 64 | + |
| 65 | + # egress rule to the same subnet to allow users to use OCI Bastion service to connect to the operator |
| 66 | + egress_security_rules { |
| 67 | + protocol = local.tcp_protocol |
| 68 | + destination = local.operator_subnet |
| 69 | + |
| 70 | + tcp_options { |
| 71 | + min = local.ssh_port |
| 72 | + max = local.ssh_port |
| 73 | + } |
| 74 | + } |
| 75 | + |
| 76 | + vcn_id = var.vcn_id |
| 77 | +} |
0 commit comments