Skip to content

Tables for Roles Anywhere Profiles and Trust Anchors #2475

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

2XXE-SRA
Copy link
Contributor

This PR adds two new tables for the Roles Anywhere service. Specifically, it adds support for enumerating Trust Anchors (aws_rolesanywhere_trust_anchor) and Profiles (aws_rolesanywhere_profile).

Example query results

Results
select 
  arn, 
  inline_policy 
from aws_rolesanywhere_profile

+-------------------------------------------------------------------------------------------+----------------------------------------------------------------+
| arn                                                                                       | role_arns                                                      |
+-------------------------------------------------------------------------------------------+----------------------------------------------------------------+
| arn:aws:rolesanywhere:us-east-1:123456789012:profile/fb3dcdae-b099-49ef-bdaf-69590f64c55d | ["arn:aws:iam::123456789012:role/RoleFoo"]                     |
| arn:aws:rolesanywhere:us-east-1:123456789012:profile/7df9cbb7-36c1-432b-b07d-cf6d83de46ef | ["arn:aws:iam::123456789012:role/RoleBar"]                     |
| arn:aws:rolesanywhere:us-east-1:123456789012:profile/8ca8dcf3-1692-478b-8976-1179e47af2d2 | ["arn:aws:iam::123456789012:role/RoleBaz"]                     |
+-------------------------------------------------------------------------------------------+----------------------------------------------------------------+

select 
  arn, 
  source_type
from aws_rolesanywhere_trust_anchor

+------------------------------------------------------------------------------------------------+--------------------+
| arn                                                                                            | source_type        |
+------------------------------------------------------------------------------------------------+--------------------+
| arn:aws:rolesanywhere:us-east-1:123456789012:trust-anchor/7cb25065-23c9-451f-bd1e-3e6ba321a6af | CERTIFICATE_BUNDLE |
| arn:aws:rolesanywhere:us-east-1:123456789012:trust-anchor/45e48edd-d495-499f-96f2-c9544fe02b64 | CERTIFICATE_BUNDLE |
| arn:aws:rolesanywhere:us-east-1:123456789012:trust-anchor/6fbe3a43-df3d-4fbe-a8e8-723bdb430ca7 | CERTIFICATE_BUNDLE |
+------------------------------------------------------------------------------------------------+--------------------+

@misraved
Copy link
Contributor

@2XXE-SRA thank you so much for the new tables 🎉 !!

Could you please fix the lint failure?

@misraved misraved requested a review from Copilot April 17, 2025 21:23
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for AWS Roles Anywhere by introducing two new Steampipe tables: one for Trust Anchors and one for Profiles. Key changes include the addition of documentation, table definition implementations, and integration into the plugin service.

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
docs/tables/aws_rolesanywhere_trust_anchor.md Added documentation outlining the trust anchor table usage.
docs/tables/aws_rolesanywhere_profile.md Added documentation outlining the profile table usage.
aws/table_aws_rolesanywhere_trust_anchor.go Implemented table definition and query functions for trust anchors.
aws/table_aws_rolesanywhere_profile.go Implemented table definition and query functions for profiles.
aws/service.go Added RolesAnywhereClient to support new Roles Anywhere APIs.
aws/plugin.go Registered the new Roles Anywhere tables with the plugin.
Files not reviewed (1)
  • go.mod: Language not supported

@ParthaI
Copy link
Contributor

ParthaI commented Apr 18, 2025

Hello @2XXE-SRA, great to see the PR with the new table addition!

Just a quick note:

  • This PR includes an update to the AWS SDK v2, upgrading it to version v1.36.3.
  • However, this version introduces breaking changes related to ResolverEndpointV2. Which need some efforts to make the changes across the tables.
  • Would it be possible to downgrade or retain the existing SDK version v1.27.0 instead?
  • From what I’ve seen, the github.com/aws/aws-sdk-go-v2/service/rolesanywhere package (version v1.11.4) should still be compatible with github.com/aws/aws-sdk-go-v2 version v1.27.0.

Thanks!

@2XXE-SRA
Copy link
Contributor Author

Hello @2XXE-SRA, great to see the PR with the new table addition!

Just a quick note:

* This PR includes an update to the AWS SDK v2, upgrading it to version `v1.36.3`.

* However, this version introduces breaking changes related to `ResolverEndpointV2`. Which need some efforts to make the changes across the tables.

* Would it be possible to **downgrade or retain the existing SDK version `v1.27.0`** instead?

* From what I’ve seen, the `github.com/aws/aws-sdk-go-v2/service/rolesanywhere` package (version `v1.11.4`) should still be compatible with `github.com/aws/aws-sdk-go-v2` version `v1.27.0`.
  
  * Running the command `go get github.com/aws/[email protected]` might help you do that.

Thanks!

Yeah, no problem. I think it was just an auto-upgrade when I grabbed the service package. I will test on the lower version and then update the PR.

@2XXE-SRA
Copy link
Contributor Author

Looks like the did the trick!

@cbruno10 cbruno10 requested a review from Copilot April 21, 2025 13:34
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces two new Steampipe table implementations for AWS Roles Anywhere by adding support for querying Trust Anchors and Profiles. Key changes include the addition of documentation files for both tables, implementation of the corresponding table definitions and list/get functions in Go, and registration of these new tables via AWS clients in the plugin.

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
docs/tables/aws_rolesanywhere_trust_anchor.md Adds documentation for the aws_rolesanywhere_trust_anchor table
docs/tables/aws_rolesanywhere_profile.md Adds documentation for the aws_rolesanywhere_profile table
aws/table_aws_rolesanywhere_trust_anchor.go Implements table definition and list/get functions for Trust Anchors
aws/table_aws_rolesanywhere_profile.go Implements table definition and list/get functions for Profiles
aws/service.go Adds a new AWS client creation function (RolesAnywhereClient)
aws/plugin.go Registers the new Roles Anywhere tables in the plugin
Files not reviewed (1)
  • go.mod: Language not supported
