Skip to content
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

New resource: aws_directory_service_conditional_forwarder #4071

Merged
merged 3 commits into from
Apr 13, 2018

Conversation

spirius
Copy link
Contributor

@spirius spirius commented Apr 5, 2018

Test result

TF_ACC=1 go test -v -run=TestACCAwsDirectoryServiceConditionForwarder_* -timeout 120m
=== RUN   TestACCAwsDirectoryServiceConditionForwarder_basic
--- PASS: TestACCAwsDirectoryServiceConditionForwarder_basic (1739.65s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws   1739.686s

@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Apr 5, 2018
@bflad bflad added new-resource Introduces a new resource. service/directoryservice labels Apr 5, 2018
@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Apr 8, 2018
@spirius spirius changed the title [WIP] New resource: aws_directory_service_conditional_forwarder New resource: aws_directory_service_conditional_forwarder Apr 8, 2018
@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Apr 8, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work, @spirius! This PR looked pretty well implemented and I only had a few nitpicks which I will take care of on merge. Thanks so much! 🚀

1 test passed (all tests)
=== RUN   TestACCAwsDirectoryServiceConditionForwarder_basic
--- PASS: TestACCAwsDirectoryServiceConditionForwarder_basic (1831.84s)

},

Schema: map[string]*schema.Schema{
"directory_id": &schema.Schema{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: The &schema.Schema declarations here are extra as of Go 1.7 since its declared above in map[string]*schema.Schema

},
},

"domain_name": &schema.Schema{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To match the API, should this attribute be remote_domain_name?

Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringMatch(regexp.MustCompile("^([a-zA-Z0-9]+[\\.-])+([a-zA-Z0-9])+[.]?$"), "'domain_name' is incorrect"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent usage of validation.StringMatch()! Should we maybe return a more helpful error message like invalid value, see the RemoteDomainName attribute documentation: https://docs.aws.amazon.com/directoryservice/latest/devguide/API_ConditionalForwarder.html?

return err
}

d.SetId("")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick: we no longer require d.SetId("") on deletion 👍 #4191


if err != nil {
if isAWSErr(err, directoryservice.ErrCodeEntityDoesNotExistException, "") {
d.SetId("")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick: we should log here and below when we're removing a resource 👍 log.Printf("[WARN] Directory Service Conditional Forwarder (%s) not found, removing from state", d.Id())


d.Set("dns_ips", flattenStringList(cfd.DnsIpAddrs))
d.Set("directory_id", directoryId)
d.Set("domain_name", *cfd.RemoteDomainName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: To prevent a panic in the unlikely scenario of AWS not returning this value, we should either remove the * dereference (d.Set() can automatically handle nil values) or wrap it in aws.StringValue(cfd.RemoteDomainName)

return nil
}

func parseDSConditionalForwarderId(id string) (directoryId, domainName string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintainability note: We generally try to directly return an error as the last output from these so its obvious it needs to be handled by implementing functions (rather than expecting everywhere to know to check for "" directoryId and domainName) 👍

"github.com/hashicorp/terraform/terraform"
)

func TestACCAwsDirectoryServiceConditionForwarder_basic(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should be named TestAccAWS (lowercase cc being the most important)

bflad added a commit that referenced this pull request Apr 13, 2018
@bflad bflad added this to the v1.15.0 milestone Apr 13, 2018
@bflad bflad merged commit 1cd86d1 into hashicorp:master Apr 13, 2018
bflad added a commit that referenced this pull request Apr 13, 2018
@spirius spirius deleted the feature/ds-conditional-forwarder branch April 16, 2018 16:50
@bflad
Copy link
Contributor

bflad commented Apr 18, 2018

This has been released in version 1.15.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 6, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new-resource Introduces a new resource. size/L Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants