-
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
New Resource: aws_appsync_datasource #2758
New Resource: aws_appsync_datasource #2758
Conversation
|
@radeksimko This is new-resource, not new-data-source. The name of the object is |
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). |
@atsushi-ishibashi Do you mind rebasing this PR and resolving conflicts? |
c704c1f
to
c066f0d
Compare
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.
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"} |
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.
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": { |
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.
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": { |
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.
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": { |
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.
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("") |
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.
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("") |
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.
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("") |
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.
The SetId("")
is redundant here as we empty ID (and wipe the resource) in the upstream library inside Terraform's core.
}, | ||
}, | ||
}) | ||
} |
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.
Thanks for the thorough test coverage here! 👍
name = "tf_appsync_%s" | ||
type = "AMAZON_DYNAMODB" | ||
dynamodb_config { | ||
region = "us-west-2" |
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.
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" |
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.
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
16684aa
to
fcd7f25
Compare
I have no idea why below error occured. 🤔
|
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.
@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.
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. |
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! |
Required: #2494