-
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_glue_trigger #4464
Conversation
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.
a bunch of mostly minor comments - but this otherwise LGTM 👍
"actions": { | ||
Type: schema.TypeList, | ||
Required: true, | ||
MinItems: 1, |
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 implied, since it's required
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.
MinItems: 1
is not implied by Required: true
on schema.TypeList
Given the below configuration and removing MinItems: 1
in the schema, it allows the 0 element list to pass through and error in the API:
resource "aws_glue_trigger" "test" {
name = "%s"
type = "ON_DEMAND"
actions = []
}
testing.go:518: Step 0 error: Error applying: 1 error(s) occurred:
* aws_glue_trigger.test: 1 error(s) occurred:
* aws_glue_trigger.test: error creating Glue Trigger (tf-acc-test-123ih): InvalidInputException: Actions cannot be null or empty
status code: 400, request id: f6ad3e4b-5de6-11e8-9ff4-73cc05d78525
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
ValidateFunc: validation.NoZeroValues, |
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.
off-topic: it feels like this should be set by default in TF Core when a fields required?
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.
minor we generally sort Required -> Optional -> Computed in the schema
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.
it feels like this should be set by default in TF Core when a fields required?
Some resource attributes (not here) use ""
to denote removing or zero-ing out something currently. When Terraform 0.12 is released, maybe we can become more strict, but for now the validation is required.
we generally sort Required -> Optional -> Computed in the schema
Yikes, there are probably hundreds of AWS resources that need to be updated then. It would be nice if there was documentation or linting for this.
}, | ||
Timeouts: &schema.ResourceTimeout{ | ||
Create: schema.DefaultTimeout(5 * time.Minute), | ||
Delete: schema.DefaultTimeout(5 * time.Minute), |
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.
what about updating?
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.
Currently the resource does not wait for updates so there's no timeout to configure. Acceptance testing so far has not triggered any issues with the enabled
attribute on import which seems to imply updates are happening instantly (for now).
"conditions": { | ||
Type: schema.TypeList, | ||
Required: true, | ||
MinItems: 1, |
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.
(as above)
log.Printf("[DEBUG] Reading Glue Trigger: %s", input) | ||
output, err := conn.GetTrigger(input) | ||
if err != nil { | ||
if isAWSErr(err, glue.ErrCodeEntityNotFoundException, "") { |
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.
🤔 are we missing a generic "is not found" function? we added this in the AzureRM Provider to work around crashes when the connection dropped
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.
Luckily, we don't get crashes from the SDK in these situations. The SDK will bubble up some sort of networking error (I believe always RequestError
), which is related to handling like this I just added: https://github.com/terraform-providers/terraform-provider-aws/blob/master/aws/config.go#L354-L372
As for a generic "is not found" function -- all the AWS service APIs return something different in this regard (status codes and error codes, some services have error codes for each different resource as well), so unfortunately it would probably be more trouble than its worth to try and create a single function to handle that.
func flattenGlueActions(actions []*glue.Action) []interface{} { | ||
l := []interface{}{} | ||
|
||
for _, action := range actions { |
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 add some crash protection here incase actions is nil?
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 do not believe anything is required here: https://play.golang.org/p/-ShUuLbE9cc
func flattenGlueConditions(conditions []*glue.Condition) []interface{} { | ||
l := []interface{}{} | ||
|
||
for _, condition := range conditions { |
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 here)
|
||
input := &glue.GetTriggersInput{} | ||
err = conn.GetTriggersPages(input, func(page *glue.GetTriggersOutput, lastPage bool) bool { | ||
if len(page.Triggers) == 0 { |
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.
what if page is nil 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.
Good catch -- will update 👍
|
||
# aws_glue_trigger | ||
|
||
Provides a Glue Job resource. |
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.
minor Provides -> Manages
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.
👍
Glue Triggers can be imported using `name`, e.g. | ||
|
||
``` | ||
$ terraform import aws_glue_trigger.MyTrigger Myrigger |
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.
Myrigger
-> MyTrigger
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.
👍
Acceptance testing still passes after resource code update -- merging!
|
This has been released in version 1.20.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! |
Closes #3882