-
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
resource/aws_autoscaling_policy: Add support for target_tracking_configuration #2611
Conversation
What is the status? |
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
thanks for the PR and sorry for the delay on our side in processing it.
I left you some questions/comments to address, the important ones around schema mainly.
@@ -93,6 +93,81 @@ func resourceAwsAutoscalingPolicy() *schema.Resource { | |||
}, | |||
Set: resourceAwsAutoscalingScalingAdjustmentHash, | |||
}, | |||
"target_tracking_configuration": &schema.Schema{ | |||
Type: schema.TypeSet, |
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 looks like target_tracking_configuration
is a singleton - i.e. we'll only ever have a single instance of it since it maps to a struct, not a map nor a slice. Do you mind changing it to schema.TypeList
and attaching MaxItems: 1
? We generally prefer TypeList for singletons because it's much easier to work with the field without the hash and because there's really no ordering problem as there's nothing to order, so no reason for set.
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"predefined_metric_specification": &schema.Schema{ | ||
Type: schema.TypeSet, |
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.
Likewise - as above ^
"predefined_metric_specification": &schema.Schema{ | ||
Type: schema.TypeSet, | ||
Optional: true, | ||
ConflictsWith: []string{"target_tracking_configuration.customized_metric_specification"}, |
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 this won't actually work, because the address isn't correct. The real address would be target_tracking_configuration.0.customized_metric_specification
(if we changed target_tracking_configuration
to TypeList).
}, | ||
}, | ||
"customized_metric_specification": &schema.Schema{ | ||
Type: schema.TypeSet, |
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.
Likewise - as above ^
"customized_metric_specification": &schema.Schema{ | ||
Type: schema.TypeSet, | ||
Optional: true, | ||
ConflictsWith: []string{"target_tracking_configuration.predefined_metric_specification"}, |
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.
Likewise - as above ^
return fmt.Sprintf(` | ||
resource "aws_launch_configuration" "test" { | ||
name = "tf-test-%s" | ||
image_id = "ami-21f78e11" |
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: Do you mind using the AMI data source here instead, so we don't need to keep updating the ID over time as often?
} | ||
|
||
resource "aws_autoscaling_group" "test" { | ||
availability_zones = ["us-west-2a"] |
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 the AZ data source here to make the test region-agnostic?
https://www.terraform.io/docs/providers/aws/d/availability_zones.html
resource "aws_launch_configuration" "test" { | ||
name = "tf-test-%s" | ||
image_id = "ami-21f78e11" | ||
instance_type = "t1.micro" |
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.
AFAIK t1
family of instances has been deprecated - do you mind changing this to any low-price size of current family? e.g. t2.micro
? https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts_micro_instances.html
resource "aws_launch_configuration" "test" { | ||
name = "tf-test-%s" | ||
image_id = "ami-21f78e11" | ||
instance_type = "t1.micro" |
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.
Likewise - as above ^
} | ||
|
||
resource "aws_autoscaling_group" "test" { | ||
availability_zones = ["us-west-2a"] |
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.
Likewise - as above ^
@radeksimko Ok👍
|
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 👍
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. |
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! |
Support: #1156
adjustment_type
isn't supported if the policy type is TargetTrackingScaling so I changed Optional