Managing environments and projects
An environment holds the accounts and AWS Regions that AWS Assurance evaluates, and a project divides that environment into a smaller unit of work with its own resource scope. For the definitions of these terms, see Core concepts. This chapter describes how you create and scope projects, and how you control the Regions an environment scans.
After you create an environment, you create a project. You can create more projects at any time, each with its own resource scope. You define the scope with resource filters. Their query syntax is based on the AWS Resource Explorer syntax. The filters run against your environment’s resource inventory, and some rules differ from Resource Explorer. Resource filters select resources by service, resource type, account, Region, and tags, instead of by a list of Amazon Resource Names (ARNs).
Topics
Creating a project
To create a project in the web application, choose Create project, enter a name, and choose the services, resource types, accounts, Regions, or tags to include. Check the live preview to confirm the scope before you create the project. The web application turns your selections into the resource filters that this chapter describes. For a walkthrough, see Running your first assessment.
To create a project with the API, call CreateProject with the environment’s Amazon Resource Name (ARN), a project name, and optional resource filters. You can also add filters later.
A project name must start with a letter or a number. The remaining characters can be letters, numbers, periods (.), underscores (_), and hyphens (-). Other characters, including the number sign (#), are rejected.
The name DEFAULT is reserved without regard to case, so you can’t create a project named DEFAULT or default.
Project names are unique within an environment, and the comparison is case-sensitive. If you create a project with a name that’s already in use, AWS Assurance returns success, but it doesn’t create a project or change the existing one. It ignores the filters in the request. To change a project’s scope, update the existing project.
Scoping a project by resource attributes
A project’s scope is a list of resource filter strings. Each string is a space-separated set of tokens, and each token has a prefix that names the dimension it filters on.
The following prefixes are supported. Prefix a token with a hyphen (-) to negate it and exclude matching resources.
| Prefix | Matches |
|---|---|
|
|
The AWS service that owns the resource, for example |
|
|
The resource type, for example |
|
|
The AWS account that owns the resource. The value must be exactly 12 digits. |
|
|
The Region the resource is in, for example |
|
|
Tags on the resource. See Scoping a project by tags. |
|
|
Excludes a specific resource by ARN. |
Prefixes are not case sensitive, so accountid: and AccountId: behave the same way. Region values are lowercased before they are compared. Other values keep the case you enter.
Resource filters are attribute-based. There is no positive id: prefix, so you cannot define a project scope as a list of individual resource ARNs. Instead, describe the set of resources you want with service:, resourcetype:, accountid:, region:, and tag filters, then remove individual resources you do not want with -id:. In the AWS Assurance web application, clearing a resource from the selection in the project’s resource list records an -id: exclusion filter for that resource.
The application: and resourcetype.supports: prefixes are not supported and are rejected with a validation error. AWS Assurance does not scope a project to the members of an application; to approximate that, scope the project to a tag that the resources share, such as the AWS CloudFormation stack tag described in Scoping a project to an AWS CloudFormation stack.
Operators
Within a filter string, you can use the following operators.
| Operator | Meaning |
|---|---|
|
Space |
Separates filters. How filters combine depends on their kind. For more information, see How filters combine. |
|
Comma ( |
OR within a single token. |
|
Leading hyphen ( |
NOT. |
|
Trailing asterisk ( |
Prefix wildcard. At least three characters must precede the asterisk, except for a bare |
|
Double quotation marks ( |
Preserves spaces in a value, for example |
|
Backslash ( |
Escapes the next character. |
How filters combine
A resource is in a project’s scope when all of the following are true:
-
It matches at least one listed service or resource type. If you list no services or resource types, every service and resource type matches.
-
It’s in one of the listed accounts and one of the listed Regions. If you list no accounts, every account in the environment matches. If you list no Regions, every Region configured on the environment matches.
-
It matches every tag filter.
-
It doesn’t match any negated filter. Negations take precedence over positive filters.
Several values of one kind are alternatives, whether you list them in one token or in separate tokens. For example, service:s3 service:lambda matches the same resources as service:s3,lambda. The separate strings in a project’s filter list are combined into one filter.
Global resources stay in scope under any region: filter. To remove them, use -region:global. For more information, see Global resources and Region filters.
Filter values are case-sensitive, except Region values. Resource types use the lowercase service:type form, for example ec2:instance, not AWS::EC2::Instance.
Examples
Scope a project to Amazon S3 buckets and Amazon DynamoDB tables in one account:
service:s3,dynamodb accountid:111122223333
Scope a project to all Amazon EC2 instances except two that are out of scope for the audit:
resourcetype:ec2:instance -id:arn:aws:ec2:us-east-1:111122223333:instance/i-0abc123def4567890 -id:arn:aws:ec2:us-east-1:111122223333:instance/i-0fed987cba6543210
Scope a project to two Regions and exclude a shared services account:
region:us-east-1,eu-west-1 -accountid:444455556666
Scoping a project by tags
Tag filters let you scope a project to the resources your organization already labels. AWS Assurance supports four forms, each of which you can negate with a leading hyphen.
| Filter | Matches |
|---|---|
|
|
Resources that carry the tag key with that value. |
|
|
Resources that carry the tag key, with any value. |
|
|
Resources that carry that value on any tag key. |
|
|
Resources that carry at least one tag, and resources that carry no tags. |
Tag values and tag keys support trailing asterisk (
) prefix wildcards, with at least three characters before the asterisk. For example, tag.key:aws: matches every AWS-assigned tag key.
Tag keys that contain colons, such as aws:cloudformation:stack-name, are supported.
How tag filters combine
When you specify more than one tag filter, all of them must hold. The following scope matches only resources that carry both an Environment=Production tag and a DataClassification tag key:
tag:Environment=Production tag.key:DataClassification
Within a single tag: token, comma-separated values form a union. The following scope matches a resource that carries either tag:
tag:Owner=alice,Team=backend
For a comma-separated list to be treated as a union of key-value pairs, every segment must contain an equals sign (=). If any segment omits it, AWS Assurance treats the whole value as a list of tag keys instead of key-value pairs.
How tag matching works
AWS Assurance evaluates tag filters after it enumerates resources. It lists the resources in scope, retrieves their tags, and then drops the resources that do not match your tag filters.
AWS Assurance reads tags from the AWS Config service-linked recorder that it manages in your account, not from the AWS Resource Groups Tagging API. A resource whose tags AWS Assurance hasn’t received is treated as untagged. Such a resource doesn’t match a tag:key=value or tag.key: filter, and it’s excluded from the project’s scope, even if the tag exists on the resource. AWS Config doesn’t record tags for every resource type. If you expect a resource to be in scope and it isn’t, check whether AWS Config records tags for its resource type.
Scoping a project to an AWS CloudFormation stack
To evaluate the resources that belong to one application, scope the project to the AWS CloudFormation stack that deploys it. AWS CloudFormation applies the aws:cloudformation:stack-name tag to the resources it creates, and you can filter on that tag.
The following scope matches every tagged resource in the my-payments-service stack:
tag:aws:cloudformation:stack-name=my-payments-service
To scope a project to several stacks, list them as a union in one token:
tag:aws:cloudformation:stack-name=my-payments-api,aws:cloudformation:stack-name=my-payments-worker
To narrow the scope further, add other filters. The following scope matches only the Amazon S3 buckets in one stack, in one account:
tag:aws:cloudformation:stack-name=my-payments-service service:s3 accountid:111122223333
AWS CloudFormation does not tag every resource type it creates, and a resource that is created outside the stack is not tagged with the stack name. Review the project’s resource list after the first scan to confirm that the scope contains the resources you expect, and widen the filters if a resource is missing.
Configuring Regions for an environment
Regions are a property of the environment, not of a project. Every project in an environment scans the same set of Regions, and every account in the environment is scanned across that same set.
You set the Region list when you create an environment, and you can change it later. Updating an environment replaces the entire Region list with the list you supply, so include every Region you want in scope, not only the ones you are adding.
If you leave the Region list empty, AWS Assurance evaluates every generally available Region in the partition, including Regions that AWS adds later, not only the Region that the environment is in. If you set a Region list, AWS Assurance evaluates only those Regions, and new Regions aren’t added automatically. To go back to all Regions, update the environment with an empty list.
If the list includes a value that isn’t a generally available Region in the partition, or includes a Region twice, the request fails with a validation error. For the Regions where you can create an environment, see Region considerations. The AWS GovCloud (US) Regions and the AWS China Regions are not supported.
How AWS Assurance selects accounts to scan depends on the environment. An environment that is integrated with AWS Organizations scans the member accounts of the organization, which you can narrow to specific organizational units. An environment that is not integrated with AWS Organizations scans the account that owns the environment plus the accounts that have accepted an invitation to it. For more information, see AWS Assurance and AWS Organizations and Cross-account assessments.
Narrowing Regions with a project filter
A region: or -region: filter on a project narrows the environment’s Region list for that project. AWS Assurance applies the filter when it plans the scan, so it does not query a Region that the filter excludes.
A project filter can only remove Regions from the environment’s list. It cannot add one. If you filter on a Region that the environment does not include, the project matches no resources in that Region. Add the Region to the environment first.
For example, in an environment configured for us-east-1, us-west-2, and eu-west-1, the following project scope evaluates only us-east-1:
region:us-east-1
And the following project scope evaluates us-east-1 and us-west-2:
-region:eu-west-1
Global resources and Region filters
A resource is global when its ARN doesn’t include a Region. IAM roles, IAM policies, and Amazon Route 53 hosted zones are examples. AWS Assurance records each global resource once, under the Region value global.
Global resources stay in a project’s scope whatever Regions you name. They are attributed to the account that owns them, not to a Region, so a filter such as region:us-east-1 or -region:eu-west-1 does not remove them. To exclude every global resource, add -region:global. For example, the following project scope evaluates only the resources in us-east-1:
region:us-east-1 -region:global
To scope a project to global resources only, use region:global. You can also exclude a global resource by account with -accountid:, by service or resource type, or by ARN with -id:.
Amazon S3 is an exception. Amazon S3 ARNs don’t contain a Region, but in the inventory and the resource list, AWS Assurance attributes buckets to the Region that it discovers them in and treats them as regional resources. Region filters apply to them.
Tagging an environment in AWS Assurance
Use tags to categorize your environments and to control access to them. Environment tags label the AWS Assurance environment itself. They don’t affect which resources a project includes. To scope a project by the tags on your resources, see Scoping a project by tags.
In the AWS Management Console, add tags in the Tags section when you create the environment, or choose Manage tags on the environment page later.
With the API, to add tags when you create an environment, include the tags parameter in the CreateEnvironment request. To create an environment with tags, you must have both the assurance:CreateEnvironment and assurance:TagResource permissions. UpdateEnvironment does not change tags.
Each of the following operations takes the environment ARN in resourceArn. After you create the environment, use these operations to manage its tags:
-
TagResource -
Adds tags to the environment. If a tag key already exists,
TagResourcereplaces the value of that tag. -
UntagResource -
Removes the tags that have the keys that you specify in
tagKeys. -
ListTagsForResource -
Returns the tags of the environment.
Each tag has a key and a value. The following table shows the rules for tags.
| Constraint | Value |
|---|---|
|
Tag key length |
1 to 128 characters |
|
Tag value length |
256 characters or fewer |
|
Tags for each environment |
Up to 50 |
|
Reserved tag key prefix |
|
If a request does not obey these rules, or the resourceArn is not the ARN of an environment, the request fails. For more information about tag quotas, see Quotas for AWS Assurance.
You can use the tags of an environment to control access to the environment with attribute-based access control (ABAC). In an IAM policy, use the aws:ResourceTag condition key. For more information about ABAC, see ABAC with AWS Assurance.
Deleting an environment in AWS Assurance
An environment must have no projects before you delete it. While an environment has any project, DeleteEnvironment fails with a ConflictException. The message is The environment has projects. Delete the environment’s projects, then delete the environment. S3 sources, which are the Amazon S3 buckets and prefixes that you connect as evidence sources, do not block DeleteEnvironment. You can delete an environment that still has S3 sources.
To delete an environment in the AWS Management Console, choose Delete on the environment page. If the environment has projects or third-party connections, the dialog lists them. Delete them, one at a time or with Delete all, and then delete the environment. You can also delete a project from the web application, where Delete project is in the project menu.
To delete an environment that has projects with the AWS CLI, use the following procedure. The procedure deletes the projects first, because you cannot delete an environment that has projects. Before you begin, install and configure the AWS Command Line Interface (AWS CLI). For more information about installation, see Getting started with the AWS CLI in the AWS Command Line Interface User Guide for Version 2.
You need the following permissions:
-
assurance:ListProjects,assurance:DeleteProject, andassurance:DeleteEnvironment. -
sso:DeleteApplication, if the environment uses IAM Identity Center. AWS Assurance uses your permissions to delete the environment’s IAM Identity Center application.
For more information about forward access sessions, see Forward access sessions for AWS Assurance.
By default, the AWS CLI gets all pages of the results, so step 1 lists every project. The commands use example values. In each command, replace the following values with your own values:
-
arn:aws:assurance:us-east-1:111122223333:environment/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 -
The ARN of your environment.
-
payments-prod -
The name of a project that the output of step 1 lists.
You cannot restore a deleted environment or a deleted project. A deletion is permanent.
To delete environments that have projects
-
To list the projects in the environment, run the following AWS CLI command in a terminal:
aws assurance list-projects \ --environment-arn arn:aws:assurance:us-east-1:111122223333:environment/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111The following example output shows one project:
{ "projects": [ { "project": "payments-prod" } ] } -
To delete the projects that the output lists, run the following AWS CLI command once for each project:
aws assurance delete-project \ --environment-arn arn:aws:assurance:us-east-1:111122223333:environment/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \ --project payments-prod -
To delete the environment, run the following AWS CLI command:
aws assurance delete-environment \ --environment-arn arn:aws:assurance:us-east-1:111122223333:environment/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
To delete an environment with the AWS Assurance API, call DeleteProject for each project. Then call DeleteEnvironment with the environment ARN (environmentArn).
Data that AWS Assurance deletes with an environment
DeleteProject deletes a project and all of its associated resources.
DeleteEnvironment returns when AWS Assurance accepts the request. A background job then deletes the following data of the environment:
-
Annotations
-
Assessments
-
Chat sessions
-
Control status overrides
-
Custom frameworks and custom controls
-
Assessment schedules and resource scan settings
-
Evidence records and stored evidence content
-
Framework enablements
-
Projects
-
Resource discovery results, and the AWS Config service-linked recorder when no other environment uses it
-
Tasks and comments
AWS Assurance doesn’t delete objects in your own Amazon S3 buckets, such as the buckets that you connect as evidence sources.
Before the call returns, AWS Assurance also deletes the IAM Identity Center application of the environment, and removes the tags of the environment.
DeleteEnvironment is idempotent. If a request fails or times out, you can send it again.
Deleting an environment doesn’t delete the service-linked role AWSServiceRoleForAssurance. To remove the role, see Service-linked roles for AWS Assurance.
For more information about what happens to evidence content, including objects in your own S3 buckets, see Deleting evidence and retention.
Quotas for environments and projects
You can have up to 10 projects in each environment, and up to 10 resource filter strings in each project. Other quotas apply to the number of Regions and organizational units in an environment. These quotas are fixed, and you can’t request an increase. For all quota values, see Quotas for AWS Assurance.