Skip to content

Commit a747a98

Browse files
authored
Merge pull request #45462 from hashicorp/b-transitgateway-crash
r/aws_ec2_transit_gateway: fix crash setting `encryption_support`
2 parents 5c37ae2 + 65742ce commit a747a98

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

.changelog/45462.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```release-note:bug
2+
resource/aws_ec2_transit_gateway: Fix potential crash when setting `encryption_support`. This addresses a regression introduced in [v6.25.0](https://github.com/hashicorp/terraform-provider-aws/blob/main/CHANGELOG.md#6250-december-4-2025).
3+
```
4+
5+
```release-note:bug
6+
data-source/aws_ec2_transit_gateway: Fix potential crash when reading `encryption_support`. This addresses a regression introduced in [v6.25.0](https://github.com/hashicorp/terraform-provider-aws/blob/main/CHANGELOG.md#6250-december-4-2025).
7+
```

internal/service/ec2/transitgateway_.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,18 @@ func resourceTransitGatewayRead(ctx context.Context, d *schema.ResourceData, met
235235
d.Set("default_route_table_propagation", transitGateway.Options.DefaultRouteTablePropagation)
236236
d.Set(names.AttrDescription, transitGateway.Description)
237237
d.Set("dns_support", transitGateway.Options.DnsSupport)
238-
var encryptionSupport string
239-
encryptionState := transitGateway.Options.EncryptionSupport.EncryptionState
240-
if encryptionState == awstypes.EncryptionStateValueEnabled || encryptionState == awstypes.EncryptionStateValueEnabling {
241-
encryptionSupport = string(awstypes.EncryptionSupportOptionValueEnable)
242-
} else {
243-
encryptionSupport = string(awstypes.EncryptionSupportOptionValueDisable)
238+
239+
if transitGateway.Options.EncryptionSupport != nil {
240+
var encryptionSupport string
241+
encryptionState := transitGateway.Options.EncryptionSupport.EncryptionState
242+
if encryptionState == awstypes.EncryptionStateValueEnabled || encryptionState == awstypes.EncryptionStateValueEnabling {
243+
encryptionSupport = string(awstypes.EncryptionSupportOptionValueEnable)
244+
} else {
245+
encryptionSupport = string(awstypes.EncryptionSupportOptionValueDisable)
246+
}
247+
d.Set("encryption_support", encryptionSupport)
244248
}
245-
d.Set("encryption_support", encryptionSupport)
249+
246250
d.Set("multicast_support", transitGateway.Options.MulticastSupport)
247251
d.Set(names.AttrOwnerID, transitGateway.OwnerId)
248252
d.Set("propagation_default_route_table_id", transitGateway.Options.PropagationDefaultRouteTableId)

internal/service/ec2/transitgateway_data_source.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,18 @@ func dataSourceTransitGatewayRead(ctx context.Context, d *schema.ResourceData, m
137137
d.Set("default_route_table_propagation", transitGateway.Options.DefaultRouteTablePropagation)
138138
d.Set(names.AttrDescription, transitGateway.Description)
139139
d.Set("dns_support", transitGateway.Options.DnsSupport)
140-
var encryptionSupport string
141-
encryptionState := transitGateway.Options.EncryptionSupport.EncryptionState
142-
if encryptionState == awstypes.EncryptionStateValueEnabled || encryptionState == awstypes.EncryptionStateValueEnabling {
143-
encryptionSupport = string(awstypes.EncryptionSupportOptionValueEnable)
144-
} else {
145-
encryptionSupport = string(awstypes.EncryptionSupportOptionValueDisable)
140+
141+
if transitGateway.Options.EncryptionSupport != nil {
142+
var encryptionSupport string
143+
encryptionState := transitGateway.Options.EncryptionSupport.EncryptionState
144+
if encryptionState == awstypes.EncryptionStateValueEnabled || encryptionState == awstypes.EncryptionStateValueEnabling {
145+
encryptionSupport = string(awstypes.EncryptionSupportOptionValueEnable)
146+
} else {
147+
encryptionSupport = string(awstypes.EncryptionSupportOptionValueDisable)
148+
}
149+
d.Set("encryption_support", encryptionSupport)
146150
}
147-
d.Set("encryption_support", encryptionSupport)
151+
148152
d.Set("multicast_support", transitGateway.Options.MulticastSupport)
149153
d.Set(names.AttrOwnerID, transitGateway.OwnerId)
150154
d.Set("propagation_default_route_table_id", transitGateway.Options.PropagationDefaultRouteTableId)

0 commit comments

Comments
 (0)