-
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
r/aws_ssm_maintenance_window_target: Change MaxItems of targets #2361
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.
Thanks a lot for the work :)
Even though it is WIP, just left comments as it might help you!
@@ -30,9 +30,9 @@ func resourceAwsSsmMaintenanceWindowTarget() *schema.Resource { | |||
|
|||
"targets": { | |||
Type: schema.TypeList, | |||
Required: true, | |||
Optional: true, |
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 you said the documentation exposes that this seems required.
Let's keep it required here, the documentation is wrong on the number of items being 0. (you can even provide this feedback to AWS if you want :) )
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.
Sure👍
aws/structure.go
Outdated
@@ -2685,13 +2685,13 @@ func flattenAwsSsmTargets(targets []*ssm.Target) []map[string]interface{} { | |||
} | |||
|
|||
result := make([]map[string]interface{}, 0, len(targets)) | |||
target := targets[0] | |||
for _, target := range targets { | |||
t := make(map[string]interface{}) |
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: To be more memory-efficient, we could set: make(map[string]interface{}, 1)
, thoughts? :)
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 seems the same
func hoge1() {
results := make([]map[string]interface{}, 100)
for i := range results {
t := make(map[string]interface{})
t["key"], t["values"] = "key", "value"
results[i] = t
}
}
func hoge2() {
results := make([]map[string]interface{}, 100)
for i := range results {
t := make(map[string]interface{}, 1)
t["key"], t["values"] = "key", "value"
results[i] = t
}
}
func hoge3() {
results := make([]map[string]interface{}, 100)
for i := range results {
t := map[string]interface{}{}
t["key"], t["values"] = "key", "value"
results[i] = t
}
}
func BenchmarkHoge1(b *testing.B) {
for i := 0; i < b.N; i++ {
hoge1()
}
}
func BenchmarkHoge2(b *testing.B) {
for i := 0; i < b.N; i++ {
hoge2()
}
}
func BenchmarkHoge3(b *testing.B) {
for i := 0; i < b.N; i++ {
hoge3()
}
}
go test -bench BenchmarkHoge -benchmem
BenchmarkHoge1-4 50000 32459 ns/op 33600 B/op 200 allocs/op
BenchmarkHoge2-4 50000 32529 ns/op 33600 B/op 200 allocs/op
BenchmarkHoge3-4 50000 36636 ns/op 33600 B/op 200 allocs/op
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.
Third option is even better, interesting 🤔
Still, can you go for the second one, since it has a fixed size?
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👍
|
@@ -36,11 +36,11 @@ The following arguments are supported: | |||
|
|||
* `window_id` - (Required) The Id of the maintenance window to register the target with. | |||
* `resource_type` - (Required) The type of target being registered with the Maintenance Window. Possible values `INSTANCE`. | |||
* `targets` - (Required) The targets (either instances or tags). Instances are specified using Key=instanceids,Values=instanceid1,instanceid2. Tags are specified using Key=tag name,Values=tag value. | |||
* `targets` - (Required) The targets (either instances or tags). Instances are specified using Key=instanceids,Values=instanceid1,instanceid2. Tags are specified using Key=tag name,Values=tag value. Minimum number of 0 items. Maximum number of 5 items. |
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 you remove the first part of the change, since it is required? thanks
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.
Just added 2 checks in an acceptance test to ensure we do have multiple target in the state.
make testacc TEST=./aws TESTARGS='-run=TestAccAWSSSMMaintenanceWindow'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSSSMMaintenanceWindow -timeout 120m
=== RUN TestAccAWSSSMMaintenanceWindowTarget_basic
--- PASS: TestAccAWSSSMMaintenanceWindowTarget_basic (26.65s)
=== RUN TestAccAWSSSMMaintenanceWindowTask_basic
--- PASS: TestAccAWSSSMMaintenanceWindowTask_basic (123.93s)
=== RUN TestAccAWSSSMMaintenanceWindowTask_updateForcesNewResource
--- PASS: TestAccAWSSSMMaintenanceWindowTask_updateForcesNewResource (151.63s)
=== RUN TestAccAWSSSMMaintenanceWindow_basic
--- PASS: TestAccAWSSSMMaintenanceWindow_basic (38.68s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 340.963s
Looks very good to me, thanks for the work & reactivity! 👍
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! |
#2225
Not yet testacc.
According to Docs, minimum number is 0.
But I got a validation error and I'm asking aws-sdk-go.