Comments suppressed due to low confidence (2)

aws/table_aws_rolesanywhere_profile.go:121

  • [nitpick] Consider using Go naming conventions (e.g., profileID) instead of snake_case for variable names.
profile_id := d.EqualsQuals["id"].GetStringValue()

aws/table_aws_rolesanywhere_profile.go:114

  • Ensure that the transform functions 'unescape' and 'policyToCanonical' are properly defined and imported, as their absence may lead to runtime errors.
Transform:   transform.FromField("SessionPolicy").Transform(unescape).Transform(policyToCanonical),

Copy link
Contributor

@ParthaI ParthaI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @2XXE-SRA,

I’ve left a few review comments for you to take a look at.

Additionally, here are some suggestions:

  • Name the table columns to match the API response, with the exception of the arn column.
  • Include the standard Steampipe columns.
  • Update the column descriptions based on the AWS documentation for the API.
  • Organize the function ordering as follows:
    • List Hydrate function
    • Get Hydrate function
    • Any other Hydrate functions
    • Transform functions
  • It would be great to include more example queries in the table documentation.

Please note: I haven't added any comments for the table aws_rolesanywhere_trust_anchor, but the suggestions above is also applicable for this table.

Thanks!

Hydrate: listProfiles,
Tags: map[string]string{"service": "rolesanywhere", "action": "ListProfiles"},
},
GetMatrixItemFunc: SupportedRegionMatrix(rolesanywherev1.EndpointsID),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GetMatrixItemFunc: SupportedRegionMatrix(rolesanywherev1.EndpointsID),
GetMatrixItemFunc: SupportedRegionMatrix(AWS_ROLESANYWHERE_SERVICE_ID),

We are halfway through removing support for AWS SDK V1 from the plugin, as the V1 SDK has reached its End of Life.
We have listed all the AWS-supported service IDs in the following file: endpoint_service_ids_gen.go.

GetMatrixItemFunc: SupportedRegionMatrix(rolesanywherev1.EndpointsID),
Columns: awsRegionalColumns([]*plugin.Column{
{
Name: "id",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please rename the column to profile_id? The table schema should exactly match the API response, except for the arn column.

},
{
Name: "accept_role_session_name",
Description: "Accept custom role session names.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please update the column descriptions to align with the API response descriptions? You can refer to the details here: API_ProfileDetail.

Kindly update the descriptions for the remaining columns as well.

Type: proto.ColumnType_STRING,
},
{
Name: "duration",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Name: "duration",
Name: "duration_seconds",

Description: "Contains the session policy in a canonical form for easier searching.",
Type: proto.ColumnType_JSON,
Transform: transform.FromField("SessionPolicy").Transform(unescape).Transform(policyToCanonical),
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include the steampipe standard column here. For reference: aws_acm_certificate

Comment on lines +170 to +172
if d.RowsRemaining(ctx) == 0 {
return nil, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if d.RowsRemaining(ctx) == 0 {
return nil, nil
}
// Context may get cancelled due to manual cancellation or if the limit has been reached
if d.RowsRemaining(ctx) == 0 {
return nil, nil
}

@2XXE-SRA
Copy link
Contributor Author

Thanks for the review! I will address these in the next day or two and get back to you.

@2XXE-SRA
Copy link
Contributor Author

I have pushed changes to both tables per your above suggestions. Please let me know if there are any other required changes.

Copy link
Contributor

@ParthaI ParthaI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @2XXE-SRA,

The changes look great! However, I left a few minor review comments—could you please take another look?

I noticed that a couple of columns were missed based on the API response. For example, the name column is missing from the aws_rolesanywhere_trust_anchor table.

Could you please cross-verify if any columns are missing according to the API response?

Note: Please validate both the GET and List API calls response and add the missing columns.

Thanks!

Type: proto.ColumnType_JSON,
},
{
Name: "require_instance_properties",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the column upwards as it is a non-JSON column.

Name: "title",
Description: resourceInterfaceDescription("title"),
Type: proto.ColumnType_STRING,
Transform: transform.FromField("ProfileId"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Transform: transform.FromField("ProfileId"),
Transform: transform.FromField("Name"),

Name: "akas",
Description: resourceInterfaceDescription("akas"),
Type: proto.ColumnType_JSON,
Transform: transform.FromField("ProfileArn").Transform(arnToAkas),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Transform: transform.FromField("ProfileArn").Transform(arnToAkas),
Transform: transform.FromField("ProfileArn").Transform(transform.EnsureStringArray),

Name: "akas",
Description: resourceInterfaceDescription("akas"),
Type: proto.ColumnType_JSON,
Transform: transform.FromField("TrustAnchorArn").Transform(arnToAkas),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Transform: transform.FromField("TrustAnchorArn").Transform(arnToAkas),
Transform: transform.FromField("TrustAnchorArn").Transform(transform.EnsureStringArray),

Name: "title",
Description: resourceInterfaceDescription("title"),
Type: proto.ColumnType_STRING,
Transform: transform.FromField("TrustAnchorId"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Transform: transform.FromField("TrustAnchorId"),
Transform: transform.FromField("Name"),

@2XXE-SRA
Copy link
Contributor Author

Above items addressed!

Could you please cross-verify if any columns are missing according to the API response?

Looks like it was just the name column.

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

Successfully merging this pull request may close these issues.

3 participants