Skip to content

Commit

Permalink
Merge pull request #3421 from leibowitz/add_ad_edition_param
Browse files Browse the repository at this point in the history
Add edition parameter for MS AD
  • Loading branch information
bflad authored Feb 20, 2018
2 parents 366123f + ac9c934 commit cd21c8f
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
17 changes: 17 additions & 0 deletions aws/resource_aws_directory_service_directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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),
},
},
}
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
Expand Down
50 changes: 50 additions & 0 deletions aws/resource_aws_directory_service_directory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
},
},
Expand Down Expand Up @@ -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" {
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/directory_service_directory.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit cd21c8f

Please sign in to comment.