Tagging resources seems to be broken
lloydwatkin opened this issue · 6 comments
Describe the bug
I'm attempting to tag an autoscaling group. This is failing with the included error.
Expected Behavior
Autoscaling group gets tagged
Current Behavior
Error when attempting to tag an autoscaling group
TypeError: no implicit conversion of Symbol into Integer (TypeError)
@context[:response_target] = options[:target] || block
^^^^^^^
/home/lloyd/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/aws-sdk-core-3.190.0/lib/seahorse/client/request.rb:71:in `send_request'
/home/lloyd/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/aws-sdk-autoscaling-1.102.0/lib/aws-sdk-autoscaling/client.rb:1902:in `create_or_update_tags'
### Reproduction Steps
```ruby
Aws::AutoScaling::Resource.new(client: aws_autoscaling_client).groups.each do |group|
# Create a tag
tag = Aws::AutoScaling::Types::Tag.new(
key: 'tagging-works',
value: 'false',
)
aws_autoscaling_client.create_or_update_tags(
[tag],
[group.name]
)
end
Possible Solution
No response
Additional Information/Context
No response
Gem name ('aws-sdk', 'aws-sdk-resources' or service gems like 'aws-sdk-s3') and its version
aws-sdk-autoscaling 3.190.0
Environment details (Version of Ruby, OS environment)
Ruby 3.2.2 - Ubuntu
It looks like you may not be passing the arguments to create_or_update_tags correctly, try something like:
aws_autoscaling_client.create_or_update_tags(
tags: [
{
key: "TaggingWorks",
propagate_at_launch: true,
resource_id: group.name,
resource_type: "auto-scaling-group",
value: "true",
}])
@alextwoods thanks for the response, I've also tried that way and still get the same issue:
aws_autoscaling_client.create_or_update_tags(
tags: [{
key: "TaggingWorks",
propagate_at_launch: true,
resource_id: group.name,
resource_type: "auto-scaling-group",
value: "true",
}]
)
Error:
TypeError: no implicit conversion of Symbol into Integer (TypeError)
@context[:response_target] = options[:target] || block
Thats strange - from the error/stack trace I believe what is going on is options
is getting set as an array (and so indexing with :target
here raises that error). The signature for the creatE_or_update_tags method is def create_or_update_tags(params = {}, options = {})
so I think somehow an array is getting passed as the second argument. Can you try the following in your environment:
client = Aws::AutoScaling::Client.new(stub_responses: true)
client.create_or_update_tags({
tags: [{
key: "TaggingWorks",
propagate_at_launch: true,
resource_id: 'test',
resource_type: "auto-scaling-group",
value: "true",
}]}, {}
)
You could also potentially try making the call more explicit with:
tag = {key: "TaggingWorks", value: "true"}
aws_autoscaling_client.create_or_update_tags({tags: [tag]}, {})
I also agree this is strange. For the latest SDK, I can do the following:
autoscaling.create_or_update_tags(
tags: [{
key: "TaggingWorks",
propagate_at_launch: true,
resource_id: 'name',
resource_type: "auto-scaling-group",
value: "true",
}]
)
Perhaps are you still executing the old code?
Perhaps are you still executing the old code?
I think this may have been it actually, apologies, it seems a file had become corrupted by a bad merge and I hadn't noticed 🤦♂️
⚠️ COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.