-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add edition parameter for MS AD #3421
Changes from 2 commits
bf275f1
5492cee
88d345f
32b98f9
65f3c03
040bb6a
91eb14c
10f8eb9
ac9c934
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,6 +155,23 @@ func resourceAwsDirectoryServiceDirectory() *schema.Resource { | |
return | ||
}, | ||
}, | ||
"edition": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
Default: "Enterprise", | ||
ForceNew: true, | ||
ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be simplified to the below 😄 ValidateFunc: validation.StringInSlice([]string{
directoryservice.DirectoryEditionEnterprise,
directoryservice.DirectoryEditionStandard,
}, false), There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked around the code to find something similar, but ended up stealing the validation from another attribute. This is much better. Thanks for that |
||
validTypes := []string{"Enterprise", "Standard"} | ||
value := v.(string) | ||
for _, validType := range validTypes { | ||
if validType == value { | ||
return | ||
} | ||
} | ||
es = append(es, fmt.Errorf("%q must be one of %q", k, validTypes)) | ||
return | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
@@ -295,6 +312,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 +465,9 @@ func resourceAwsDirectoryServiceDirectoryRead(d *schema.ResourceData, meta inter | |
if dir.Size != nil { | ||
d.Set("size", *dir.Size) | ||
} | ||
if dir.Edition != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normally this check wouldn't be necessary, however I think because we the SDK handles both SimpleAD and MicrosoftAD directory types that in fact we do want to keep this nil check in here. 👍 |
||
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)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Can you please use the SDK provided constant here?
directoryservice.DirectoryEditionEnterprise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done