Skip to content

Commit efa6f2f

Browse files
authored
Merge pull request #37815 from nikhil-goenka/f/aws_customer_gateway
bgp_asn_extended
2 parents e358873 + edfda88 commit efa6f2f

File tree

6 files changed

+92
-5
lines changed

6 files changed

+92
-5
lines changed

.changelog/37815.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```release-note:enhancement
2+
resource/aws_customer_gateway: Add `bgp_asn_extended` argument
3+
```
4+
5+
```release-note:enhancement
6+
data-source/aws_customer_gateway: Add `bgp_asn_extended` argument
7+
```

internal/service/ec2/vpnsite_customer_gateway.go

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,18 @@ func resourceCustomerGateway() *schema.Resource {
4646
Computed: true,
4747
},
4848
"bgp_asn": {
49-
Type: schema.TypeString,
50-
Required: true,
51-
ForceNew: true,
52-
ValidateFunc: verify.Valid4ByteASN,
49+
Type: schema.TypeString,
50+
Optional: true,
51+
ForceNew: true,
52+
ValidateFunc: verify.Valid4ByteASN,
53+
ConflictsWith: []string{"bgp_asn_extended"},
54+
},
55+
"bgp_asn_extended": {
56+
Type: schema.TypeString,
57+
Optional: true,
58+
ForceNew: true,
59+
ValidateFunc: verify.Valid4ByteASN,
60+
ConflictsWith: []string{"bgp_asn"},
5361
},
5462
names.AttrCertificateARN: {
5563
Type: schema.TypeString,
@@ -102,6 +110,16 @@ func resourceCustomerGatewayCreate(ctx context.Context, d *schema.ResourceData,
102110
input.BgpAsn = aws.Int32(int32(v))
103111
}
104112

113+
if v, ok := d.GetOk("bgp_asn_extended"); ok {
114+
v, err := strconv.ParseInt(v.(string), 10, 64)
115+
116+
if err != nil {
117+
return sdkdiag.AppendFromErr(diags, err)
118+
}
119+
120+
input.BgpAsnExtended = aws.Int64(v)
121+
}
122+
105123
if v, ok := d.GetOk(names.AttrCertificateARN); ok {
106124
input.CertificateArn = aws.String(v.(string))
107125
}
@@ -154,6 +172,7 @@ func resourceCustomerGatewayRead(ctx context.Context, d *schema.ResourceData, me
154172
}.String()
155173
d.Set(names.AttrARN, arn)
156174
d.Set("bgp_asn", customerGateway.BgpAsn)
175+
d.Set("bgp_asn_extended", customerGateway.BgpAsnExtended)
157176
d.Set(names.AttrCertificateARN, customerGateway.CertificateArn)
158177
d.Set(names.AttrDeviceName, customerGateway.DeviceName)
159178
d.Set(names.AttrIPAddress, customerGateway.IpAddress)

internal/service/ec2/vpnsite_customer_gateway_data_source.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ func dataSourceCustomerGateway() *schema.Resource {
4040
Type: schema.TypeInt,
4141
Computed: true,
4242
},
43+
"bgp_asn_extended": {
44+
Type: schema.TypeInt,
45+
Computed: true,
46+
},
4347
names.AttrCertificateARN: {
4448
Type: schema.TypeString,
4549
Computed: true,
@@ -108,6 +112,17 @@ func dataSourceCustomerGatewayRead(ctx context.Context, d *schema.ResourceData,
108112
} else {
109113
d.Set("bgp_asn", nil)
110114
}
115+
if v := aws.ToString(cgw.BgpAsnExtended); v != "" {
116+
v, err := strconv.ParseInt(v, 0, 0)
117+
118+
if err != nil {
119+
return sdkdiag.AppendFromErr(diags, err)
120+
}
121+
122+
d.Set("bgp_asn_extended", v)
123+
} else {
124+
d.Set("bgp_asn_extended", nil)
125+
}
111126
d.Set(names.AttrCertificateARN, cgw.CertificateArn)
112127
d.Set(names.AttrDeviceName, cgw.DeviceName)
113128
d.Set(names.AttrIPAddress, cgw.IpAddress)

internal/service/ec2/vpnsite_customer_gateway_test.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,40 @@ func TestAccSiteVPNCustomerGateway_basic(t *testing.T) {
5656
})
5757
}
5858

