GET
/aws/account/{account_id}/{region}/{format}
Overview
Scan and render one region of an AWS account into a blueprint in JSON, SVG, PNG, PDF, or MxGraph format.
The time required to generate the snapshot depends on the number of resources in the AWS region.
The API behaves as a long poll, with a wait time of up to 120 seconds for the result. For most
environments, the API call will therefore directly return a blueprint. If
the wait time is exceeded, a 202 Accepted
response is returned with a
{code: STILL_PROCESSING, retry: true ...}
JSON body. The snapshot will continue processing in the background, and a retry will either immediately return the result or continue waiting.
Path Parameters
- account_id: UUID. The AWS account ID as registered with Cloudcraft.
- region: String. The AWS region, for example, “us-east-1”.
- format: String. One of “json”, “svg”, “png”, “pdf”, “mxGraph”.
Optional query parameters
- filter: String. Render a subset of the AWS account. Accepts a filter expression as used on the Live tab in the web application. The filter expression terms must be separated by spaces. The terms are substrings to be matched, key-value pairs, logical operators, or parentheses. For example, `env=dev OR env=test`.
- exclude: List of Strings. Exclude AWS services by name. For example, “ec2,sg” to exclude both EC2s and Security Groups. The service value is specified by the “type” field of Blueprint components.
- label: Boolean. Automatically label all components. Defaults to true.
- autoconnect: Boolean. Automatically connect all components. Defaults to true.
- scale: Float. Scale relative to original size (1.0). For example, 0.5 for half or 2.0 for double size.
- width: Number. Image width in pixels (for SVG, PNG, and PDF).
- height: Number. Image height in pixels (for SVG, PNG, and PDF).
- grid: Boolean. Enable or disable grid rendering.
- transparent: Boolean. Enable or disable transparent background rendering.
- landscape: Boolean. Enable or disable landscape paper format (PDF).
- paperSize: String. Applies when the format is PDF. One of “Letter”, “Legal”, “Tabloid”, “Ledger”, “A0”, “A1”, “A2”, “A3”, “A4”, or “A5”.
- projection: String. The visual style of the diagram. One of “isometric” or “2d”.
- theme: String. The color theme of the diagram. One of “light” or “dark”.
Response
Wait time exceeded
Expand All
A code indicating the status of the snapshot generation.
A message explaining the reason for the 202 response.
A flag indicating whether the client should retry the request.
{
"code": "STILL_PROCESSING",
"message": "Result wait time exceeded. Processing continues in the background, retry to receive result.",
"retry": true
}
Forbidden, insufficient privileges
Code Example
curl --location 'https://api.cloudcraft.co/aws/account/{account_id}/{region}/{format}'
package main
import (
"context"
"log"
"os"
"github.com/DataDog/cloudcraft-go"
)
func main() {
// Get the API key from the environment.
key, ok := os.LookupEnv("CLOUDCRAFT_API_KEY")
if !ok {
log.Fatal("missing env var: CLOUDCRAFT_API_KEY")
}
// Check if the command line arguments are correct.
if len(os.Args) != 2 {
log.Fatalf("usage: %s <account-id>", os.Args[0])
}
// Create new Config to initialize a Client.
cfg := cloudcraft.NewConfig(key)
// Create a new Client instance with the given Config.
client, err := cloudcraft.NewClient(cfg)
if err != nil {
log.Fatal(err)
}
// Create a new snapshot of the us-east-1 region with the given account-id
// coming from a command line argument.
snapshot, _, err := client.AWS.Snapshot(
context.Background(),
os.Args[1],
"us-east-1",
"png",
&cloudcraft.SnapshotParams{
Width: 1920,
Height: 1080,
},
)
if err != nil {
log.Fatal(err)
}
// Save the snapshot to a file.
if err := os.WriteFile("snapshot.png", snapshot, 0o600); err != nil {
log.Fatal(err)
}
}
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://api.cloudcraft.co/aws/account/{account_id}/{region}/{format}")
.method("GET", body)
.build();
Response response = client.newCall(request).execute();
from cloudcraftco import Cloudcraft
cloudcraft = Cloudcraft()
account_id = 1234
options = {"grid": True, "scale": 1.5}
region = "us-east-1"
file_format = "png"
snapshot = cloudcraft.snapshot_aws_account(account_id, region, file_format, options)
with open(f'snapshot.{file_format}', "wb") as binary_file:
binary_file.write(snapshot)
require "uri"
require "net/http"
url = URI("https://api.cloudcraft.co/aws/account/{account_id}/{region}/{format}")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Get.new(url)
response = https.request(request)
puts response.read_body
var requestOptions = {
method: 'GET',
redirect: 'follow'
};
fetch("https://api.cloudcraft.co/aws/account/{account_id}/{region}/{format}", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));