provider/aws: Fixed the aws_vpc enable_dns_support handling on creation
This commit is contained in:
parent
e7411891f4
commit
281eba72ad
|
@ -23,59 +23,59 @@ func resourceAwsVpc() *schema.Resource {
|
|||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"cidr_block": &schema.Schema{
|
||||
"cidr_block": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
ValidateFunc: validateCIDRNetworkAddress,
|
||||
},
|
||||
|
||||
"instance_tenancy": &schema.Schema{
|
||||
"instance_tenancy": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"enable_dns_hostnames": &schema.Schema{
|
||||
"enable_dns_hostnames": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"enable_dns_support": &schema.Schema{
|
||||
"enable_dns_support": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"enable_classiclink": &schema.Schema{
|
||||
"enable_classiclink": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"main_route_table_id": &schema.Schema{
|
||||
"main_route_table_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"default_network_acl_id": &schema.Schema{
|
||||
"default_network_acl_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"dhcp_options_id": &schema.Schema{
|
||||
"dhcp_options_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"default_security_group_id": &schema.Schema{
|
||||
"default_security_group_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"default_route_table_id": &schema.Schema{
|
||||
"default_route_table_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
|
@ -260,7 +260,9 @@ func resourceAwsVpcUpdate(d *schema.ResourceData, meta interface{}) error {
|
|||
d.SetPartial("enable_dns_support")
|
||||
}
|
||||
|
||||
if d.HasChange("enable_dns_support") {
|
||||
_, hasEnableDnsSupportOption := d.GetOk("enable_dns_support")
|
||||
|
||||
if !hasEnableDnsSupportOption || d.HasChange("enable_dns_support") {
|
||||
val := d.Get("enable_dns_support").(bool)
|
||||
modifyOpts := &ec2.ModifyVpcAttributeInput{
|
||||
VpcId: &vpcid,
|
||||
|
|
|
@ -19,7 +19,7 @@ func TestAccAWSVpc_basic(t *testing.T) {
|
|||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckVpcDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
{
|
||||
Config: testAccVpcConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckVpcExists("aws_vpc.foo", &vpc),
|
||||
|
@ -42,7 +42,7 @@ func TestAccAWSVpc_dedicatedTenancy(t *testing.T) {
|
|||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckVpcDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
{
|
||||
Config: testAccVpcDedicatedConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckVpcExists("aws_vpc.bar", &vpc),
|
||||
|
@ -62,7 +62,7 @@ func TestAccAWSVpc_tags(t *testing.T) {
|
|||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckVpcDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
{
|
||||
Config: testAccVpcConfigTags,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckVpcExists("aws_vpc.foo", &vpc),
|
||||
|
@ -73,7 +73,7 @@ func TestAccAWSVpc_tags(t *testing.T) {
|
|||
),
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
{
|
||||
Config: testAccVpcConfigTagsUpdate,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckVpcExists("aws_vpc.foo", &vpc),
|
||||
|
@ -93,7 +93,7 @@ func TestAccAWSVpc_update(t *testing.T) {
|
|||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckVpcDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
{
|
||||
Config: testAccVpcConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckVpcExists("aws_vpc.foo", &vpc),
|
||||
|
@ -102,7 +102,7 @@ func TestAccAWSVpc_update(t *testing.T) {
|
|||
"aws_vpc.foo", "cidr_block", "10.1.0.0/16"),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
{
|
||||
Config: testAccVpcConfigUpdate,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckVpcExists("aws_vpc.foo", &vpc),
|
||||
|
@ -195,7 +195,7 @@ func TestAccAWSVpc_bothDnsOptionsSet(t *testing.T) {
|
|||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckVpcDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
{
|
||||
Config: testAccVpcConfig_BothDnsOptions,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
resource.TestCheckResourceAttr(
|
||||
|
@ -208,13 +208,31 @@ func TestAccAWSVpc_bothDnsOptionsSet(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
// https://github.com/hashicorp/terraform/issues/10168
|
||||
func TestAccAWSVpc_DisabledDnsSupport(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckVpcDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccVpcConfig_DisabledDnsSupport,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_vpc.bar", "enable_dns_support", "false"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccAWSVpc_classiclinkOptionSet(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckVpcDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
{
|
||||
Config: testAccVpcConfig_ClassiclinkOption,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
resource.TestCheckResourceAttr(
|
||||
|
@ -278,6 +296,18 @@ resource "aws_vpc" "bar" {
|
|||
}
|
||||
`
|
||||
|
||||
const testAccVpcConfig_DisabledDnsSupport = `
|
||||
provider "aws" {
|
||||
region = "eu-central-1"
|
||||
}
|
||||
|
||||
resource "aws_vpc" "bar" {
|
||||
cidr_block = "10.2.0.0/16"
|
||||
|
||||
enable_dns_support = false
|
||||
}
|
||||
`
|
||||
|
||||
const testAccVpcConfig_ClassiclinkOption = `
|
||||
resource "aws_vpc" "bar" {
|
||||
cidr_block = "172.2.0.0/16"
|
||||
|
|
Loading…
Reference in New Issue