diff --git a/aws/resource_aws_directory_service_directory.go b/aws/resource_aws_directory_service_directory.go index 9de42ed3b0b..35e7ff293d5 100644 --- a/aws/resource_aws_directory_service_directory.go +++ b/aws/resource_aws_directory_service_directory.go @@ -11,6 +11,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/directoryservice" "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/helper/validation" ) var directoryCreationFuncs = map[string]func(*directoryservice.DirectoryService, *schema.ResourceData) (string, error){ @@ -155,6 +156,16 @@ func resourceAwsDirectoryServiceDirectory() *schema.Resource { return }, }, + "edition": { + Type: schema.TypeString, + Optional: true, + Default: directoryservice.DirectoryEditionEnterprise, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + directoryservice.DirectoryEditionEnterprise, + directoryservice.DirectoryEditionStandard, + }, false), + }, }, } } @@ -295,6 +306,9 @@ func createActiveDirectoryService(dsconn *directoryservice.DirectoryService, d * if v, ok := d.GetOk("short_name"); ok { input.ShortName = aws.String(v.(string)) } + if v, ok := d.GetOk("edition"); ok { + input.Edition = aws.String(v.(string)) + } input.VpcSettings, err = buildVpcSettings(d) if err != nil { @@ -445,6 +459,9 @@ func resourceAwsDirectoryServiceDirectoryRead(d *schema.ResourceData, meta inter if dir.Size != nil { d.Set("size", *dir.Size) } + if dir.Edition != nil { + d.Set("edition", *dir.Edition) + } d.Set("type", *dir.Type) d.Set("vpc_settings", flattenDSVpcSettings(dir.VpcSettings)) d.Set("connect_settings", flattenDSConnectSettings(dir.DnsIpAddrs, dir.ConnectSettings)) diff --git a/aws/resource_aws_directory_service_directory_test.go b/aws/resource_aws_directory_service_directory_test.go index a027b5dd5af..9c2448402b9 100644 --- a/aws/resource_aws_directory_service_directory_test.go +++ b/aws/resource_aws_directory_service_directory_test.go @@ -132,6 +132,24 @@ func TestAccAWSDirectoryServiceDirectory_microsoft(t *testing.T) { Config: testAccDirectoryServiceDirectoryConfig_microsoft, Check: resource.ComposeTestCheckFunc( testAccCheckServiceDirectoryExists("aws_directory_service_directory.bar"), + resource.TestCheckResourceAttr("aws_directory_service_discovery.bar", "edition", directoryservice.DirectoryEditionEnterprise), + ), + }, + }, + }) +} + +func TestAccAWSDirectoryServiceDirectory_microsoftStandard(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckDirectoryServiceDirectoryDestroy, + Steps: []resource.TestStep{ + { + Config: testAccDirectoryServiceDirectoryConfig_microsoftStandard, + Check: resource.ComposeTestCheckFunc( + testAccCheckServiceDirectoryExists("aws_directory_service_directory.bar"), + resource.TestCheckResourceAttr("aws_directory_service_discovery.bar", "edition", directoryservice.DirectoryEditionStandard), ), }, }, @@ -455,6 +473,38 @@ resource "aws_subnet" "bar" { } ` +const testAccDirectoryServiceDirectoryConfig_microsoftStandard = ` +resource "aws_directory_service_directory" "bar" { + name = "corp.notexample.com" + password = "SuperSecretPassw0rd" + type = "MicrosoftAD" + edition = "Standard" + + vpc_settings { + vpc_id = "${aws_vpc.main.id}" + subnet_ids = ["${aws_subnet.foo.id}", "${aws_subnet.bar.id}"] + } +} + +resource "aws_vpc" "main" { + cidr_block = "10.0.0.0/16" + tags { + Name = "terraform-testacc-directory-service-directory-microsoft" + } +} + +resource "aws_subnet" "foo" { + vpc_id = "${aws_vpc.main.id}" + availability_zone = "us-west-2a" + cidr_block = "10.0.1.0/24" +} +resource "aws_subnet" "bar" { + vpc_id = "${aws_vpc.main.id}" + availability_zone = "us-west-2b" + cidr_block = "10.0.2.0/24" +} +` + var randomInteger = acctest.RandInt() var testAccDirectoryServiceDirectoryConfig_withAlias = fmt.Sprintf(` resource "aws_directory_service_directory" "bar_a" { diff --git a/website/docs/r/directory_service_directory.html.markdown b/website/docs/r/directory_service_directory.html.markdown index 99a44bf3f49..3e323123858 100644 --- a/website/docs/r/directory_service_directory.html.markdown +++ b/website/docs/r/directory_service_directory.html.markdown @@ -62,6 +62,7 @@ The following arguments are supported: * `short_name` - (Optional) The short name of the directory, such as `CORP`. * `enable_sso` - (Optional) Whether to enable single-sign on for the directory. Requires `alias`. Defaults to `false`. * `type` (Optional) - The directory type (`SimpleAD` or `MicrosoftAD` are accepted values). Defaults to `SimpleAD`. +* `edition` - (Optional) The MicrosoftAD edition (`Standard` or `Enterprise`). Defaults to `Enterprise` (applies to MicrosoftAD type only). * `tags` - (Optional) A mapping of tags to assign to the resource. **vpc_settings** supports the following: