Skip to content
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

Tagging resources seems to be broken #2969

Closed
lloydwatkin opened this issue Dec 18, 2023 · 6 comments
Closed

Tagging resources seems to be broken #2969

lloydwatkin opened this issue Dec 18, 2023 · 6 comments
Labels
guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@lloydwatkin
Copy link

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

@lloydwatkin lloydwatkin added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 18, 2023
@alextwoods
Copy link
Contributor

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 alextwoods added guidance Question that needs advice or information. and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 18, 2023
@mullermp mullermp added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Dec 18, 2023
@lloydwatkin
Copy link
Author

@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
  

@alextwoods
Copy link
Contributor

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]}, {})

@mullermp
Copy link
Contributor

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?

@lloydwatkin
Copy link
Author

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 🤦‍♂️

Copy link

⚠️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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

3 participants