-
Notifications
You must be signed in to change notification settings - Fork 104
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
Excessive duplicate AWS API calls #2259
Comments
Hello, @aidansteele, I apologize for any inconvenience caused. The issue you're experiencing with the To address this, I have raised a PR that includes the following enhancements:
Please note that the table design has not yet been finalized. In our environment, we have limited resources to test the performance of these changes. It would be greatly appreciated if you could test the PR branch ( Official blog post query(It should run more smoothly than before): WITH instances AS (
SELECT
instance_id,
instance_type,
account_id,
tags ->> 'Name' AS instance_name,
_ctx ->> 'connection_name' AS account_name,
instance_state,
region,
image_id
FROM
aws_ec2_instance
)
SELECT DISTINCT
aws_ec2_ami_shared.image_id as image_id,
aws_ec2_ami_shared.owner_id as image_owner_id,
aws_ec2_ami_shared.image_owner_alias as image_owner_name,
instances.instance_name,
instances.account_name,
instances.region,
aws_ec2_ami_shared.name as image_name
FROM
instances
LEFT JOIN aws_ec2_ami_shared ON aws_ec2_ami_shared.image_id=instances.image_id
WHERE aws_ec2_ami_shared.image_owner_alias != 'amazon'
AND aws_ec2_ami_shared.image_owner_alias != 'self' Taking advantage of batch operation: with instances as (
select
instance_id,
instance_type,
account_id,
tags ->> 'Name' as instance_name,
_ctx ->> 'connection_name' as account_name,
instance_state,
region,
image_id
from
aws_ec2_instance
),
all_image_ids as (
select
json_agg(image_id)::jsonb as image_ids -- Cast to jsonb
from
instances
),
shared_ami as (
select
s.*
from
aws_ec2_ami_shared as s,
all_image_ids
where s.image_ids = all_image_ids.image_ids
)
select distinct
shared_ami.image_id as image_id,
shared_ami.owner_id as image_owner_id,
shared_ami.image_owner_alias as image_owner_name,
instances.instance_name,
instances.account_name,
instances.region,
shared_ami.name as image_name
from
instances
left join shared_ami on shared_ami.image_id=instances.image_id
where shared_ami.image_owner_alias != 'amazon'
and shared_ami.image_owner_alias != 'self'; Thank you for your understanding and assistance! |
Hi @ParthaI, thank you for such a speedy response. My apologies for only getting back to you now. I attempted to try your PR, but didn't have much luck and I suspect it's a user error on my behalf. This is what I did:
I then verified that there was a new binary (based on last modified timestamp) at
I also tried inspecting the table and didn't see
|
Hi @aidansteele, I apologize for the inconvenience. Upon reviewing the issue, I discovered that our current main branch has a bug, which is causing the plugin not to build correctly locally. To address this, I have raised a PR with the necessary fix. If you rebase the Here are the steps to rebase:
Thank you for your understanding and patience! |
Hi @aidansteele, FYI, the PR has already been merged into the |
Hello @aidansteele, Have you had a chance to look at the above comment again? |
Hi @aidansteele We haven’t heard back from you in a while, so we’re going to close this issue for now. If you’re still experiencing this problem or have additional information to share, please feel free to reopen the issue or create a new one. Thank you for your understanding! |
Describe the bug
The Steampipe AWS plugin appears to be making excessive duplicate API calls when running well-formed SQL queries. This is causing queries to run much slower than they should.
Steampipe version (
steampipe -v
)Steampipe v0.23.3
Plugin version (
steampipe plugin list
)hub.steampipe.io/plugins/turbot/aws 0.116.0
To reproduce
I ran the Ensuring AMIs are from trusted sources sample query from this official blog post. In case the blog post gets updated, this is the exact SQL that I ran:
The query ultimately failed (for reasons that I suspect are not Steampipe's fault: it got a
RequestExpired: Request has expired
response from the EC2 API, indicating a clock skew issue), but it made at least 53,899 calls toec2:DescribeImages
as per CloudTrail. A lot of these were duplicates, e.g. see these screenshot of duplicate AMI lookupsExpected behavior
I would have expected Steampipe to deduplicate/cache these API calls and (presumably) for the query to be executed much faster.
Additional context
This query was executed against an aggregation of 225 AWS accounts and two AWS regions. I am not an SQL expert and I assume that the SQL query in the Steampipe blog is optimal.
The text was updated successfully, but these errors were encountered: