Merge pull request #4879 from hashicorp/b-aws-vpc-classiclink-fix
providers/aws: Fix issue with VPC Classic Link and regions that don't support it
This commit is contained in:
commit
dd0475ca4e
|
@ -179,18 +179,27 @@ func resourceAwsVpcRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
DescribeClassiclinkOpts := &ec2.DescribeVpcClassicLinkInput{
|
DescribeClassiclinkOpts := &ec2.DescribeVpcClassicLinkInput{
|
||||||
VpcIds: []*string{&vpcid},
|
VpcIds: []*string{&vpcid},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Classic Link is only available in regions that support EC2 Classic
|
||||||
respClassiclink, err := conn.DescribeVpcClassicLink(DescribeClassiclinkOpts)
|
respClassiclink, err := conn.DescribeVpcClassicLink(DescribeClassiclinkOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
classiclink_enabled := false
|
classiclink_enabled := false
|
||||||
for _, v := range respClassiclink.Vpcs {
|
for _, v := range respClassiclink.Vpcs {
|
||||||
if *v.VpcId == vpcid {
|
if *v.VpcId == vpcid {
|
||||||
|
if v.ClassicLinkEnabled != nil {
|
||||||
classiclink_enabled = *v.ClassicLinkEnabled
|
classiclink_enabled = *v.ClassicLinkEnabled
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d.Set("enable_classiclink", classiclink_enabled)
|
d.Set("enable_classiclink", classiclink_enabled)
|
||||||
|
}
|
||||||
|
|
||||||
// Get the main routing table for this VPC
|
// Get the main routing table for this VPC
|
||||||
// Really Ugly need to make this better - rmenn
|
// Really Ugly need to make this better - rmenn
|
||||||
|
|
|
@ -264,6 +264,10 @@ resource "aws_vpc" "bar" {
|
||||||
`
|
`
|
||||||
|
|
||||||
const testAccVpcConfig_BothDnsOptions = `
|
const testAccVpcConfig_BothDnsOptions = `
|
||||||
|
provider "aws" {
|
||||||
|
region = "eu-central-1"
|
||||||
|
}
|
||||||
|
|
||||||
resource "aws_vpc" "bar" {
|
resource "aws_vpc" "bar" {
|
||||||
cidr_block = "10.2.0.0/16"
|
cidr_block = "10.2.0.0/16"
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,9 @@ The following arguments are supported:
|
||||||
* `instance_tenancy` - (Optional) A tenancy option for instances launched into the VPC
|
* `instance_tenancy` - (Optional) A tenancy option for instances launched into the VPC
|
||||||
* `enable_dns_support` - (Optional) A boolean flag to enable/disable DNS support in the VPC. Defaults true.
|
* `enable_dns_support` - (Optional) A boolean flag to enable/disable DNS support in the VPC. Defaults true.
|
||||||
* `enable_dns_hostnames` - (Optional) A boolean flag to enable/disable DNS hostnames in the VPC. Defaults false.
|
* `enable_dns_hostnames` - (Optional) A boolean flag to enable/disable DNS hostnames in the VPC. Defaults false.
|
||||||
* `enable_classiclink` - (Optional) A boolean flag to enable/disable ClassicLink for the VPC. Defaults false.
|
* `enable_classiclink` - (Optional) A boolean flag to enable/disable ClassicLink
|
||||||
|
for the VPC. Only valid in regions and accounts that support EC2 Classic.
|
||||||
|
See the [ClassicLink documentation][1] for more information. Defaults false.
|
||||||
* `tags` - (Optional) A mapping of tags to assign to the resource.
|
* `tags` - (Optional) A mapping of tags to assign to the resource.
|
||||||
|
|
||||||
## Attributes Reference
|
## Attributes Reference
|
||||||
|
@ -59,3 +61,6 @@ The following attributes are exported:
|
||||||
[`aws_main_route_table_association`](/docs/providers/aws/r/main_route_table_assoc.html).
|
[`aws_main_route_table_association`](/docs/providers/aws/r/main_route_table_assoc.html).
|
||||||
* `default_network_acl_id` - The ID of the network ACL created by default on VPC creation
|
* `default_network_acl_id` - The ID of the network ACL created by default on VPC creation
|
||||||
* `default_security_group_id` - The ID of the security group created by default on VPC creation
|
* `default_security_group_id` - The ID of the security group created by default on VPC creation
|
||||||
|
|
||||||
|
|
||||||
|
[1]: http://docs.aws.amazon.com/fr_fr/AWSEC2/latest/UserGuide/vpc-classiclink.html
|
||||||
|
|
Loading…
Reference in New Issue