-
Notifications
You must be signed in to change notification settings - Fork 433
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
#584 Added Support for SSM based Instance #1159
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution.
I've a few comments regarding the changes
- The changes belong to a new file in systemsmanager folder
- Take inspiration from how other
FetchDataFunction
s are written - don't use "." imports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop the cost calculation as we'll be going with AWS cost explorer API integration for AWS provider
yep i removed the cost monitoring and will be doing test on it . any suggestion where i should i call the function from |
almost done with testing and going to do some changes 👍 |
@Azanul ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
failing CLI
Region: client.AWSClient.Region, | ||
ResourceId: *ec2instance.InstanceId, | ||
Name: *ec2instance.Name, | ||
Cost: 0.0, // No cost calculation in this version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cost: 0.0, // No cost calculation in this version |
Name: *ec2instance.Name, | ||
Cost: 0.0, // No cost calculation in this version | ||
CreatedAt: *ec2instance.RegistrationDate, | ||
Tags: nil, // No tags in this version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tags: nil, // No tags in this version |
its because i didn't committed latest changes , i am asking what should be in the
once the id is populated i will push the commits |
I think that's auto. It'll be filled by the respective DB. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I see too many API requests being sent. Could you move client creation to the main function and create helper functions to fetch respective data for all instances at once instead of making an API call for each instance.
- refer to other implementations for error handling
Ok |
hey @Azanul now i am fetching the all instance info at once which reduce the API calls , and now just few API calls , i have also tested it
|
ec2Client := ec2.NewFromConfig(*client.AWSClient) | ||
|
||
ssmOutput, err := ssmClient.DescribeInstanceInformation(ctx, &ssm.DescribeInstanceInformationInput{ | ||
MaxResults: aws.Int32(50), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason we are keeping this parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it tells what instances are managed ec2 instances, and later we are using describe because it provides more info regarding the instance, and the parameter is set to MaxResults: aws.Int32(50)
is maximum value we can use (Defined by aws). another reason is making as less as possible call, thats why the MaxResults: aws.Int32(50)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of SSM managing more instances > 50 we would still need those too as we want users to know what resources in what quantity are active
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know that we have pagination token, let me add it so it will fetch all ssm intance even its >50 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AvineshTripathi thanks for pointing it out , i removed the MaxResults
because if the ssm-instance is less than 5 it will through error now just using pagination token
👍 .
MaxResults: aws.Int32(50), | ||
}) | ||
if err != nil { | ||
log.Fatal(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Fatal(err) | |
return resources, err |
InstanceIds: instanceIds, | ||
}) | ||
if err != nil { | ||
return nil, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil, err | |
return resources, err |
some nits for readability
|
||
account, accountID, err := fetchID(ctx, client) | ||
if err != nil { | ||
return nil, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil, err | |
return resources, err |
Provider: "AWS", | ||
Account: account, | ||
AccountId: accountID, | ||
Service: "EC2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we call this SSM Instance
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, thanks for noticing it out 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please donot add -
and use space that is how we have done for other resources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the failing CI. You need to call getManagedEc2. Check out other implementations.
@Horiodino Still failing |
in aws.go on line 103 i have added |
Co-authored-by: Azanul Haque <[email protected]>
o i added it but i forgot to commit it , sorry |
* enhancement: added ssm based instance * enhancement: added cost-monitoring on smm based instances * Refactor: Removed dot imports and organized changes into the systemsmanager folder. * enhancement: Removed the cost calculation logic and related code * implemented suggested changes * Reduced API Requests & bulk data fetching for instances. * added suggested changes * added pagination token for fetching ssm-instance-info * fixed the failing CI * Update providers/aws/systemsmanager/managedinstances.go Co-authored-by: Azanul Haque <[email protected]> --------- Co-authored-by: Azanul Haque <[email protected]> Co-authored-by: LABOUARDY Mohamed <[email protected]>
Problem
Support AWS Systems Manager managed-instane #584
Changes Made
Notes
this hasn't been tested yet , i opened this pull request to view the code for the reviewers to know what i did
and if theirs any problem please correct me .
Checklist
Reviewers
@[username of the reviewer]