Setting up AWS Ops Agent for networking across an AWS Organization
You can scope an Agent Space by organizational unit (OU) instead of by individual account. The scope stays current as accounts join or move, and with a delegated administrator, your team can run AWS Ops Agent for networking without management-account credentials. There are two tasks: turn on AWS Organizations trusted access for AWS Ops Agent and for networking, and create an Agent Space in organization mode with the Networking specialist (or add the Networking specialist to an existing one).
This topic covers organization mode. To cover individual accounts instead (account mode), you don't turn on AWS Organizations trusted access. Instead, you add the Networking specialist in each account, and you manually create the AWS Network Manager service-linked role in each account. For more information, see Getting started with AWS Ops Agent for networking.
Trusted access roles
Organization mode uses the following trusted access roles:
| Service | Service principal | Role | Covers |
|---|---|---|---|
| AWS Ops Agent | aidevops.amazonaws.com | AIDevOpsAgentSpaceRole-* (deployed to member accounts through a service-managed CloudFormation StackSet) | Organization accounts and resources |
| AWS Network Manager | networkmanager.amazonaws.com | AWSServiceRoleForNetworkManager | Network topology and connectivity |
| Network security analysis | network-security-director.amazonaws.com | AWSServiceRoleForNetworkSecurityDirector | Network security findings |
AWS Ops Agent for networking runs from the AWS Network Manager delegated administrator account. Network security analysis has no delegated administrator of its own. The management account turns on the NETWORK_SECURITY_DIRECTOR_POLICY policy type and delegates management to the AWS Network Manager delegated administrator.
Prerequisites
An organization with all features turned on. All features is the AWS Organizations setting that is required to enable policy types and trusted access for organization mode.
Management-account access with the following permissions:
organizations:EnableAWSServiceAccess,organizations:RegisterDelegatedAdministrator,organizations:EnablePolicyType,organizations:PutResourcePolicy,organizations:DescribeResourcePolicy,cloudformation:ActivateOrganizationsAccess,networkmanager:StartOrganizationServiceAccessUpdate, andiam:CreateServiceLinkedRole.A recommended delegated administrator member account. Use the same account for AWS Ops Agent and AWS Network Manager. This account hosts the Agent Space and the monitor role.
Agent Space account permissions:
iam:CreateRole,iam:AttachRolePolicy,iam:PutRolePolicy, andiam:PassRolewithiam:PassedToServiceequal toaidevops.amazonaws.com, plus the network scope permissions from Getting started with AWS Ops Agent for networking.The Regions where your workloads run.
The latest AWS CLI, if you use the AWS CLI.
Step 1: Turn on trusted access
To turn on trusted access (console)
Sign in with the management account.
Open Agent spaces settings.
Choose Organizations trusted access and delegated admins.
Select AWS Ops Agent and Networking.
Choose Enable.
Choose a delegated administrator for each service, or choose None to run from the management account.
Confirm your choices, and then refresh.
If a step fails, choose Enable again to resume from the failed step. If AWS Network Manager fails, network security analysis is skipped.
To turn on trusted access with the AWS CLI, run the following commands. Turn on AWS Ops Agent trusted access.
aws organizations enable-aws-service-access --service-principal aidevops.amazonaws.com aws cloudformation activate-organizations-access aws organizations register-delegated-administrator \ --service-principal aidevops.amazonaws.com \ --account-id <delegated-admin-account-id>
Turn on AWS Network Manager trusted access. This operation is asynchronous and uses the home Region US West (Oregon), us-west-2.
aws networkmanager start-organization-service-access-update --action ENABLE --region us-west-2 aws networkmanager list-organization-service-access-status --region us-west-2 aws organizations register-delegated-administrator \ --service-principal networkmanager.amazonaws.com \ --account-id <delegated-admin-account-id>
Turn on network security analysis trusted access and enable the policy type on the root.
aws organizations enable-aws-service-access --service-principal network-security-director.amazonaws.com aws organizations enable-policy-type --root-id r-examplerootid --policy-type NETWORK_SECURITY_DIRECTOR_POLICY
Delegate policy management to the AWS Network Manager delegated administrator. You create the delegation policy file (network-security-analysis-delegation-policy.json) yourself. It contains an AWS Organizations resource policy with four statements, with the Sids AgentSpacesNsdDelegatingOrgReadActions, AgentSpacesNsdDelegatingPolicyMutationActions, AgentSpacesNsdDelegatingPolicyManageActions, and AgentSpacesNsdDelegatingPolicyTagActions.
put-resource-policy replaces the entire delegation policy. Run describe-resource-policy first, and merge your changes.
aws organizations describe-resource-policy aws organizations put-resource-policy --content file://network-security-analysis-delegation-policy.json
Verify trusted access and the delegated administrators.
aws organizations list-aws-service-access-for-organization aws organizations list-delegated-administrators --service-principal networkmanager.amazonaws.com aws organizations list-delegated-administrators --service-principal network-security-director.amazonaws.com
Don't directly edit, detach, or delete the network security analysis policy that AWS Ops Agent for networking manages. The AWS Organizations console prevents these actions, but the AWS Organizations API still permits mutating actions, so don't change the managed policy through the API either. If you edit it, findings can become incomplete or missing.
Step 2: Create an Agent Space with the Networking specialist
To create an Agent Space with the Networking specialist (console)
Open the AWS Ops Agent console and choose Create agent space.
Enter a name (for example,
my-ops-agent) and an optional description and response language.For Specialist, choose Networking.
Choose the Regions to analyze, and then choose Next.
For Agent scope, choose the OUs or the organization root.
Review your choices, and then choose Create agent space.
To create the Agent Space with the AWS CLI, complete the following tasks.
Create the Agent Space. This returns an
agentSpaceId.aws devops-agent create-agent-space \ --name my-ops-agent \ --aws-source-mode organization \ --region <region>Create the monitor role. The trust policy (
trust.json) pinsaws:SourceAccountandaws:SourceArnto the Agent Space. AttachAIDevOpsAgentAccessPolicy(agent reads) andAIDevOpsOrganizationsAccessPolicy(organization reads and StackSet permissions).{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "aidevops.amazonaws.com" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "aws:SourceAccount": "111122223333" }, "ArnEquals": { "aws:SourceArn": "arn:aws:aidevops:us-east-1:111122223333:agent-space/as-example" } } } ] }Associate the monitor account.
aws devops-agent associate-service \ --service-id aws \ --account-type monitor \ --assumable-role-arn <monitor-role-arn>Scope the Agent Space to an OU. The
organizationalUnitvalue covers all accounts in the OU, including future accounts. The root ID (r-*) covers the whole organization. TheaccountIdsvalue (1–1,000) narrows coverage.aws devops-agent associate-service \ --service-id aws \ --source-aws-org organizationalUnit=<ou-id>Wait for the OU association to become
valid(about 1 minute). The StackSetAIDevOpsOrgSource-<association-id>deploysAIDevOpsAgentSpaceRole-*to member accounts, anddeploymentState.deployedAccountCountincreases.NoteThe management account is never a source account. If you associate the root in an Agent Space that is hosted in the management account, the management account is listed under
deploymentState.issueswith the reasonmanagementAccountNotSupported. The management account's own resources are covered through the monitor account association. Confirm the deployment withcloudformation list-stack-instances.Add AWS Ops Agent for networking. AWS Network Manager and network security analysis trusted access must be on,
NETWORK_SECURITY_DIRECTOR_POLICYmust be enabled on the root, and the delegation policy must be in place. Otherwise, the operation returnsValidationException. This returns aruntimeMetadata.networkScopeId, and the association moves frompending-confirmationtovalidin about 30 seconds.aws devops-agent associate-service \ --service-id addon \ --addon-id networkAgent \ --regions <region-1> <region-2>Verify the associations with
list-associations. You should see the monitor (aws), the OU (aws), and AWS Ops Agent for networking (addon).aws devops-agent list-associations --agent-space-id <agent-space-id>
Change the Regions that AWS Ops Agent for networking analyzes
To change the Regions that AWS Ops Agent for networking analyzes, remove the Networking specialist, and then add it again with the new Regions. To add the Networking specialist, see Step 2: Create an Agent Space with the Networking specialist. To remove it, see Removing AWS Ops Agent for networking.
Organization-mode limits
Organization mode associates a single organization, with up to 3,000 member accounts. You can include multiple organizational units (OUs) within that organization. Associating a second organization returns an error.
An OU can be associated only once per Agent Space. You can use
update-associationto change theaccountIds, but not the OU. To switch OUs, create a new association and delete the old one.A delegated administrator can't add the management account. To cover the management account, create the Agent Space in the management account.
For more quotas, see Quotas and limitations. For troubleshooting messages, see Troubleshooting AWS Ops Agent for networking.