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_appsync_datasource #2758

Merged
merged 7 commits into from
Mar 28, 2018

Conversation

atsushi-ishibashi
Copy link
Contributor

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

Required: #2494

  • test
  • docs
TF_ACC=1 go test ./aws -v -run=TestAccAwsAppsyncDatasource_ -timeout 120m
=== RUN   TestAccAwsAppsyncDatasource_ddb
--- PASS: TestAccAwsAppsyncDatasource_ddb (59.92s)
=== RUN   TestAccAwsAppsyncDatasource_es
--- PASS: TestAccAwsAppsyncDatasource_es (996.38s)
=== RUN   TestAccAwsAppsyncDatasource_lambda
--- PASS: TestAccAwsAppsyncDatasource_lambda (55.18s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws

@atsushi-ishibashi
Copy link
Contributor Author

TF_ACC=1 go test ./aws -v -run=TestAccAwsAppsyncDatasource_update -timeout 120m
=== RUN   TestAccAwsAppsyncDatasource_update
--- PASS: TestAccAwsAppsyncDatasource_update (103.41s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	103.443s

@radeksimko radeksimko added the new-data-source Introduces a new data source. label Dec 24, 2017
@atsushi-ishibashi atsushi-ishibashi changed the title [WIP]New Resource: Appsync datasource New Resource: Appsync datasource Dec 25, 2017
@atsushi-ishibashi
Copy link
Contributor Author

@radeksimko This is new-resource, not new-data-source. The name of the object is AppSyncDataSource so it might confused you 😅

@radeksimko radeksimko added new-resource Introduces a new resource. and removed new-data-source Introduces a new data source. labels Jan 9, 2018
@radeksimko radeksimko added the service/appsync Issues and PRs that pertain to the appsync service. label Jan 12, 2018
@radeksimko radeksimko changed the title New Resource: Appsync datasource New Resource: aws_appsync_datasource Jan 16, 2018
@radeksimko
Copy link
Member

Thanks for this PR too.

I will let you finish #2494 first though before diving into this one as it's easier to deal with smaller diff (after rebasing).

@radeksimko radeksimko added the waiting-response Maintainers are waiting on response from community or contributor. label Feb 8, 2018
@radeksimko
Copy link
Member

@atsushi-ishibashi Do you mind rebasing this PR and resolving conflicts?

@ghost ghost added the size/XL Managed by automation to categorize the size of a PR. label Feb 15, 2018
@radeksimko radeksimko removed the waiting-response Maintainers are waiting on response from community or contributor. label Feb 15, 2018
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
sorry for a small delay in processing this PR.

It looks overall pretty good, I just left you some comments to address about naming conventions etc.

Let me know if you have any questions, as always! 🙂

Required: true,
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) {
value := strings.ToUpper(v.(string))
validTypes := []string{"AWS_LAMBDA", "AMAZON_DYNAMODB", "AMAZON_ELASTICSEARCH"}
Copy link
Member

Choose a reason for hiding this comment

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

Do you mind turning these into constants and using a helper here? i.e.

ValidateFunc: validation.StringInSlice([]string{
    appsync.DataSourceTypeAwsLambda,
    appsync.DataSourceTypeAmazonDynamodb,
    appsync.DataSourceTypeAmazonElasticsearch,
    appsync.DataSourceTypeNone,
}, true),

},
ConflictsWith: []string{"dynamodb_config", "elasticsearch_config"},
},
"service_role": {
Copy link
Member

Choose a reason for hiding this comment

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

I think that we should keep this name as specific as it is in the API, i.e. service_role_arn, so it's obvious that we expect ARN here, not ID or name or anything else.

Type: schema.TypeString,
Required: true,
},
"table": {
Copy link
Member

Choose a reason for hiding this comment

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

I think that we should keep this name as specific as it is in the API, i.e. table_name, so it's obvious that we expect name of the table here, not ID/ARN or anything else.

MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"arn": {
Copy link
Member

Choose a reason for hiding this comment

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

I think that we should make this name a bit more specific, e.g. function_arn, so it's obvious that we expect ARN of the Lambda function - just in case Amazon decides to introduce more ARN-based arguments in the future.

resp, err := conn.GetDataSource(input)
if err != nil {
if isAWSErr(err, appsync.ErrCodeNotFoundException, "") {
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.

Do you mind adding a WARN log message here per convention?

_, err := conn.DeleteDataSource(input)
if err != nil {
if isAWSErr(err, appsync.ErrCodeNotFoundException, "") {
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.

The SetId("") is redundant here as we empty ID (and wipe the resource) in the upstream library inside Terraform's core.

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.

The SetId("") is redundant here as we empty ID (and wipe the resource) in the upstream library inside Terraform's core.

},
},
})
}
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the thorough test coverage here! 👍

name = "tf_appsync_%s"
type = "AMAZON_DYNAMODB"
dynamodb_config {
region = "us-west-2"
Copy link
Member

Choose a reason for hiding this comment

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

Do you mind swapping this for a data source, so the test is usable in any region?
https://www.terraform.io/docs/providers/aws/d/region.html

name = "tf_appsync_%s"
type = "AMAZON_ELASTICSEARCH"
elasticsearch_config {
region = "us-west-2"
Copy link
Member

Choose a reason for hiding this comment

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

Do you mind swapping this for a data source, so the test is usable in any region?
https://www.terraform.io/docs/providers/aws/d/region.html

@radeksimko radeksimko added the waiting-response Maintainers are waiting on response from community or contributor. label Mar 26, 2018
@ghost ghost added the size/XL Managed by automation to categorize the size of a PR. label Mar 26, 2018
@atsushi-ishibashi
Copy link
Contributor Author

I have no idea why below error occured. 🤔

TF_ACC=1 go test ./aws -v -run=TestAccAwsAppsyncDatasource_* -timeout 120m
=== RUN   TestAccAwsAppsyncDatasource_ddb
--- PASS: TestAccAwsAppsyncDatasource_ddb (86.84s)
=== RUN   TestAccAwsAppsyncDatasource_es
--- FAIL: TestAccAwsAppsyncDatasource_es (322.16s)
	testing.go:518: Step 0 error: Error applying: 1 error(s) occurred:
		
		* aws_appsync_datasource.test: 1 error(s) occurred:
		
		* aws_appsync_datasource.test: BadRequestException: Invalid endpoint configuration.
			status code: 400, request id: 5120e276-310f-11e8-b4d3-fdc8c0696d6a
=== RUN   TestAccAwsAppsyncDatasource_lambda
--- PASS: TestAccAwsAppsyncDatasource_lambda (56.85s)
=== RUN   TestAccAwsAppsyncDatasource_update
--- PASS: TestAccAwsAppsyncDatasource_update (109.15s)
FAIL
FAIL	github.com/terraform-providers/terraform-provider-aws/aws	575.030s
make: *** [testacc] Error 1

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.

@atsushi-ishibashi the test failure was related to missing protocol in the endpoint, I just patched the test so we can pull this in as the PR is otherwise in a great shape. Thanks.

@radeksimko radeksimko removed new-resource Introduces a new resource. waiting-response Maintainers are waiting on response from community or contributor. labels Mar 28, 2018
@radeksimko radeksimko added the new-resource Introduces a new resource. label Mar 28, 2018
@radeksimko radeksimko merged commit 13a8273 into hashicorp:master Mar 28, 2018
@bflad bflad added this to the v1.13.0 milestone Mar 29, 2018
@bflad
Copy link
Contributor

bflad commented Mar 29, 2018

This has been released in version 1.13.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 7, 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 7, 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. service/appsync Issues and PRs that pertain to the appsync service. size/XL Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants