-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resource/aws_dx_private_virtual_interface: Update resource to support MTU param #6141
Changes from 16 commits
5298e48
d549990
b5f9c82
cdecb24
4b3d2f0
c4593cc
636db33
257a94a
4cff326
0cf60ab
83b25df
bd5798b
1d75428
6f8738b
1e6b61a
77e465a
da69517
1a7b0d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,11 +84,22 @@ func resourceAwsDxPrivateVirtualInterface() *schema.Resource { | |
Computed: true, | ||
ForceNew: true, | ||
}, | ||
"mtu": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See |
||
Type: schema.TypeInt, | ||
Default: 1500, | ||
Optional: true, | ||
ValidateFunc: validateIntegerInSlice([]int{1500, 9001}), | ||
}, | ||
"jumbo_frame_capable": { | ||
Type: schema.TypeBool, | ||
Computed: true, | ||
}, | ||
"tags": tagsSchema(), | ||
}, | ||
|
||
Timeouts: &schema.ResourceTimeout{ | ||
Create: schema.DefaultTimeout(10 * time.Minute), | ||
Update: schema.DefaultTimeout(10 * time.Minute), | ||
Delete: schema.DefaultTimeout(10 * time.Minute), | ||
}, | ||
} | ||
|
@@ -111,6 +122,7 @@ func resourceAwsDxPrivateVirtualInterfaceCreate(d *schema.ResourceData, meta int | |
Vlan: aws.Int64(int64(d.Get("vlan").(int))), | ||
Asn: aws.Int64(int64(d.Get("bgp_asn").(int))), | ||
AddressFamily: aws.String(d.Get("address_family").(string)), | ||
Mtu: aws.Int64(int64(d.Get("mtu").(int))), | ||
}, | ||
} | ||
if vgwOk && vgwIdRaw.(string) != "" { | ||
|
@@ -145,7 +157,7 @@ func resourceAwsDxPrivateVirtualInterfaceCreate(d *schema.ResourceData, meta int | |
}.String() | ||
d.Set("arn", arn) | ||
|
||
if err := dxPrivateVirtualInterfaceWaitUntilAvailable(d, conn); err != nil { | ||
if err := dxPrivateVirtualInterfaceWaitUntilAvailable(conn, d.Id(), d.Timeout(schema.TimeoutCreate)); err != nil { | ||
return err | ||
} | ||
|
||
|
@@ -175,6 +187,8 @@ func resourceAwsDxPrivateVirtualInterfaceRead(d *schema.ResourceData, meta inter | |
d.Set("amazon_address", vif.AmazonAddress) | ||
d.Set("vpn_gateway_id", vif.VirtualGatewayId) | ||
d.Set("dx_gateway_id", vif.DirectConnectGatewayId) | ||
d.Set("mtu", vif.Mtu) | ||
d.Set("jumbo_frame_capable", vif.JumboFrameCapable) | ||
if err := getTagsDX(conn, d, d.Get("arn").(string)); err != nil { | ||
return err | ||
} | ||
|
@@ -187,6 +201,10 @@ func resourceAwsDxPrivateVirtualInterfaceUpdate(d *schema.ResourceData, meta int | |
return err | ||
} | ||
|
||
if err := dxPrivateVirtualInterfaceWaitUntilAvailable(meta.(*AWSClient).dxconn, d.Id(), d.Timeout(schema.TimeoutUpdate)); err != nil { | ||
return err | ||
} | ||
|
||
return resourceAwsDxPrivateVirtualInterfaceRead(d, meta) | ||
} | ||
|
||
|
@@ -207,10 +225,11 @@ func resourceAwsDxPrivateVirtualInterfaceImport(d *schema.ResourceData, meta int | |
return []*schema.ResourceData{d}, nil | ||
} | ||
|
||
func dxPrivateVirtualInterfaceWaitUntilAvailable(d *schema.ResourceData, conn *directconnect.DirectConnect) error { | ||
func dxPrivateVirtualInterfaceWaitUntilAvailable(conn *directconnect.DirectConnect, vifId string, timeout time.Duration) error { | ||
return dxVirtualInterfaceWaitUntilAvailable( | ||
d, | ||
conn, | ||
vifId, | ||
timeout, | ||
[]string{ | ||
directconnect.VirtualInterfaceStatePending, | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,49 @@ func TestAccAwsDxPrivateVirtualInterface_dxGateway(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccAwsDxPrivateVirtualInterface_mtuUpdate(t *testing.T) { | ||
key := "DX_CONNECTION_ID" | ||
connectionId := os.Getenv(key) | ||
if connectionId == "" { | ||
t.Skipf("Environment variable %s is not set", key) | ||
} | ||
vifName := fmt.Sprintf("terraform-testacc-dxvif-%s", acctest.RandString(5)) | ||
bgpAsn := randIntRange(64512, 65534) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckAwsDxPrivateVirtualInterfaceDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDxPrivateVirtualInterfaceConfig_noTags(connectionId, vifName, bgpAsn), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAwsDxPrivateVirtualInterfaceExists("aws_dx_private_virtual_interface.foo"), | ||
resource.TestCheckResourceAttr("aws_dx_private_virtual_interface.foo", "name", vifName), | ||
resource.TestCheckResourceAttr("aws_dx_private_virtual_interface.foo", "mtu", "1500"), | ||
resource.TestCheckResourceAttr("aws_dx_private_virtual_interface.foo", "jumbo_frame_capable", "1"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to change this to resource.TestCheckResourceAttr("aws_dx_private_virtual_interface.foo", "jumbo_frame_capable", "true"), or else will get errors like $ DX_CONNECTION_ID=dxcon-xxxxxxxx AWS_DEFAULT_REGION=us-east-1 make testacc TESTARGS='-run=TestAccAwsDxPrivateVirtualInterface_mtuUpdate'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccAwsDxPrivateVirtualInterface_mtuUpdate -timeout 120m
? github.com/terraform-providers/terraform-provider-aws [no test files]
=== RUN TestAccAwsDxPrivateVirtualInterface_mtuUpdate
--- FAIL: TestAccAwsDxPrivateVirtualInterface_mtuUpdate (667.21s)
testing.go:538: Step 0 error: Check failed: Check 4/4 error: aws_dx_private_virtual_interface.foo: Attribute 'jumbo_frame_capable' expected "1", got "true"
FAIL
FAIL github.com/terraform-providers/terraform-provider-aws/aws 668.068s
make: *** [testacc] Error 1 |
||
), | ||
}, | ||
{ | ||
Config: testAccDxPrivateVirtualInterfaceConfig_jumboFrames(connectionId, vifName, bgpAsn), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAwsDxPrivateVirtualInterfaceExists("aws_dx_private_virtual_interface.foo"), | ||
resource.TestCheckResourceAttr("aws_dx_private_virtual_interface.foo", "name", vifName), | ||
resource.TestCheckResourceAttr("aws_dx_private_virtual_interface.foo", "mtu", "9001"), | ||
), | ||
}, | ||
{ | ||
Config: testAccDxPrivateVirtualInterfaceConfig_noTags(connectionId, vifName, bgpAsn), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAwsDxPrivateVirtualInterfaceExists("aws_dx_private_virtual_interface.foo"), | ||
resource.TestCheckResourceAttr("aws_dx_private_virtual_interface.foo", "name", vifName), | ||
resource.TestCheckResourceAttr("aws_dx_private_virtual_interface.foo", "mtu", "1500"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCheckAwsDxPrivateVirtualInterfaceDestroy(s *terraform.State) error { | ||
conn := testAccProvider.Meta().(*AWSClient).dxconn | ||
|
||
|
@@ -177,3 +220,24 @@ resource "aws_dx_private_virtual_interface" "foo" { | |
} | ||
`, n, amzAsn, cid, n, bgpAsn) | ||
} | ||
|
||
func testAccDxPrivateVirtualInterfaceConfig_jumboFrames(cid, n string, bgpAsn int) string { | ||
return fmt.Sprintf(` | ||
resource "aws_vpn_gateway" "foo" { | ||
tags { | ||
Name = "%s" | ||
} | ||
} | ||
|
||
resource "aws_dx_private_virtual_interface" "foo" { | ||
connection_id = "%s" | ||
|
||
vpn_gateway_id = "${aws_vpn_gateway.foo.id}" | ||
name = "%s" | ||
vlan = 4094 | ||
address_family = "ipv4" | ||
bgp_asn = %d | ||
mtu = 9001 | ||
} | ||
`, n, cid, n, bgpAsn) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