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: appsync_graphql_api #2494

Merged
merged 6 commits into from
Feb 12, 2018

Conversation

atsushi-ishibashi
Copy link
Contributor

@atsushi-ishibashi atsushi-ishibashi commented Nov 30, 2017

  • docs
TF_ACC=1 go test ./aws -v -run=TestAccAwsAppsyncGraphqlApi_basic -timeout 120m
=== RUN   TestAccAwsAppsyncGraphqlApi_basic
--- PASS: TestAccAwsAppsyncGraphqlApi_basic (150.35s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	150.386s

@radeksimko radeksimko added the new-resource Introduces a new resource. label Nov 30, 2017
@atsushi-ishibashi atsushi-ishibashi changed the title [WIP]New Resource: appsync_graphql_api New Resource: appsync_graphql_api Dec 23, 2017
@radeksimko radeksimko added the service/appsync Issues and PRs that pertain to the appsync service. label Jan 16, 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
thanks for the PR, this is looking pretty good, very close to mergeable state!

I left you some comments to address.

resp, err := conn.GetGraphqlApi(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 our usual WARN log message here?

},
StateFunc: func(v interface{}) string {
return strings.ToUpper(v.(string))
},
Copy link
Member

Choose a reason for hiding this comment

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

Can't we avoid this just by tightening the validation above (i.e. by not accepting lowercase)?

}
}
errors = append(errors, fmt.Errorf("expected %s to be one of %v, got %s", k, validTypes, value))
return
Copy link
Member

Choose a reason for hiding this comment

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

Would you mind using constants available in the SDK?
Also we have a built-in validation helper for this:

ValidateFunc: validation.StringInSlice([]string{
  appsync.AuthenticationTypeApiKey,
  appsync.AuthenticationTypeAwsIam,
  appsync.AuthenticationTypeAmazonCognitoUserPools,
}, false),

😉

},
StateFunc: func(v interface{}) string {
return strings.ToUpper(v.(string))
},
Copy link
Member

Choose a reason for hiding this comment

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

Same question as above ^

}
errors = append(errors, fmt.Errorf("expected %s to be one of %v, got %s", k, validTypes, value))
return
},
Copy link
Member

Choose a reason for hiding this comment

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

Same question as above ^

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.

Likewise ^

if isAWSErr(err, appsync.ErrCodeNotFoundException, "") {
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.

I can't think of a reason why the user would want to silently fail updating API when it doesn't exist. 🤔 Is there any?

The most common cases (refresh, deletion) are covered correctly, but I think we should just error out on update.

input := &appsync.CreateGraphqlApiInput{
AuthenticationType: aws.String(d.Get("authentication_type").(string)),
Name: aws.String(d.Get("name").(string)),
UserPoolConfig: expandAppsyncGraphqlApiUserPoolConfig(d.Get("user_pool_config").([]interface{})),
Copy link
Member

Choose a reason for hiding this comment

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

I am admittedly surprised this isn't causing a crash in the attached test where user_pool_config is not present. It's no big deal as it's not crashing, but it may be safer to always wrap optional fields in d.GetOk().

---
layout: "aws"
page_title: "AWS: aws_appsync_graphql_api"
sidebar_current: "docs-aws-resource-appsync-praphql-api"
Copy link
Member

Choose a reason for hiding this comment

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

Typo 👓 praphql -> graphql

authentication_type = "AMAZON_COGNITO_USER_POOLS"
name = "tf_appsync_%s"
user_pool_config {
aws_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.

Although our tests commonly run in us-west-2 I think we should keep the test region-agnostic. Do you mind adding aws_region data source here?

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 Feb 8, 2018
@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Feb 10, 2018
@atsushi-ishibashi
Copy link
Contributor Author

@radeksimko Thank you for your review. OK👍

TF_ACC=1 go test ./aws -v -run=TestAccAwsAppsyncGraphqlApi_* -timeout 120m
=== RUN   TestAccAwsAppsyncGraphqlApi_basic
--- PASS: TestAccAwsAppsyncGraphqlApi_basic (32.12s)
=== RUN   TestAccAwsAppsyncGraphqlApi_iam
--- PASS: TestAccAwsAppsyncGraphqlApi_iam (27.64s)
=== RUN   TestAccAwsAppsyncGraphqlApi_cognito
--- PASS: TestAccAwsAppsyncGraphqlApi_cognito (44.92s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws

@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Feb 12, 2018
@radeksimko radeksimko removed the waiting-response Maintainers are waiting on response from community or contributor. label Feb 12, 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.

LGTM, Thanks, I just removed the not-found check from Update() as mentioned. I hope you don't mind.

@radeksimko radeksimko merged commit 8f671af into hashicorp:master Feb 12, 2018
@atsushi-ishibashi
Copy link
Contributor Author

atsushi-ishibashi commented Feb 12, 2018

@radeksimko Ok👍I misunderstood what you said in the above review.
Thank you!

@ahl
Copy link
Contributor

ahl commented Feb 25, 2018

Is the plan to accrete pieces for appsync gradually or is there a consistent plan? @atsushi-ishibashi

@atsushi-ishibashi
Copy link
Contributor Author

atsushi-ishibashi commented Feb 25, 2018

I have no plan to implement anymore. In my opinion, schema, resolver and type are outside of terraform's role and apikey will expire in a few days so it also doesn't suit.
But they are important for those who want to manage them by terraform👍

@bflad bflad added this to the v1.10.0 milestone Feb 27, 2018
@bflad
Copy link
Contributor

bflad commented Feb 27, 2018

This has been released in version 1.10.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/L Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants