-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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_api_gateway_documentation_part #2893
Conversation
4c888d0
to
16d2836
Compare
RestApiId: aws.String(d.Get("rest_api_id").(string)), | ||
}) | ||
if err != nil { | ||
if isAWSErr(err, "NotFoundException", "") { |
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.
Nitpick: Constant is available for this exception: apigateway.ErrCodeNotFoundException
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.
This is getting there! Only must fix items are related to adding an import test and fixing the documentation for that functionality (which may or may not require adjustment of the resource ID).
Passes acceptance testing in its current form for me:
make testacc TEST=./aws TESTARGS='-run=TestAccAWSAPIGatewayDocumentationPart'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSAPIGatewayDocumentationPart -timeout 120m
=== RUN TestAccAWSAPIGatewayDocumentationPart_basic
--- PASS: TestAccAWSAPIGatewayDocumentationPart_basic (25.19s)
=== RUN TestAccAWSAPIGatewayDocumentationPart_method
--- PASS: TestAccAWSAPIGatewayDocumentationPart_method (41.56s)
=== RUN TestAccAWSAPIGatewayDocumentationPart_responseHeader
--- PASS: TestAccAWSAPIGatewayDocumentationPart_responseHeader (24.67s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 91.477s
resource.TestStep{ | ||
Config: testAccAWSAPIGatewayDocumentationPartConfig(apiName, properties), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAWSAPIGatewayDocumentationPartExists("aws_api_gateway_documentation_part.test", &conf), |
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.
Nitpick (personal): I've been finding it helpful to declare the resource names as a top level variable in the function so its easier to duplicate code across functions/resources. e.g. resourceName := "aws_api_gateway_documentation_part.test"
- personal opinion though!
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'm ok with that, sounds reasonable, the only thing is that the majority of the tests we have in the codebase now doesn't follow this, so we might want to revisit the existing code, so other folks copy-pasting code know what's "preferred".
var conf apigateway.DocumentationPart | ||
|
||
rString := acctest.RandString(8) | ||
apiName := fmt.Sprintf("tf_acc_api_%s", rString) |
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.
Generic question: should we try to include the test name (e.g. t.Name()
) instead of the fairly diverse naming we have across resources for acceptance tests? I'm guessing it really depends on naming restrictions for some resources (max length, no underscores, etc).
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 agree we should make it test-specific, but t.Name()
is a bit tricky for the reasons you mentioned, so I'll come up with custom, static name.
Delete: resourceAwsApiGatewayDocumentationPartDelete, | ||
|
||
Importer: &schema.ResourceImporter{ | ||
State: schema.ImportStatePassthrough, |
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.
Must fix: missing acceptance test for import functionality
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.
Good catch! Will add.
if err != nil { | ||
return err | ||
} | ||
d.SetId(*out.Id) |
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.
Does the documentation part ID need to be combined with the REST API ID to support import? e.g. fmt.Sprintf("%s:%s", d.Get("rest_api_id").(string), *.out.Id)
and requisite idParts := strings.Split(d.Id(), ":")
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.
Yep, good catch, I'll pick /
as the divider though. It seems safer, given that both IDs are then used in a URL, divided by that character.
|
||
#### `location` | ||
|
||
* `method` - (Optional) The HTTP verb of a method. It is a valid field for the API entity types of `METHOD`, `PATH_PARAMETER`, `QUERY_PARAMETER`, `REQUEST_HEADER`, `REQUEST_BODY`, `RESPONSE`, `RESPONSE_HEADER`, and `RESPONSE_BODY`. The default value is `*` for any method. |
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.
Can we refer to the API Gateway documentation for this attribute and the ones below instead of listing these out?
|
||
## Import | ||
|
||
API Gateway documentation_parts can be imported using the word `api-gateway-documentation_part`, e.g. |
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.
Needs to be updated for (REST API ID and )documentation part ID
depending on outcome of ID value
return err | ||
} | ||
|
||
return fmt.Errorf("API Gateway Documentation Part %s/%s still exists.", |
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.
Should be updated based on ID discussion (or at least made a little clear what the second ID is). 😄
} | ||
_, err := conn.GetDocumentationPart(req) | ||
if err != nil { | ||
if isAWSErr(err, "NotFoundException", "") { |
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.
Same note about apigateway.ErrCodeNotFoundException
constant
testAccCheckAWSAPIGatewayDocumentationPartExists("aws_api_gateway_documentation_part.test", &conf), | ||
resource.TestCheckResourceAttr("aws_api_gateway_documentation_part.test", "location.#", "1"), | ||
resource.TestCheckResourceAttr("aws_api_gateway_documentation_part.test", "location.0.type", "API"), | ||
resource.TestCheckResourceAttr("aws_api_gateway_documentation_part.test", "properties", `{"description":"Terraform Acceptance Test"}`), |
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.
Can this use strconv.Unquote(properties)
instead?
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.
Good point in principle, I will use strconv.Quote()
.
@bflad I just addressed all of your comments. PTAL.
|
a66b6c8
to
f5f3e4d
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.
LGTM! Thanks for the fixes.
make testacc TEST=./aws TESTARGS='-run=TestAccAWSAPIGatewayDocumentationPart'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSAPIGatewayDocumentationPart -timeout 120m
=== RUN TestAccAWSAPIGatewayDocumentationPart_basic
--- PASS: TestAccAWSAPIGatewayDocumentationPart_basic (25.01s)
=== RUN TestAccAWSAPIGatewayDocumentationPart_method
--- PASS: TestAccAWSAPIGatewayDocumentationPart_method (35.23s)
=== RUN TestAccAWSAPIGatewayDocumentationPart_responseHeader
--- PASS: TestAccAWSAPIGatewayDocumentationPart_responseHeader (27.14s)
=== RUN TestAccAWSAPIGatewayDocumentationPart_importBasic
--- PASS: TestAccAWSAPIGatewayDocumentationPart_importBasic (23.45s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 110.870s
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. |
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! |
Test results