-
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_appautoscaling_scheduled_action #2231
New Resource: aws_appautoscaling_scheduled_action #2231
Conversation
|
502f7f8
to
99a586a
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.
Thanks for this PR @atsushi-ishibashi
I left you some comments & questions, the most important one about support of updates and unique ID.
Let me know what you think.
validDimensions := []string{"ecs:service:DesiredCount", "ec2:spot-fleet-request:TargetCapacity", | ||
"elasticmapreduce:instancegroup:InstanceCount", "appstream:fleet:DesiredCapacity", | ||
"dynamodb:table:ReadCapacityUnits", "dynamodb:table:WriteCapacityUnits", | ||
"dynamodb:index:ReadCapacityUnits", "dynamodb:index:WriteCapacityUnits"} |
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.
While offline, plan-time validation is usually useful I'm afraid it could be counter-productive here as the list of valid dimensions may and will expand and it did recently. I think we'd play a constant catch-up with AWS here and rushing to cut a release just to support a new dimension just because of this strict validation.
Theoretically we could validate for something like [a-zA-Z]+:[a-zA-Z]+:[a-zA-Z]+
but frankly I'd just rather avoid the validation altogether here.
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.
docs lists constant strings so I removed ValidateFunc
.
ForceNew: true, | ||
ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) { | ||
value := v.(string) | ||
validServiceNamespaces := []string{"ecs", "elasticmapreduce", "ec2", "appstream", "dynamodb"} |
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 below - I'm afraid the list of valid service namespaces may/will grow and I'd like us to avoid the maintenance burden associated with it, if possible.
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.
Ok, I removed ValidateFunc
.
} | ||
} | ||
|
||
func resourceAwsAppautoscalingScheduledActionCreate(d *schema.ResourceData, meta interface{}) error { |
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.
Per docs I think we should support updates of this resource and basically just rename this function to something like resourceAwsAppautoscalingScheduledActionCreateOrUpdate
or resourceAwsAppautoscalingScheduledActionPut
and reference it in Update
too.
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.
OK👍
return resource.RetryableError(err) | ||
default: | ||
return resource.NonRetryableError(err) | ||
} |
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.
Q: Is this related to eventual consistency?
Regardless of the reason I think the above conditional starting on L153 can be simplified to something like this:
if err != nil {
if isAWSErr(err, applicationautoscaling.ErrCodeObjectNotFoundException, "") {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
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 assumed that soon after creating dynamo table and on...
I simplified handling error.
return nil | ||
} | ||
if len(resp.ScheduledActions) != 1 { | ||
return fmt.Errorf("Number of Scheduled Action (%s) isn't one, got %d", saName, len(resp.ScheduledActions)) |
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.
Grammar nitpick, do you mind changing this to Expected 1 scheduled action under %s, found %d
?
"Action": [ | ||
"ecs:DescribeServices", | ||
"ecs:UpdateService", | ||
"cloudwatch:DescribeAlarms" |
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 - extra whitespace here 👀
} | ||
|
||
resource "aws_ecs_cluster" "hoge" { | ||
name = "tf-ecs-cluster-%s" |
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.
extra whitespace here 👀
} | ||
|
||
resource "aws_ecs_task_definition" "hoge" { | ||
family = "foobar" |
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 using a random name here too, please?
The following arguments are supported: | ||
|
||
* `name` - (Required) The name of the scheduled action. | ||
* `service_namespace` - (Required) The namespace of the AWS service. Documentation can be found in the parameter at: [AWS Application Auto Scaling API Reference](https://docs.aws.amazon.com/ApplicationAutoScaling/latest/APIReference/API_PutScheduledAction.html#ApplicationAutoScaling-PutScheduledAction-request-ServiceNamespace) Valid Values: ecs | elasticmapreduce | ec2 | appstream | dynamodb |
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 would avoid documenting all valid values as that will become a maintenance burden as these expand. How about we just mention a few examples? The user can always IMO look up all valid values in the docs, right?
* `name` - (Required) The name of the scheduled action. | ||
* `service_namespace` - (Required) The namespace of the AWS service. Documentation can be found in the parameter at: [AWS Application Auto Scaling API Reference](https://docs.aws.amazon.com/ApplicationAutoScaling/latest/APIReference/API_PutScheduledAction.html#ApplicationAutoScaling-PutScheduledAction-request-ServiceNamespace) Valid Values: ecs | elasticmapreduce | ec2 | appstream | dynamodb | ||
* `resource_id` - (Required) The identifier of the resource associated with the scheduled action. Documentation can be found in the parameter at: [AWS Application Auto Scaling API Reference](https://docs.aws.amazon.com/ApplicationAutoScaling/latest/APIReference/API_PutScheduledAction.html#ApplicationAutoScaling-PutScheduledAction-request-ResourceId) | ||
* `scalable_dimension` - (Optional) The scalable dimension. Documentation can be found in the parameter at: [AWS Application Auto Scaling API Reference](https://docs.aws.amazon.com/ApplicationAutoScaling/latest/APIReference/API_PutScheduledAction.html#ApplicationAutoScaling-PutScheduledAction-request-ScalableDimension) Valid Values: ecs:service:DesiredCount | ec2:spot-fleet-request:TargetCapacity | elasticmapreduce:instancegroup:InstanceCount | appstream:fleet:DesiredCapacity | dynamodb:table:ReadCapacityUnits | dynamodb:table:WriteCapacityUnits | dynamodb:index:ReadCapacityUnits | dynamodb:index:WriteCapacityUnits |
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 would avoid documenting all valid values as that will become a maintenance burden as these expand. How about we just mention a few examples? The user can always IMO look up all valid values in the docs, right?
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.
👍 🚢
* Make files * WIP * WIP * New Resource: aws_appautoscaling_scheduled_action * Reflect reviews * Used 3fields for id
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! |
#2227