@aws-sdk/client-detective
Description
AWS SDK for JavaScript Detective Client for Node.js, Browser and React Native.
Detective uses machine learning and purpose-built visualizations to help you to
analyze and investigate security issues across your Amazon Web Services (Amazon Web Services) workloads. Detective automatically extracts time-based events such
as login attempts, API calls, and network traffic from CloudTrail and Amazon Virtual Private Cloud (Amazon VPC) flow logs. It also extracts findings detected by
Amazon GuardDuty.
The Detective API primarily supports the creation and management of behavior
graphs. A behavior graph contains the extracted data from a set of member accounts, and is
created and managed by an administrator account.
To add a member account to the behavior graph, the administrator account sends an
invitation to the account. When the account accepts the invitation, it becomes a member
account in the behavior graph.
Detective is also integrated with Organizations. The organization
management account designates the Detective administrator account for the
organization. That account becomes the administrator account for the organization behavior
graph. The Detective administrator account is also the delegated administrator
account for Detective in Organizations.
The Detective administrator account can enable any organization account as a
member account in the organization behavior graph. The organization accounts do not receive
invitations. The Detective administrator account can also invite other accounts to
the organization behavior graph.
Every behavior graph is specific to a Region. You can only use the API to manage
behavior graphs that belong to the Region that is associated with the currently selected
endpoint.
The administrator account for a behavior graph can use the Detective API to do
the following:
-
Enable and disable Detective. Enabling Detective creates a new
behavior graph.
-
View the list of member accounts in a behavior graph.
-
Add member accounts to a behavior graph.
-
Remove member accounts from a behavior graph.
-
Apply tags to a behavior graph.
The organization management account can use the Detective API to select the
delegated administrator for Detective.
The Detective administrator account for an organization can use the Detective API to do the following:
An invited member account can use the Detective API to do the following:
-
View the list of behavior graphs that they are invited to.
-
Accept an invitation to contribute to a behavior graph.
-
Decline an invitation to contribute to a behavior graph.
-
Remove their account from a behavior graph.
All API actions are logged as CloudTrail events. See Logging Detective API Calls with CloudTrail.
We replaced the term "master account" with the term "administrator account". An
administrator account is used to centrally manage multiple accounts. In the case of
Detective, the administrator account manages the accounts in their behavior
graph.
Installing
To install this package, simply type add or install @aws-sdk/client-detective
using your favorite package manager:
npm install @aws-sdk/client-detective
yarn add @aws-sdk/client-detective
pnpm add @aws-sdk/client-detective
Getting Started
Import
The AWS SDK is modulized by clients and commands.
To send a request, you only need to import the DetectiveClient
and
the commands you need, for example ListGraphsCommand
:
const { DetectiveClient, ListGraphsCommand } = require("@aws-sdk/client-detective");
import { DetectiveClient, ListGraphsCommand } from "@aws-sdk/client-detective";
Usage
To send a request, you:
- Initiate client with configuration (e.g. credentials, region).
- Initiate command with input parameters.
- Call
send
operation on client with command object as input. - If you are using a custom http handler, you may call
destroy()
to close open connections.
const client = new DetectiveClient({ region: "REGION" });
const params = {
};
const command = new ListGraphsCommand(params);
Async/await
We recommend using await
operator to wait for the promise returned by send operation as follows:
try {
const data = await client.send(command);
} catch (error) {
} finally {
}
Async-await is clean, concise, intuitive, easy to debug and has better error handling
as compared to using Promise chains or callbacks.
Promises
You can also use Promise chaining
to execute send operation.
client.send(command).then(
(data) => {
},
(error) => {
}
);
Promises can also be called using .catch()
and .finally()
as follows:
client
.send(command)
.then((data) => {
})
.catch((error) => {
})
.finally(() => {
});
Callbacks
We do not recommend using callbacks because of callback hell,
but they are supported by the send operation.
client.send(command, (err, data) => {
});
v2 compatible style
The client can also send requests using v2 compatible style.
However, it results in a bigger bundle size and may be dropped in next major version. More details in the blog post
on modular packages in AWS SDK for JavaScript
import * as AWS from "@aws-sdk/client-detective";
const client = new AWS.Detective({ region: "REGION" });
try {
const data = await client.listGraphs(params);
} catch (error) {
}
client
.listGraphs(params)
.then((data) => {
})
.catch((error) => {
});
client.listGraphs(params, (err, data) => {
});
Troubleshooting
When the service returns an exception, the error will include the exception information,
as well as response metadata (e.g. request id).
try {
const data = await client.send(command);
} catch (error) {
const { requestId, cfId, extendedRequestId } = error.$metadata;
console.log({ requestId, cfId, extendedRequestId });
}
Getting Help
Please use these community resources for getting help.
We use the GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them.
To test your universal JavaScript code in Node.js, browser and react-native environments,
visit our code samples repo.
Contributing
This client code is generated automatically. Any modifications will be overwritten the next time the @aws-sdk/client-detective
package is updated.
To contribute to client you can check our generate clients scripts.
License
This SDK is distributed under the
Apache License, Version 2.0,
see LICENSE for more information.
Client Commands (Operations List)
AcceptInvitation
Command API Reference / Input / Output
BatchGetGraphMemberDatasources
Command API Reference / Input / Output
BatchGetMembershipDatasources
Command API Reference / Input / Output
CreateGraph
Command API Reference / Input / Output
CreateMembers
Command API Reference / Input / Output
DeleteGraph
Command API Reference / Input / Output
DeleteMembers
Command API Reference / Input / Output
DescribeOrganizationConfiguration
Command API Reference / Input / Output
DisableOrganizationAdminAccount
Command API Reference / Input / Output
DisassociateMembership
Command API Reference / Input / Output
EnableOrganizationAdminAccount
Command API Reference / Input / Output
GetInvestigation
Command API Reference / Input / Output
GetMembers
Command API Reference / Input / Output
ListDatasourcePackages
Command API Reference / Input / Output
ListGraphs
Command API Reference / Input / Output
ListIndicators
Command API Reference / Input / Output
ListInvestigations
Command API Reference / Input / Output
ListInvitations
Command API Reference / Input / Output
ListMembers
Command API Reference / Input / Output
ListOrganizationAdminAccounts
Command API Reference / Input / Output
ListTagsForResource
Command API Reference / Input / Output
RejectInvitation
Command API Reference / Input / Output
StartInvestigation
Command API Reference / Input / Output
StartMonitoringMember
Command API Reference / Input / Output
TagResource
Command API Reference / Input / Output
UntagResource
Command API Reference / Input / Output
UpdateDatasourcePackages
Command API Reference / Input / Output
UpdateInvestigationState
Command API Reference / Input / Output
UpdateOrganizationConfiguration
Command API Reference / Input / Output