You can view all attributes for IaC+ and cloud resources in an Organization. This allows you to inventory all of your resources across cloud provider accounts or see the recorded state of any resource during the most recent scan.
View all resources
To list all resources in an Organization, send a request to the /cloud/resources endpoint in the following format:
curl -X GET \
'https://api.snyk.io/rest/orgs/YOUR-ORGANIZATION-ID/cloud/resources?version=2022-12-21~beta' \
-H 'Authorization: token YOUR-API-TOKEN'
Understand the API response
Snyk returns a JSON document containing information about all resources in the Organization, for example:
The following table lists some key attributes from the API response:
Attribute
Definition
data.id
Resource ID
data.attributes.environment_id
ID of the environment containing the resource
data.attributes.scan_id
ID of the scan where this resource was first detected
data.attributes.resource_type
Resource type
data.attributes.native_id
Cloud provider's unique identifier for the resource; for AWS, the Amazon Resource Name (ARN)
data.attributes.state
Resource attributes at the time of the most recent scan
Filter resource list
Query parameters allow you to filter the list of resources.
For example, to return resources from a single environment, add environment_id=YOUR-ENVIRONMENT-ID to the URL:
curl -X GET \
'https://api.snyk.io/rest/orgs/YOUR-ORGANIZATION-ID/cloud/resources?environment_id=YOUR-ENVIRONMENT-ID&version=2022-12-21~beta' \
-H 'Authorization: token YOUR-API-TOKEN'
Some parameters allow you to specify multiple values. To return resources in Amazon Web Services (AWS) regions us-east-1 or us-east-2, add location=us-east-1,us-east-2 to the URL:
curl -X GET \
'https://api.snyk.io/rest/orgs/YOUR-ORGANIZATION-ID/cloud/resources?location=us-east-1,us-east-2&version=2022-12-21~beta' \
-H 'Authorization: token YOUR-API-TOKEN'
You can combine query parameters by using the & symbol. To return only 5 AWS S3 buckets, add resource_type=aws_s3_bucket&limit=5 to the URL:
curl -X GET \
'https://api.snyk.io/rest/orgs/YOUR-ORGANIZATION-ID/cloud/resources?resource_type=aws_s3_bucket&limit=5&version=2022-12-21~beta' \
-H 'Authorization: token YOUR-API-TOKEN'