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: Service Discovery Service #2613

Merged

Conversation

atsushi-ishibashi
Copy link
Contributor

@atsushi-ishibashi atsushi-ishibashi commented Dec 9, 2017

Depend: #2569 #2589

TF_ACC=1 go test ./aws -v -run=TestAccAwsServiceDiscoveryService_ -timeout 120m
=== RUN   TestAccAwsServiceDiscoveryService_private
--- PASS: TestAccAwsServiceDiscoveryService_private (172.04s)
=== RUN   TestAccAwsServiceDiscoveryService_public
--- PASS: TestAccAwsServiceDiscoveryService_public (120.92s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	293.039s
InvalidInput: The record types in the request must be the same as those present in the existing service. Records in the existing service are [A], but the records in the request are [AAAA]. The record types of a service cannot be changed.

InvalidInput: Type of health check cannot be changed

So dns_records.type and health_check_config.type are ForceNew.

@radeksimko radeksimko added the new-resource Introduces a new resource. label Dec 11, 2017
@atsushi-ishibashi atsushi-ishibashi force-pushed the service_discovery_service branch from 13efd67 to 542cf85 Compare December 13, 2017 00:17
@atsushi-ishibashi
Copy link
Contributor Author

@radeksimko Ok👍 I have rebased and added some tests.

@Rowern
Copy link

Rowern commented Jan 3, 2018

This looks really cool. Any ETA on a review/merge to master?

@atsushi-ishibashi
Copy link
Contributor Author

@radeksimko Please review this 🙇

Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

Hi @atsushi-ishibashi
thanks for this PR.

I left you mostly lower prio comments. None of them are blockers, perhaps except the WARN log message and "not found" checks. Let me know what you think.

Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: Do you mind extracting this function into validators.go? This block of code is already deeply nested, so we can save 1 indentation at least.

Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: likewise - do you mind extracting it?

resp, err := conn.GetService(input)
if err != nil {
if isAWSErr(err, servicediscovery.ErrCodeServiceNotFound, "") {
d.SetId("")
Copy link
Member

Choose a reason for hiding this comment

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

d.Set("name", resp.Service.Name)
d.Set("description", resp.Service.Description)
d.Set("dns_config", flattenServiceDiscoveryDnsConfig(resp.Service.DnsConfig))
d.Set("health_check_config", flattenServiceDiscoveryHealthCheckConfig(resp.Service.HealthCheckConfig))
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: We could simplify the block by something like service := resp.Service 😉

if isAWSErr(err, servicediscovery.ErrCodeServiceNotFound, "") {
d.SetId("")
return nil
}
Copy link
Member

Choose a reason for hiding this comment

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

What's the motivation behind this check here? Every apply/plan will by default run Read() which has that check already, so it seems redundant.

if isAWSErr(err, servicediscovery.ErrCodeServiceNotFound, "") {
d.SetId("")
return nil
}
Copy link
Member

Choose a reason for hiding this comment

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

What's the motivation behind this check here? Every apply/plan will by default run Read() which has that check already, so it seems redundant.

return err
}

d.SetId("")
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: This is redundant (yes, I know many resources still have it... 🤷‍♂️ ).

https://github.com/hashicorp/terraform/blob/096847c9f774bfb946de7413260b30f9f6041241/helper/schema/resource.go#L197-L206

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! I missed this workflow😅

ttl = 10
type = "A"
}
dns_records {
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: Indentation

type = "A"
}
}
health_check_config {
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: indentation

@radeksimko radeksimko added the waiting-response Maintainers are waiting on response from community or contributor. label Jan 10, 2018
@atsushi-ishibashi atsushi-ishibashi force-pushed the service_discovery_service branch from b5fdb02 to da4395d Compare January 10, 2018 16:26
@atsushi-ishibashi
Copy link
Contributor Author

@radeksimko Thank you for review! Ok👍

@radeksimko radeksimko removed the waiting-response Maintainers are waiting on response from community or contributor. label Jan 10, 2018
@radeksimko radeksimko merged commit 52d2963 into hashicorp:master Jan 10, 2018
@bflad
Copy link
Contributor

bflad commented Jan 12, 2018

This has been released in terraform-provider-aws version 1.7.0. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@bflad bflad added this to the v1.7.0 milestone Jan 12, 2018
@ghost
Copy link

ghost commented Apr 8, 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 8, 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants