Skip to content

Commit 05fc8fc

Browse files
committed
Merge branch 'main' into f-provider-meta-simple
2 parents 27a7855 + 6332785 commit 05fc8fc

File tree

7 files changed

+175
-9
lines changed

7 files changed

+175
-9
lines changed

.changelog/45509.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/aws_odb_network_peering_connection: Add network peering creation using `odb_network_arn` for resource sharing model.
3+
```

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 6.26.0 (Unreleased)
1+
## 6.26.0 (December 10, 2025)
22

33
FEATURES:
44

@@ -19,6 +19,7 @@ ENHANCEMENTS:
1919
* resource/aws_kinesisanalyticsv2_application: Add `application_configuration.application_encryption_configuration` argument ([#45356](https://github.com/hashicorp/terraform-provider-aws/issues/45356))
2020
* resource/aws_kinesisanalyticsv2_application: Support `FLINK-1_20` as a valid value for `runtime_environment` ([#45356](https://github.com/hashicorp/terraform-provider-aws/issues/45356))
2121
* resource/aws_lambda_capacity_provider: Add resource identity support ([#45456](https://github.com/hashicorp/terraform-provider-aws/issues/45456))
22+
* resource/aws_odb_network_peering_connection: Add network peering creation using `odb_network_arn` for resource sharing model. ([#45509](https://github.com/hashicorp/terraform-provider-aws/issues/45509))
2223
* resource/aws_rds_cluster: Add `upgrade_rollout_order` attribute ([#45527](https://github.com/hashicorp/terraform-provider-aws/issues/45527))
2324
* resource/aws_s3vectors_index: Add `encryption_configuration` block ([#45470](https://github.com/hashicorp/terraform-provider-aws/issues/45470))
2425
* resource/aws_s3vectors_index: Add `metadata_configuration` block ([#45470](https://github.com/hashicorp/terraform-provider-aws/issues/45470))

internal/service/odb/network_peering_connection.go

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ func (r *resourceNetworkPeeringConnection) Schema(ctx context.Context, req resou
6868
names.AttrARN: framework.ARNAttributeComputedOnly(),
6969
names.AttrID: framework.IDAttribute(),
7070
"odb_network_id": schema.StringAttribute{
71-
Required: true,
71+
Optional: true,
72+
Computed: true,
7273
PlanModifiers: []planmodifier.String{
7374
stringplanmodifier.RequiresReplace(),
75+
stringplanmodifier.UseStateForUnknown(),
7476
},
7577
Description: "Required field. The unique identifier of the ODB network that initiates the peering connection. " +
7678
"A sample ID is odbpcx-abcdefgh12345678. Changing this will force terraform to create new resource.",
@@ -109,8 +111,10 @@ func (r *resourceNetworkPeeringConnection) Schema(ctx context.Context, req resou
109111

110112
"odb_network_arn": schema.StringAttribute{
111113
Description: "ARN of the odb network peering connection.",
114+
Optional: true,
112115
Computed: true,
113116
PlanModifiers: []planmodifier.String{
117+
stringplanmodifier.RequiresReplaceIfConfigured(),
114118
stringplanmodifier.UseStateForUnknown(),
115119
},
116120
},
@@ -157,15 +161,49 @@ func (r *resourceNetworkPeeringConnection) Schema(ctx context.Context, req resou
157161
}
158162
}
159163

164+
func (r *resourceNetworkPeeringConnection) ValidateConfig(ctx context.Context, req resource.ValidateConfigRequest, resp *resource.ValidateConfigResponse) {
165+
var data odbNetworkPeeringConnectionResourceModel
166+
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
167+
if resp.Diagnostics.HasError() {
168+
return
169+
}
170+
171+
//Neither is present
172+
if data.OdbNetworkId.IsNull() && data.OdbNetworkArn.IsNull() {
173+
err := errors.New("either odb_network_id or odb_network_arn must be present. Neither is present.")
174+
resp.Diagnostics.AddError(
175+
create.ProblemStandardMessage(names.ODB, create.ErrActionCreating, ResNameNetworkPeeringConnection, data.DisplayName.String(), err),
176+
err.Error(),
177+
)
178+
return
179+
}
180+
181+
//Both are present
182+
if !data.OdbNetworkId.IsNull() && !data.OdbNetworkArn.IsNull() {
183+
err := errors.New("either odb_network_id or odb_network_arn must be present. Both are present.")
184+
resp.Diagnostics.AddError(
185+
create.ProblemStandardMessage(names.ODB, create.ErrActionCreating, ResNameNetworkPeeringConnection, data.DisplayName.String(), err),
186+
err.Error(),
187+
)
188+
return
189+
}
190+
}
191+
160192
func (r *resourceNetworkPeeringConnection) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
161193
conn := r.Meta().ODBClient(ctx)
162194
var plan odbNetworkPeeringConnectionResourceModel
163195
resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...)
164196
if resp.Diagnostics.HasError() {
165197
return
166198
}
199+
200+
odbNetwork := plan.OdbNetworkArn
201+
if odbNetwork.IsNull() || odbNetwork.IsUnknown() {
202+
odbNetwork = plan.OdbNetworkId
203+
}
204+
167205
input := odb.CreateOdbPeeringConnectionInput{
168-
OdbNetworkId: plan.OdbNetworkId.ValueStringPointer(),
206+
OdbNetworkId: odbNetwork.ValueStringPointer(),
169207
PeerNetworkId: plan.PeerNetworkId.ValueStringPointer(),
170208
DisplayName: plan.DisplayName.ValueStringPointer(),
171209
Tags: getTagsIn(ctx),

internal/service/odb/network_peering_connection_test.go

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,74 @@ func TestAccODBNetworkPeeringConnection_basic(t *testing.T) {
7575
})
7676
}
7777

78+
func TestAccODBNetworkPeeringConnection_withARN(t *testing.T) {
79+
ctx := acctest.Context(t)
80+
81+
if testing.Short() {
82+
t.Skip("skipping long-running test in short mode")
83+
}
84+
85+
var odbPeeringResource odb.GetOdbPeeringConnectionOutput
86+
odbPeeringDisplayName := sdkacctest.RandomWithPrefix(oracleDBNwkPeeringTestResource.odbPeeringDisplayNamePrefix)
87+
vpcName := sdkacctest.RandomWithPrefix(oracleDBNwkPeeringTestResource.vpcNamePrefix)
88+
odbNetName := sdkacctest.RandomWithPrefix(oracleDBNwkPeeringTestResource.odbNwkDisplayNamePrefix)
89+
resourceName := "aws_odb_network_peering_connection.test"
90+
91+
resource.ParallelTest(t, resource.TestCase{
92+
PreCheck: func() {
93+
acctest.PreCheck(ctx, t)
94+
oracleDBNwkPeeringTestResource.testAccPreCheck(ctx, t)
95+
},
96+
ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID),
97+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
98+
CheckDestroy: oracleDBNwkPeeringTestResource.testAccCheckNetworkPeeringConnectionDestroy(ctx),
99+
Steps: []resource.TestStep{
100+
{
101+
Config: oracleDBNwkPeeringTestResource.basicConfigWithARN(vpcName, odbNetName, odbPeeringDisplayName),
102+
Check: resource.ComposeAggregateTestCheckFunc(
103+
testAccCheckNetworkPeeringConnectionExists(ctx, resourceName, &odbPeeringResource),
104+
resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, "1"),
105+
resource.TestCheckResourceAttr(resourceName, "tags.env", "dev"),
106+
),
107+
},
108+
{
109+
ResourceName: resourceName,
110+
ImportState: true,
111+
ImportStateVerify: true,
112+
},
113+
},
114+
})
115+
}
116+
117+
func TestAccODBNetworkPeeringConnection_variables(t *testing.T) {
118+
ctx := acctest.Context(t)
119+
if testing.Short() {
120+
t.Skip("skipping long-running test in short mode")
121+
}
122+
123+
odbPeeringDisplayName := sdkacctest.RandomWithPrefix(oracleDBNwkPeeringTestResource.odbPeeringDisplayNamePrefix)
124+
vpcName := sdkacctest.RandomWithPrefix(oracleDBNwkPeeringTestResource.vpcNamePrefix)
125+
odbNetName := sdkacctest.RandomWithPrefix(oracleDBNwkPeeringTestResource.odbNwkDisplayNamePrefix)
126+
127+
resource.ParallelTest(t, resource.TestCase{
128+
PreCheck: func() {
129+
acctest.PreCheck(ctx, t)
130+
vmClusterTestEntity.testAccPreCheck(ctx, t)
131+
},
132+
ErrorCheck: acctest.ErrorCheck(t, names.ODBServiceID),
133+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
134+
CheckDestroy: oracleDBNwkPeeringTestResource.testAccCheckNetworkPeeringConnectionDestroy(ctx),
135+
Steps: []resource.TestStep{
136+
// nosemgrep:ci.semgrep.acctest.checks.replace-planonly-checks
137+
{
138+
Config: oracleDBNwkPeeringTestResource.basicConfig_useVariables(vpcName, odbNetName, odbPeeringDisplayName),
139+
PlanOnly: true,
140+
ExpectNonEmptyPlan: true,
141+
},
142+
},
143+
})
144+
}
145+
78146
func TestAccODBNetworkPeeringConnection_tagging(t *testing.T) {
79147
ctx := acctest.Context(t)
80148

@@ -260,6 +328,62 @@ resource "aws_odb_network_peering_connection" "test" {
260328
`, vpcName, odbNetName, odbPeeringName)
261329
}
262330

331+
func (oracleDBNwkPeeringResourceTest) basicConfig_useVariables(vpcName, odbNetName, odbPeeringName string) string {
332+
return fmt.Sprintf(`
333+
resource "aws_vpc" "test" {
334+
cidr_block = "10.0.0.0/16"
335+
tags = {
336+
Name = %[1]q
337+
}
338+
}
339+
340+
variable odb_network_id {
341+
default = "odbnet_3l9st3litg"
342+
type = string
343+
description = "ODB Network"
344+
}
345+
346+
resource "aws_odb_network_peering_connection" "test" {
347+
display_name = %[3]q
348+
odb_network_id = var.odb_network_id
349+
peer_network_id = aws_vpc.test.id
350+
tags = {
351+
"env" = "dev"
352+
}
353+
}
354+
`, vpcName, odbNetName, odbPeeringName)
355+
}
356+
357+
func (oracleDBNwkPeeringResourceTest) basicConfigWithARN(vpcName, odbNetName, odbPeeringName string) string {
358+
return fmt.Sprintf(`
359+
360+
resource "aws_vpc" "test" {
361+
cidr_block = "10.0.0.0/16"
362+
tags = {
363+
Name = %[1]q
364+
}
365+
}
366+
367+
resource "aws_odb_network" "test" {
368+
display_name = %[2]q
369+
availability_zone_id = "use1-az6"
370+
client_subnet_cidr = "10.2.0.0/24"
371+
backup_subnet_cidr = "10.2.1.0/24"
372+
s3_access = "DISABLED"
373+
zero_etl_access = "DISABLED"
374+
}
375+
376+
resource "aws_odb_network_peering_connection" "test" {
377+
display_name = %[3]q
378+
odb_network_id = aws_odb_network.test.arn
379+
peer_network_id = aws_vpc.test.id
380+
tags = {
381+
"env" = "dev"
382+
}
383+
}
384+
`, vpcName, odbNetName, odbPeeringName)
385+
}
386+
263387
func (oracleDBNwkPeeringResourceTest) basicConfigNoTag(vpcName, odbNetName, odbPeeringName string) string {
264388
return fmt.Sprintf(`
265389
resource "aws_vpc" "test" {

internal/service/ssm/parameter_list_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) HashiCorp, Inc.
1+
// Copyright IBM Corp. 2014, 2025
22
// SPDX-License-Identifier: MPL-2.0
33

44
package ssm_test

version/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.25.1
1+
6.26.0

website/docs/r/odb_network_peering_connection.html.markdown

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: |-
88

99
# Resource: aws_odb_network_peering_connection
1010

11-
Terraform resource for managing oracle database network peering resource in AWS.
11+
Terraform resource for managing oracle database network peering resource in AWS. If underlying odb network is shared, ARN must be used while creating network peering.
1212

1313
You can find out more about Oracle Database@AWS from [User Guide](https://docs.aws.amazon.com/odb/latest/UserGuide/what-is-odb.html).
1414

@@ -31,12 +31,13 @@ resource "aws_odb_network_peering_connection" "example" {
3131

3232
The following arguments are required:
3333

34-
* `odb_network_id` - (Required) The unique identifier of the ODB network that initiates the peering connection. A sample ID is `odbpcx-abcdefgh12345678`. Changing this will force Terraform to create a new resource.
35-
* `peer_network_id` - (Required) The unique identifier of the ODB peering connection. Changing this will force Terraform to create a new resource.
34+
* `peer_network_id` - (Required) The unique identifier of the ODB peering connection. Changing this will force Terraform to create a new resource. Either odb_network_id or odb_network_arn should be used.
3635
* `display_name` - (Required) Display name of the ODB network peering connection. Changing this will force Terraform to create a new resource.
3736

3837
The following arguments are optional:
3938

39+
* `odb_network_id` - (Optional) The unique identifier of the ODB network that initiates the peering connection. A sample ID is `odbpcx-abcdefgh12345678`. Changing this will force Terraform to create a new resource.
40+
* `odb_network_arn` - (Optional) ARN of the ODB network that initiates the peering connection. Changing this will force Terraform to create a new resource. Either odb_network_id or odb_network_arn should be used.
4041
* `region` - (Optional) Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the [provider configuration](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#aws-configuration-reference).
4142
* `tags` - (Optional) A map of tags to assign to the resource. If configured with a provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level.
4243

@@ -47,7 +48,6 @@ This data source exports the following attributes in addition to the arguments a
4748
* `id` - Unique identifier of odb network peering connection.
4849
* `status` - Status of the ODB network peering connection.
4950
* `status_reason` - The reason for the current status of the ODB peering connection.
50-
* `odb_network_arn` - ARN of the ODB network peering connection.
5151
* `peer_network_arn` - ARN of the peer network peering connection.
5252
* `odb_peering_connection_type` - Type of the ODB peering connection.
5353
* `created_at` - Created time of the ODB network peering connection.

0 commit comments

Comments
 (0)