59+
func TestAccSiteVPNCustomerGateway_bgpASNExtended(t *testing.T) {
60+
ctx := acctest.Context(t)
61+
var gateway awstypes.CustomerGateway
62+
rBgpAsnExtended := sdkacctest.RandIntRange(2147483648, 4294967295)
63+
resourceName := "aws_customer_gateway.test"
64+
65+
resource.ParallelTest(t, resource.TestCase{
66+
PreCheck: func() { acctest.PreCheck(ctx, t) },
67+
ErrorCheck: acctest.ErrorCheck(t, names.EC2ServiceID),
68+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
69+
CheckDestroy: testAccCheckCustomerGatewayDestroy(ctx),
70+
Steps: []resource.TestStep{
71+
{
72+
Config: testAccSiteVPNCustomerGatewayConfig_bgpASNExtended(rBgpAsnExtended),
73+
Check: resource.ComposeTestCheckFunc(
74+
testAccCheckCustomerGatewayExists(ctx, resourceName, &gateway),
75+
acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "ec2", regexache.MustCompile(`customer-gateway/cgw-.+`)),
76+
resource.TestCheckResourceAttr(resourceName, "bgp_asn_extended", strconv.Itoa(rBgpAsnExtended)),
77+
resource.TestCheckResourceAttr(resourceName, names.AttrCertificateARN, ""),
78+
resource.TestCheckResourceAttr(resourceName, names.AttrDeviceName, ""),
79+
resource.TestCheckResourceAttr(resourceName, names.AttrIPAddress, "172.0.0.1"),
80+
resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct0),
81+
resource.TestCheckResourceAttr(resourceName, names.AttrType, "ipsec.1"),
82+
),
83+
},
84+
{
85+
ResourceName: resourceName,
86+
ImportState: true,
87+
ImportStateVerify: true,
88+
},
89+
},
90+
})
91+
}
92+
5993
func TestAccSiteVPNCustomerGateway_disappears(t *testing.T) {
6094
ctx := acctest.Context(t)
6195
var gateway awstypes.CustomerGateway
@@ -298,6 +332,16 @@ resource "aws_customer_gateway" "test" {
298332
`, rBgpAsn)
299333
}
300334

335+
func testAccSiteVPNCustomerGatewayConfig_bgpASNExtended(rBgpAsnExtended int) string {
336+
return fmt.Sprintf(`
337+
resource "aws_customer_gateway" "test" {
338+
bgp_asn_extended = %[1]d
339+
ip_address = "172.0.0.1"
340+
type = "ipsec.1"
341+
}
342+
`, rBgpAsnExtended)
343+
}
344+
301345
func testAccSiteVPNCustomerGatewayConfig_tags1(rBgpAsn int, tagKey1, tagValue1 string) string {
302346
return fmt.Sprintf(`
303347
resource "aws_customer_gateway" "test" {

website/docs/d/customer_gateway.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ This data source exports the following attributes in addition to the arguments a
4848

4949
* `arn` - ARN of the customer gateway.
5050
* `bgp_asn` - Gateway's Border Gateway Protocol (BGP) Autonomous System Number (ASN).
51+
* `bgp_asn_extended` - Gateway's Border Gateway Protocol (BGP) Autonomous System Number (ASN).
5152
* `certificate_arn` - ARN for the customer gateway certificate.
5253
* `device_name` - Name for the customer gateway device.
5354
* `ip_address` - IP address of the gateway's Internet-routable external interface.

website/docs/r/customer_gateway.html.markdown

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ resource "aws_customer_gateway" "main" {
3030

3131
This resource supports the following arguments:
3232

33-
* `bgp_asn` - (Required) The gateway's Border Gateway Protocol (BGP) Autonomous System Number (ASN).
33+
* `bgp_asn` - (Optional, Forces new resource) The gateway's Border Gateway Protocol (BGP) Autonomous System Number (ASN). Valid values are from `1` to `2147483647`. Conflicts with `bgp_asn_extended`.
34+
* `bgp_asn_extended` - (Optional, Forces new resource) The gateway's Border Gateway Protocol (BGP) Autonomous System Number (ASN). Valid values are from `2147483648` to `4294967295` Conflicts with `bgp_asn`.
3435
* `certificate_arn` - (Optional) The Amazon Resource Name (ARN) for the customer gateway certificate.
3536
* `device_name` - (Optional) A name for the customer gateway device.
3637
* `ip_address` - (Optional) The IPv4 address for the customer gateway device's outside interface.

0 commit comments

Comments
 (0)