Skip to content

Commit b6cb13f

Browse files
ccushingdshelbyo
authored andcommitted
Support VCN Transit
1 parent 71ae6f8 commit b6cb13f

10 files changed

+86
-5
lines changed

oci/core_drg_attachment_resource.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ func DrgAttachmentResource() *schema.Resource {
3939
Optional: true,
4040
Computed: true,
4141
},
42+
"route_table_id": {
43+
Type: schema.TypeString,
44+
Optional: true,
45+
Computed: true,
46+
},
4247

4348
// Computed
4449
"compartment_id": {
@@ -142,6 +147,11 @@ func (s *DrgAttachmentResourceCrud) Create() error {
142147
request.DrgId = &tmp
143148
}
144149

150+
if routeTableId, ok := s.D.GetOkExists("route_table_id"); ok {
151+
tmp := routeTableId.(string)
152+
request.RouteTableId = &tmp
153+
}
154+
145155
if vcnId, ok := s.D.GetOkExists("vcn_id"); ok {
146156
tmp := vcnId.(string)
147157
request.VcnId = &tmp
@@ -186,6 +196,11 @@ func (s *DrgAttachmentResourceCrud) Update() error {
186196
tmp := s.D.Id()
187197
request.DrgAttachmentId = &tmp
188198

199+
if routeTableId, ok := s.D.GetOkExists("route_table_id"); ok {
200+
tmp := routeTableId.(string)
201+
request.RouteTableId = &tmp
202+
}
203+
189204
request.RequestMetadata.RetryPolicy = getRetryPolicy(s.DisableNotFoundRetries, "core")
190205

191206
response, err := s.Client.UpdateDrgAttachment(context.Background(), request)
@@ -222,6 +237,10 @@ func (s *DrgAttachmentResourceCrud) SetData() error {
222237
s.D.Set("drg_id", *s.Res.DrgId)
223238
}
224239

240+
if s.Res.RouteTableId != nil {
241+
s.D.Set("route_table_id", *s.Res.RouteTableId)
242+
}
243+
225244
s.D.Set("state", s.Res.LifecycleState)
226245

227246
if s.Res.TimeCreated != nil {

oci/core_drg_attachment_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ var (
2828
}
2929

3030
drgAttachmentRepresentation = map[string]interface{}{
31-
"drg_id": Representation{repType: Required, create: `${oci_core_drg.test_drg.id}`},
32-
"vcn_id": Representation{repType: Required, create: `${oci_core_vcn.test_vcn.id}`},
33-
"display_name": Representation{repType: Optional, create: `displayName`, update: `displayName2`},
31+
"drg_id": Representation{repType: Required, create: `${oci_core_drg.test_drg.id}`},
32+
"vcn_id": Representation{repType: Required, create: `${oci_core_vcn.test_vcn.id}`},
33+
"display_name": Representation{repType: Optional, create: `displayName`, update: `displayName2`},
34+
"route_table_id": Representation{repType: Required, create: `${oci_core_vcn.test_vcn.default_route_table_id}`},
3435
}
3536

3637
DrgAttachmentResourceDependencies = DrgRequiredOnlyResource + VcnRequiredOnlyResource + VcnResourceDependencies
@@ -61,6 +62,7 @@ func TestCoreDrgAttachmentResource_basic(t *testing.T) {
6162
generateResourceFromRepresentationMap("oci_core_drg_attachment", "test_drg_attachment", Required, Create, drgAttachmentRepresentation),
6263
Check: resource.ComposeAggregateTestCheckFunc(
6364
resource.TestCheckResourceAttrSet(resourceName, "drg_id"),
65+
resource.TestCheckResourceAttrSet(resourceName, "route_table_id"),
6466
resource.TestCheckResourceAttrSet(resourceName, "vcn_id"),
6567

6668
func(s *terraform.State) (err error) {
@@ -83,6 +85,7 @@ func TestCoreDrgAttachmentResource_basic(t *testing.T) {
8385
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName"),
8486
resource.TestCheckResourceAttrSet(resourceName, "drg_id"),
8587
resource.TestCheckResourceAttrSet(resourceName, "id"),
88+
resource.TestCheckResourceAttrSet(resourceName, "route_table_id"),
8689
resource.TestCheckResourceAttrSet(resourceName, "state"),
8790
resource.TestCheckResourceAttrSet(resourceName, "vcn_id"),
8891

@@ -102,6 +105,7 @@ func TestCoreDrgAttachmentResource_basic(t *testing.T) {
102105
resource.TestCheckResourceAttr(resourceName, "display_name", "displayName2"),
103106
resource.TestCheckResourceAttrSet(resourceName, "drg_id"),
104107
resource.TestCheckResourceAttrSet(resourceName, "id"),
108+
resource.TestCheckResourceAttrSet(resourceName, "route_table_id"),
105109
resource.TestCheckResourceAttrSet(resourceName, "state"),
106110
resource.TestCheckResourceAttrSet(resourceName, "vcn_id"),
107111

@@ -130,6 +134,7 @@ func TestCoreDrgAttachmentResource_basic(t *testing.T) {
130134
resource.TestCheckResourceAttr(datasourceName, "drg_attachments.0.display_name", "displayName2"),
131135
resource.TestCheckResourceAttrSet(datasourceName, "drg_attachments.0.drg_id"),
132136
resource.TestCheckResourceAttrSet(datasourceName, "drg_attachments.0.id"),
137+
resource.TestCheckResourceAttrSet(datasourceName, "drg_attachments.0.route_table_id"),
133138
resource.TestCheckResourceAttrSet(datasourceName, "drg_attachments.0.state"),
134139
resource.TestCheckResourceAttrSet(datasourceName, "drg_attachments.0.vcn_id"),
135140
),

oci/core_drg_attachments_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ func (s *DrgAttachmentsDataSourceCrud) SetData() error {
139139
drgAttachment["id"] = *r.Id
140140
}
141141

142+
if r.RouteTableId != nil {
143+
drgAttachment["route_table_id"] = *r.RouteTableId
144+
}
145+
142146
drgAttachment["state"] = r.LifecycleState
143147

144148
if r.TimeCreated != nil {

oci/core_local_peering_gateway_resource.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ func LocalPeeringGatewayResource() *schema.Resource {
5757
Computed: true,
5858
Elem: schema.TypeString,
5959
},
60+
"route_table_id": {
61+
Type: schema.TypeString,
62+
Optional: true,
63+
Computed: true,
64+
},
6065
// @CODEGEN we use peer_id to do the connect action
6166
"peer_id": {
6267
Type: schema.TypeString,
@@ -74,6 +79,13 @@ func LocalPeeringGatewayResource() *schema.Resource {
7479
Type: schema.TypeString,
7580
Computed: true,
7681
},
82+
"peer_advertised_cidr_details": {
83+
Type: schema.TypeList,
84+
Computed: true,
85+
Elem: &schema.Schema{
86+
Type: schema.TypeString,
87+
},
88+
},
7789
"peering_status": {
7890
Type: schema.TypeString,
7991
Computed: true,
@@ -245,6 +257,11 @@ func (s *LocalPeeringGatewayResourceCrud) Create() error {
245257
request.FreeformTags = objectMapToStringMap(freeformTags.(map[string]interface{}))
246258
}
247259

260+
if routeTableId, ok := s.D.GetOkExists("route_table_id"); ok {
261+
tmp := routeTableId.(string)
262+
request.RouteTableId = &tmp
263+
}
264+
248265
if vcnId, ok := s.D.GetOkExists("vcn_id"); ok {
249266
tmp := vcnId.(string)
250267
request.VcnId = &tmp
@@ -301,6 +318,11 @@ func (s *LocalPeeringGatewayResourceCrud) Update() error {
301318
tmp := s.D.Id()
302319
request.LocalPeeringGatewayId = &tmp
303320

321+
if routeTableId, ok := s.D.GetOkExists("route_table_id"); ok {
322+
tmp := routeTableId.(string)
323+
request.RouteTableId = &tmp
324+
}
325+
304326
request.RequestMetadata.RetryPolicy = getRetryPolicy(s.DisableNotFoundRetries, "core")
305327

306328
response, err := s.Client.UpdateLocalPeeringGateway(context.Background(), request)
@@ -347,12 +369,18 @@ func (s *LocalPeeringGatewayResourceCrud) SetData() error {
347369
s.D.Set("peer_advertised_cidr", *s.Res.PeerAdvertisedCidr)
348370
}
349371

372+
s.D.Set("peer_advertised_cidr_details", s.Res.PeerAdvertisedCidrDetails)
373+
350374
s.D.Set("peering_status", s.Res.PeeringStatus)
351375

352376
if s.Res.PeeringStatusDetails != nil {
353377
s.D.Set("peering_status_details", *s.Res.PeeringStatusDetails)
354378
}
355379

380+
if s.Res.RouteTableId != nil {
381+
s.D.Set("route_table_id", *s.Res.RouteTableId)
382+
}
383+
356384
s.D.Set("state", s.Res.LifecycleState)
357385

358386
if s.Res.TimeCreated != nil {

oci/core_local_peering_gateway_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ var (
3232
"defined_tags": Representation{repType: Optional, create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
3333
"display_name": Representation{repType: Optional, create: `displayName`, update: `displayName2`},
3434
"freeform_tags": Representation{repType: Optional, create: map[string]string{"Department": "Finance"}, update: map[string]string{"Department": "Accounting"}},
35+
"route_table_id": Representation{repType: Required, create: `${oci_core_vcn.test_vcn.default_route_table_id}`},
3536
}
3637

3738
secondLocalPeeringGatewayRepresentation = map[string]interface{}{
@@ -86,6 +87,7 @@ func TestCoreLocalPeeringGatewayResource_basic(t *testing.T) {
8687
generateResourceFromRepresentationMap("oci_core_local_peering_gateway", "test_local_peering_gateway", Required, Create, localPeeringGatewayRepresentation),
8788
Check: resource.ComposeAggregateTestCheckFunc(
8889
resource.TestCheckResourceAttr(resourceName, "compartment_id", compartmentId),
90+
resource.TestCheckResourceAttrSet(resourceName, "route_table_id"),
8991
resource.TestCheckResourceAttrSet(resourceName, "vcn_id"),
9092

9193
func(s *terraform.State) (err error) {
@@ -111,6 +113,7 @@ func TestCoreLocalPeeringGatewayResource_basic(t *testing.T) {
111113
resource.TestCheckResourceAttrSet(resourceName, "id"),
112114
resource.TestCheckResourceAttrSet(resourceName, "is_cross_tenancy_peering"),
113115
resource.TestCheckResourceAttrSet(resourceName, "peering_status"),
116+
resource.TestCheckResourceAttrSet(resourceName, "route_table_id"),
114117
resource.TestCheckResourceAttrSet(resourceName, "state"),
115118
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
116119
resource.TestCheckResourceAttrSet(resourceName, "vcn_id"),
@@ -134,6 +137,7 @@ func TestCoreLocalPeeringGatewayResource_basic(t *testing.T) {
134137
resource.TestCheckResourceAttrSet(resourceName, "id"),
135138
resource.TestCheckResourceAttrSet(resourceName, "is_cross_tenancy_peering"),
136139
resource.TestCheckResourceAttrSet(resourceName, "peering_status"),
140+
resource.TestCheckResourceAttrSet(resourceName, "route_table_id"),
137141
resource.TestCheckResourceAttrSet(resourceName, "state"),
138142
resource.TestCheckResourceAttrSet(resourceName, "time_created"),
139143
resource.TestCheckResourceAttrSet(resourceName, "vcn_id"),
@@ -165,6 +169,7 @@ func TestCoreLocalPeeringGatewayResource_basic(t *testing.T) {
165169
resource.TestCheckResourceAttrSet(datasourceName, "local_peering_gateways.0.id"),
166170
resource.TestCheckResourceAttrSet(datasourceName, "local_peering_gateways.0.is_cross_tenancy_peering"),
167171
resource.TestCheckResourceAttrSet(datasourceName, "local_peering_gateways.0.peering_status"),
172+
resource.TestCheckResourceAttrSet(datasourceName, "local_peering_gateways.0.route_table_id"),
168173
resource.TestCheckResourceAttrSet(datasourceName, "local_peering_gateways.0.state"),
169174
resource.TestCheckResourceAttrSet(datasourceName, "local_peering_gateways.0.time_created"),
170175
resource.TestCheckResourceAttrSet(datasourceName, "local_peering_gateways.0.vcn_id"),

oci/core_local_peering_gateways_data_source.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,18 @@ func (s *LocalPeeringGatewaysDataSourceCrud) SetData() error {
121121
localPeeringGateway["peer_advertised_cidr"] = *r.PeerAdvertisedCidr
122122
}
123123

124+
localPeeringGateway["peer_advertised_cidr_details"] = r.PeerAdvertisedCidrDetails
125+
124126
localPeeringGateway["peering_status"] = r.PeeringStatus
125127

126128
if r.PeeringStatusDetails != nil {
127129
localPeeringGateway["peering_status_details"] = *r.PeeringStatusDetails
128130
}
129131

132+
if r.RouteTableId != nil {
133+
localPeeringGateway["route_table_id"] = *r.RouteTableId
134+
}
135+
130136
localPeeringGateway["state"] = r.LifecycleState
131137

132138
if r.TimeCreated != nil {

website/docs/d/core_drg_attachments.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ The following attributes are exported:
4949
* `display_name` - A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
5050
* `drg_id` - The OCID of the DRG.
5151
* `id` - The DRG attachment's Oracle ID (OCID).
52+
* `route_table_id` - The OCID of the route table the DRG attachment is using.
5253
* `state` - The DRG attachment's current state.
5354
* `time_created` - The date and time the DRG attachment was created, in the format defined by RFC3339. Example: `2016-08-25T21:10:29.600Z`
5455
* `vcn_id` - The OCID of the VCN.

website/docs/d/core_local_peering_gateways.html.markdown

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ The following attributes are exported:
4747
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
4848
* `id` - The LPG's Oracle ID (OCID).
4949
* `is_cross_tenancy_peering` - Whether the VCN at the other end of the peering is in a different tenancy. Example: `false`
50-
* `peer_advertised_cidr` - The range of IP addresses available on the VCN at the other end of the peering from this LPG. The value is `null` if the LPG is not peered. You can use this as the destination CIDR for a route rule to route a subnet's traffic to this LPG. Example: `192.168.0.0/16`
50+
* `peer_advertised_cidr` - The smallest aggregate CIDR that contains all the CIDR routes advertised by the VCN at the other end of the peering from this LPG. See `peerAdvertisedCidrDetails` for the individual CIDRs. The value is `null` if the LPG is not peered. Example: `192.168.0.0/16`, or if aggregated with `172.16.0.0/24` then `128.0.0.0/1`
51+
* `peer_advertised_cidr_details` - The specific ranges of IP addresses available on or via the VCN at the other end of the peering from this LPG. The value is `null` if the LPG is not peered. You can use these as destination CIDRs for route rules to route a subnet's traffic to this LPG. Example: [`192.168.0.0/16`, `172.16.0.0/24`]
5152
* `peering_status` - Whether the LPG is peered with another LPG. `NEW` means the LPG has not yet been peered. `PENDING` means the peering is being established. `REVOKED` means the LPG at the other end of the peering has been deleted.
5253
* `peering_status_details` - Additional information regarding the peering status, if applicable.
54+
* `route_table_id` - The OCID of the route table the LPG is using.
5355
* `state` - The LPG's current lifecycle state.
5456
* `time_created` - The date and time the LPG was created, in the format defined by RFC3339. Example: `2016-08-25T21:10:29.600Z`
5557
* `vcn_id` - The OCID of the VCN the LPG belongs to.

website/docs/r/core_drg_attachment.html.markdown

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ resource "oci_core_drg_attachment" "test_drg_attachment" {
3232
3333
#Optional
3434
display_name = "${var.drg_attachment_display_name}"
35+
route_table_id = "${oci_core_route_table.test_route_table.id}"
3536
}
3637
```
3738

@@ -41,6 +42,9 @@ The following arguments are supported:
4142

4243
* `display_name` - (Optional) (Updatable) A user-friendly name. Does not have to be unique. Avoid entering confidential information.
4344
* `drg_id` - (Required) The OCID of the DRG.
45+
* `route_table_id` - (Optional) (Updatable) The OCID of the route table the DRG attachment will use.
46+
47+
If you don't specify a route table here, the DRG attachment is created without an associated route table. The Networking service does NOT automatically associate the attached VCN's default route table with the DRG attachment.
4448
* `vcn_id` - (Required) The OCID of the VCN.
4549

4650

@@ -55,6 +59,7 @@ The following attributes are exported:
5559
* `display_name` - A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
5660
* `drg_id` - The OCID of the DRG.
5761
* `id` - The DRG attachment's Oracle ID (OCID).
62+
* `route_table_id` - The OCID of the route table the DRG attachment is using.
5863
* `state` - The DRG attachment's current state.
5964
* `time_created` - The date and time the DRG attachment was created, in the format defined by RFC3339. Example: `2016-08-25T21:10:29.600Z`
6065
* `vcn_id` - The OCID of the VCN.

website/docs/r/core_local_peering_gateway.html.markdown

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ resource "oci_core_local_peering_gateway" "test_local_peering_gateway" {
2525
display_name = "${var.local_peering_gateway_display_name}"
2626
freeform_tags = {"Department"= "Finance"}
2727
peer_id = "${oci_core_local_peering_gateway.test_local_peering_gateway2.id}"
28+
route_table_id = "${oci_core_route_table.test_route_table.id}"
2829
}
2930
```
3031

@@ -41,6 +42,9 @@ The following arguments are supported:
4142
* `display_name` - (Optional) (Updatable) A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
4243
* `freeform_tags` - (Optional) (Updatable) Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
4344
* `peer_id` - (Optional) The OCID of the LPG you want to peer with. Specifying a peer_id connects this local peering gateway (LPG) to another one in the same region. This operation must be called by the VCN administrator who is designated as the *requestor* in the peering relationship. The *acceptor* must implement an Identity and Access Management (IAM) policy that gives the requestor permission to connect to LPGs in the acceptor's compartment. Without that permission, this operation will fail. For more information, see [VCN Peering](https://docs.cloud.oracle.com/iaas/Content/Network/Tasks/VCNpeering.htm).
45+
* `route_table_id` - (Optional) (Updatable) The OCID of the route table the LPG will use.
46+
47+
If you don't specify a route table here, the LPG is created without an associated route table. The Networking service does NOT automatically associate the attached VCN's default route table with the LPG.
4448
* `vcn_id` - (Required) The OCID of the VCN the LPG belongs to.
4549

4650

@@ -57,9 +61,11 @@ The following attributes are exported:
5761
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
5862
* `id` - The LPG's Oracle ID (OCID).
5963
* `is_cross_tenancy_peering` - Whether the VCN at the other end of the peering is in a different tenancy. Example: `false`
60-
* `peer_advertised_cidr` - The range of IP addresses available on the VCN at the other end of the peering from this LPG. The value is `null` if the LPG is not peered. You can use this as the destination CIDR for a route rule to route a subnet's traffic to this LPG. Example: `192.168.0.0/16`
64+
* `peer_advertised_cidr` - The smallest aggregate CIDR that contains all the CIDR routes advertised by the VCN at the other end of the peering from this LPG. See `peerAdvertisedCidrDetails` for the individual CIDRs. The value is `null` if the LPG is not peered. Example: `192.168.0.0/16`, or if aggregated with `172.16.0.0/24` then `128.0.0.0/1`
65+
* `peer_advertised_cidr_details` - The specific ranges of IP addresses available on or via the VCN at the other end of the peering from this LPG. The value is `null` if the LPG is not peered. You can use these as destination CIDRs for route rules to route a subnet's traffic to this LPG. Example: [`192.168.0.0/16`, `172.16.0.0/24`]
6166
* `peering_status` - Whether the LPG is peered with another LPG. `NEW` means the LPG has not yet been peered. `PENDING` means the peering is being established. `REVOKED` means the LPG at the other end of the peering has been deleted.
6267
* `peering_status_details` - Additional information regarding the peering status, if applicable.
68+
* `route_table_id` - The OCID of the route table the LPG is using.
6369
* `state` - The LPG's current lifecycle state.
6470
* `time_created` - The date and time the LPG was created, in the format defined by RFC3339. Example: `2016-08-25T21:10:29.600Z`
6571
* `vcn_id` - The OCID of the VCN the LPG belongs to.

0 commit comments

Comments
 (0)