Skip to content

Commit

Permalink
providers/aws: Fix issue with VPC Classic Link and regions that don't…
Browse files Browse the repository at this point in the history
… support it
  • Loading branch information
catsby committed Jan 28, 2016
1 parent 4cc51f6 commit 760cdab
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions builtin/providers/aws/resource_aws_vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,27 @@ func resourceAwsVpcRead(d *schema.ResourceData, meta interface{}) error {
DescribeClassiclinkOpts := &ec2.DescribeVpcClassicLinkInput{
VpcIds: []*string{&vpcid},
}

// Classic Link is only available in regions that support EC2 Classic
respClassiclink, err := conn.DescribeVpcClassicLink(DescribeClassiclinkOpts)
if err != nil {
return err
}
classiclink_enabled := false
for _, v := range respClassiclink.Vpcs {
if *v.VpcId == vpcid {
classiclink_enabled = *v.ClassicLinkEnabled
break
if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "UnsupportedOperation" {
log.Printf("[WARN] VPC Classic Link is not supported in this region")
} else {
return err
}
} else {
classiclink_enabled := false
for _, v := range respClassiclink.Vpcs {
if *v.VpcId == vpcid {
if v.ClassicLinkEnabled != nil {
classiclink_enabled = *v.ClassicLinkEnabled
}
break
}
}
d.Set("enable_classiclink", classiclink_enabled)
}
d.Set("enable_classiclink", classiclink_enabled)

// Get the main routing table for this VPC
// Really Ugly need to make this better - rmenn
Expand Down

0 comments on commit 760cdab

Please sign in to comment.