Skip to content

Commit

Permalink
Merge pull request #3367 from terraform-providers/b-dx-lag-ignore-def…
Browse files Browse the repository at this point in the history
…ault-conn

resource/aws_dx_lag: Deprecate number_of_connections
  • Loading branch information
radeksimko authored Feb 14, 2018
2 parents b63533c + 7bc7a8e commit 3d0ac5d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
2 changes: 0 additions & 2 deletions aws/resource_aws_dx_connection_association_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ resource "aws_dx_lag" "test" {
name = "tf-dx-%s"
connections_bandwidth = "1Gbps"
location = "EqSe2"
number_of_connections = 1
force_destroy = true
}
Expand Down Expand Up @@ -121,7 +120,6 @@ resource "aws_dx_lag" "test" {
name = "tf-dx-%s"
connections_bandwidth = "1Gbps"
location = "EqSe2"
number_of_connections = 1
force_destroy = true
}
Expand Down
18 changes: 15 additions & 3 deletions aws/resource_aws_dx_lag.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ func resourceAwsDxLag() *schema.Resource {
},
"number_of_connections": {
Type: schema.TypeInt,
Required: true,
Optional: true,
Computed: true,
ForceNew: true,
Deprecated: "Use aws_dx_connection and aws_dx_connection_association resources instead. " +
"Default connections will be removed as part of LAG creation automatically in future versions.",
},
"force_destroy": {
Type: schema.TypeBool,
Expand All @@ -57,11 +60,18 @@ func resourceAwsDxLag() *schema.Resource {
func resourceAwsDxLagCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).dxconn

var noOfConnections int
if v, ok := d.GetOk("number_of_connections"); ok {
noOfConnections = v.(int)
} else {
noOfConnections = 1
}

req := &directconnect.CreateLagInput{
ConnectionsBandwidth: aws.String(d.Get("connections_bandwidth").(string)),
LagName: aws.String(d.Get("name").(string)),
Location: aws.String(d.Get("location").(string)),
NumberOfConnections: aws.Int64(int64(d.Get("number_of_connections").(int))),
NumberOfConnections: aws.Int64(int64(noOfConnections)),
}

log.Printf("[DEBUG] Creating Direct Connect LAG: %#v", req)
Expand All @@ -70,6 +80,9 @@ func resourceAwsDxLagCreate(d *schema.ResourceData, meta interface{}) error {
return err
}

// TODO: Remove default connection(s) automatically provisioned by AWS
// per NumberOfConnections

d.SetId(aws.StringValue(resp.LagId))
return resourceAwsDxLagUpdate(d, meta)
}
Expand Down Expand Up @@ -119,7 +132,6 @@ func resourceAwsDxLagRead(d *schema.ResourceData, meta interface{}) error {
d.Set("name", lag.LagName)
d.Set("connections_bandwidth", lag.ConnectionsBandwidth)
d.Set("location", lag.Location)
d.Set("number_of_connections", lag.NumberOfConnections)

if err := getTagsDX(conn, d, arn); err != nil {
return err
Expand Down
5 changes: 0 additions & 5 deletions aws/resource_aws_dx_lag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func TestAccAwsDxLag_basic(t *testing.T) {
resource.TestCheckResourceAttr("aws_dx_lag.hoge", "name", lagName1),
resource.TestCheckResourceAttr("aws_dx_lag.hoge", "connections_bandwidth", "1Gbps"),
resource.TestCheckResourceAttr("aws_dx_lag.hoge", "location", "EqSe2"),
resource.TestCheckResourceAttr("aws_dx_lag.hoge", "number_of_connections", "2"),
resource.TestCheckResourceAttr("aws_dx_lag.hoge", "tags.%", "0"),
),
},
Expand All @@ -38,7 +37,6 @@ func TestAccAwsDxLag_basic(t *testing.T) {
resource.TestCheckResourceAttr("aws_dx_lag.hoge", "name", lagName2),
resource.TestCheckResourceAttr("aws_dx_lag.hoge", "connections_bandwidth", "1Gbps"),
resource.TestCheckResourceAttr("aws_dx_lag.hoge", "location", "EqSe2"),
resource.TestCheckResourceAttr("aws_dx_lag.hoge", "number_of_connections", "2"),
resource.TestCheckResourceAttr("aws_dx_lag.hoge", "tags.%", "0"),
),
},
Expand Down Expand Up @@ -127,7 +125,6 @@ resource "aws_dx_lag" "hoge" {
name = "%s"
connections_bandwidth = "1Gbps"
location = "EqSe2"
number_of_connections = 2
force_destroy = true
}
`, n)
Expand All @@ -139,7 +136,6 @@ resource "aws_dx_lag" "hoge" {
name = "%s"
connections_bandwidth = "1Gbps"
location = "EqSe2"
number_of_connections = 2
force_destroy = true
tags {
Expand All @@ -156,7 +152,6 @@ resource "aws_dx_lag" "hoge" {
name = "%s"
connections_bandwidth = "1Gbps"
location = "EqSe2"
number_of_connections = 2
force_destroy = true
tags {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/dx_lag.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The following arguments are supported:
* `name` - (Required) The name of the LAG.
* `connections_bandwidth` - (Required) The bandwidth of the individual physical connections bundled by the LAG. Available values: 1Gbps, 10Gbps. Case sensitive.
* `location` - (Required) The AWS Direct Connect location in which the LAG should be allocated. See [DescribeLocations](https://docs.aws.amazon.com/directconnect/latest/APIReference/API_DescribeLocations.html) for the list of AWS Direct Connect locations. Use `locationCode`.
* `number_of_connections` - (Required) The number of physical connections initially provisioned and bundled by the LAG.
* `number_of_connections` - (**Deprecated**) The number of physical connections initially provisioned and bundled by the LAG. Use `aws_dx_connection` and `aws_dx_connection_association` resources instead. Default connections will be removed as part of LAG creation automatically in future versions.
* `force_destroy` - (Optional, Default:false) A boolean that indicates all connections associated with the LAG should be deleted so that the LAG can be destroyed without error. These objects are *not* recoverable.
* `tags` - (Optional) A mapping of tags to assign to the resource.

Expand Down

0 comments on commit 3d0ac5d

Please sign in to comment.