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

Getting Exception When I try to List Attached Policies on Role #841

Closed
zepplen opened this issue Jun 16, 2015 · 1 comment
Closed

Getting Exception When I try to List Attached Policies on Role #841

zepplen opened this issue Jun 16, 2015 · 1 comment

Comments

@zepplen
Copy link

zepplen commented Jun 16, 2015

I am getting an exception when I try to list the attached_policies for a role

#pry
[1] pry(main)> "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
=> "2.1.5-p273"
[2] pry(main)> require 'aws-sdk'
=> true
[3] pry(main)> Aws::VERSION
=> "2.1.0"
[4] pry(main)> iam_resource = Aws::IAM::Resource.new(region: 'us-east-1', http_wire_trace: true)
=> #<Aws::IAM::Resource>
[5] pry(main)> role_name = 'ROLE_NAME'
=> "ROLE_NAME"
[6] pry(main)> role = iam_resource.role(role_name)
=> #<Aws::IAM::Role name="ROLE_NAME">
[7] pry(main)> role.create_date
opening connection to iam.amazonaws.com:443...
opened
starting SSL for iam.amazonaws.com:443...
SSL established
<- "POST / HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded; charset=utf-8\r\nAccept-Encodi
ng: \r\nUser-Agent: aws-sdk-ruby2/2.1.0 ruby/2.1.5 x86_64-linux resources\r\nX-Amz-Date: 20150616T1338
38Z\r\nHost: iam.amazonaws.com\r\nX-Amz-Security-Token: ****************\r\nX-Amz-Content-Sha256: *********************\r\nAuthorization: AWS4-HMAC-SHA256 Credential=*****************/20150616/us-east-1/iam/aws4_request, SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;x-amz-date;x-amz-security-token, Signature=***************\r\nContent-Length: 77\r\nAccept: */*\r\n\r\n"
-> "HTTP/1.1 200 OK\r\n"
-> "x-amzn-RequestId: fef4a31a-142c-11e5-9a74-63b6d9cb554f\r\n"
-> "Content-Type: text/xml\r\n"
-> "Content-Length: 801\r\n"
-> "Date: Tue, 16 Jun 2015 13:38:39 GMT\r\n"
-> "\r\n"
reading 801 bytes...
-> "<GetRoleResponse xmlns=\"https://iam.amazonaws.com/doc/2010-05-08/\">\n  <GetRoleResult>\n    <Role>\n      <Path>/</Path>\n      <AssumeRolePolicyDocument>%7B%22Version%22%3A%222008-10-17%22%2C%22Statement%22%3A%5B%7B%22Sid%22%3A%22%22%2C%22Effect%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22Service%22%3A%22ec2.amazonaws.com%22%7D%2C%22Action%22%3A%22sts%3AAssumeRole%22%7D%5D%7D</AssumeRolePolicyDocument>\n      <RoleId>AROAJ4NEDK3ICNTVLMSXM</RoleId>\n      <RoleName>ROLE_NAME</RoleName>\n      <Arn>arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME</Arn>\n      <CreateDate>2015-06-12T21:26:58Z</CreateDate>\n    </Role>\n  </GetRoleResult>\n  <ResponseMetadata>\n    <RequestId>fef4a31a-142c-11e5-9a74-63b6d9cb554f</RequestId>\n  </ResponseMetadata>\n</GetRoleResponse>\n"
read 801 bytes
Conn keep-alive
=> 2015-06-12 21:26:58 UTC
[8] pry(main)> role.attached_policies.map{|policy| policy}
opening connection to iam.amazonaws.com:443...
opened
starting SSL for iam.amazonaws.com:443...
SSL established
<- "POST / HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded; charset=utf-8\r\nAccept-Encoding: \r\nUser-Agent: aws-sdk-ruby2/2.1.0 ruby/2.1.5 x86_64-linux resources\r\nX-Amz-Date: 20150616T133907Z\r\nHost: iam.amazonaws.com\r\nX-Amz-Security-Token: *****************\r\nX-Amz-Content-Sha256: ********************************\r\nAuthorization: AWS4-HMAC-SHA256 Credential=********/us-east-1/iam/aws4_request, SignedHeaders=content-type;host;user-agent;x-amz-content-sha256;x-amz-date;x-amz-security-token, Signature=*****************************\r\nContent-Length: 94\r\nAccept: */*\r\n\r\n"
-> "HTTP/1.1 200 OK\r\n"
-> "x-amzn-RequestId: 0fb482fb-142d-11e5-bd7e-6b31668f8cb4\r\n"
-> "Content-Type: text/xml\r\n"
-> "Content-Length: 537\r\n"
-> "Date: Tue, 16 Jun 2015 13:39:06 GMT\r\n"
-> "\r\n"
reading 537 bytes...
-> "<ListAttachedRolePoliciesResponse xmlns=\"https://iam.amazonaws.com/doc/2010-05-08/\">\n  <ListAttachedRolePoliciesResult>\n    <IsTruncated>false</IsTruncated>\n    <AttachedPolicies>\n      <member>\n        <PolicyArn>arn:aws:iam::ACCOUNT_ID:policy/Base-Default</PolicyArn>\n        <PolicyName>Base-Default</PolicyName>\n      </member>\n    </AttachedPolicies>\n  </ListAttachedRolePoliciesResult>\n  <ResponseMetadata>\n    <RequestId>0fb482fb-142d-11e5-bd7e-6b31668f8cb4</RequestId>\n  </ResponseMetadata>\n</ListAttachedRolePoliciesResponse>\n"
read 537 bytes
Conn keep-alive
#<struct Aws::IAM::Types::ListAttachedRolePoliciesResponse attached_policies=[#<struct Aws::IAM::Types::AttachedPolicy policy_name="Base-Default", policy_arn="arn:aws:iam::ACCOUNT_ID:policy/Base-Default">], is_truncated=false, marker=nil>Aws::IAM::Types::ListAttachedRolePoliciesResponseNoMethodError: undefined method `each' for #<Seahorse::Client::Response:0x00000002054950>
from /home/mtrimmer/.rvm/gems/ruby-2.1.5@infra_builder/gems/aws-sdk-core-2.1.0/lib/seahorse/client/response.rb:83:in `method_missing'
@trevorrowe
Copy link
Member

When IAM added the new attached policies API, the paginators did not get updated to configure the SDK on how to enumerate the new list operations. I've added them, and they will be part of the next release soon. Thank you for reporting this issue.

@srchase srchase added the bug label Dec 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants