Enable Storage Management for a bucket

PUT https://api.ap1.datadoghq.com/api/v2/cloudinventoryservice/syncconfigshttps://api.ap2.datadoghq.com/api/v2/cloudinventoryservice/syncconfigshttps://api.datadoghq.eu/api/v2/cloudinventoryservice/syncconfigshttps://api.ddog-gov.com/api/v2/cloudinventoryservice/syncconfigshttps://api.us2.ddog-gov.com/api/v2/cloudinventoryservice/syncconfigshttps://api.datadoghq.com/api/v2/cloudinventoryservice/syncconfigshttps://api.us3.datadoghq.com/api/v2/cloudinventoryservice/syncconfigshttps://api.us5.datadoghq.com/api/v2/cloudinventoryservice/syncconfigs

Overview

Enable Storage Management for an S3 bucket, GCS bucket, or Azure container by registering the destination that holds its inventory reports. Set data.id to the cloud provider (aws, gcp, or azure) and provide the matching settings under data.attributes. Calling this endpoint with the same provider replaces the existing configuration. This endpoint requires the aws_configurations_manage permission.

Request

Body Data (required)

Expand All

Field

Type

Description

data [required]

object

Storage Management configuration data for the create or update request.

attributes [required]

object

Settings for the cloud provider specified in data.id. Include only the matching provider object (aws, gcp, or azure).

aws

object

AWS settings for the S3 bucket Storage Management reads inventory reports from.

aws_account_id [required]

string

AWS account ID that owns the inventory bucket.

destination_bucket_name [required]

string

Name of the S3 bucket containing inventory files.

destination_bucket_region [required]

string

AWS Region of the inventory bucket.

destination_prefix

string

Object key prefix where inventory reports are written. Omit or set to / when reports are written at the bucket root.

azure

object

Azure settings for the storage account and container with inventory data.

client_id [required]

string

Azure AD application (client) ID used for access.

container [required]

string

Blob container name.

resource_group [required]

string

Resource group containing the storage account.

storage_account [required]

string

Storage account name.

subscription_id [required]

string

Azure subscription ID.

tenant_id [required]

string

Azure AD tenant ID.

gcp

object

GCP settings for buckets involved in inventory reporting.

destination_bucket_name [required]

string

GCS bucket name where Datadog reads inventory reports.

project_id [required]

string

GCP project ID for the inventory destination bucket.

service_account_email [required]

string

Service account email used to read the destination bucket.

source_bucket_name [required]

string

GCS bucket name that inventory reports are generated for.

id [required]

enum

Cloud provider for this sync configuration (aws, gcp, or azure). For requests, must match the provider block supplied under attributes. Allowed enum values: aws,gcp,azure

type [required]

enum

Always cloud_provider. Allowed enum values: cloud_provider

{
  "data": {
    "attributes": {
      "aws": {
        "aws_account_id": "123456789012",
        "destination_bucket_name": "my-inventory-bucket",
        "destination_bucket_region": "us-east-1",
        "destination_prefix": "logs/"
      },
      "azure": {
        "client_id": "11111111-1111-1111-1111-111111111111",
        "container": "inventory-container",
        "resource_group": "my-resource-group",
        "storage_account": "mystorageaccount",
        "subscription_id": "33333333-3333-3333-3333-333333333333",
        "tenant_id": "22222222-2222-2222-2222-222222222222"
      },
      "gcp": {
        "destination_bucket_name": "my-inventory-reports",
        "project_id": "my-gcp-project",
        "service_account_email": "reader@my-gcp-project.iam.gserviceaccount.com",
        "source_bucket_name": "my-monitored-bucket"
      }
    },
    "id": "aws",
    "type": "cloud_provider"
  }
}

Response

OK

Storage Management configuration returned after a create or update. Additional read-only fields appear on list and get responses.

Expand All

Field

Type

Description

data [required]

object

Storage Management configuration data.

attributes [required]

object

Attributes for a Storage Management configuration. Fields other than id may be empty in the response immediately after a create or update; subsequent reads return the full configuration.

aws_account_id [required]

string

AWS account ID for the inventory bucket.

aws_bucket_name [required]

string

AWS S3 bucket name for inventory files.

aws_region [required]

string

AWS Region for the inventory bucket.

azure_client_id [required]

string

Azure AD application (client) ID.

azure_container_name [required]

string

Azure blob container name.

azure_storage_account_name [required]

string

Azure storage account name.

azure_tenant_id [required]

string

Azure AD tenant ID.

cloud_provider [required]

enum

Cloud provider for this sync configuration (aws, gcp, or azure). For requests, must match the provider block supplied under attributes. Allowed enum values: aws,gcp,azure

error [required]

string

Human-readable error detail when sync is unhealthy.

error_code [required]

string

Machine-readable error code when sync is unhealthy.

gcp_bucket_name [required]

string

GCS bucket name for inventory files Datadog reads.

gcp_project_id [required]

string

GCP project ID.

gcp_service_account_email [required]

string

Service account email for bucket access.

prefix [required]

string

Object key prefix where inventory reports are written. Returns / when reports are written at the bucket root.

id [required]

string

Unique identifier for this Storage Management configuration.

type [required]

enum

Always sync_configs. Allowed enum values: sync_configs

{
  "data": {
    "attributes": {
      "aws_account_id": "123456789012",
      "aws_bucket_name": "my-inventory-bucket",
      "aws_region": "us-east-1",
      "azure_client_id": "11111111-1111-1111-1111-111111111111",
      "azure_container_name": "inventory-container",
      "azure_storage_account_name": "mystorageaccount",
      "azure_tenant_id": "22222222-2222-2222-2222-222222222222",
      "cloud_provider": "aws",
      "error": "",
      "error_code": "",
      "gcp_bucket_name": "my-inventory-reports",
      "gcp_project_id": "my-gcp-project",
      "gcp_service_account_email": "reader@my-gcp-project.iam.gserviceaccount.com",
      "prefix": "logs/"
    },
    "id": "abc123",
    "type": "sync_configs"
  }
}

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short human-readable summary of the error.

{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example

                  ## AWS inventory bucket
# 

# Curl command
curl -X PUT "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.us2.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/cloudinventoryservice/syncconfigs" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "data": { "attributes": { "aws": { "aws_account_id": "123456789012", "destination_bucket_name": "my-inventory-bucket", "destination_bucket_region": "us-east-1", "destination_prefix": "logs/" } }, "id": "aws", "type": "cloud_provider" } } EOF
"""
Enable Storage Management for a bucket returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.storage_management_api import StorageManagementApi
from datadog_api_client.v2.model.cloud_inventory_cloud_provider_id import CloudInventoryCloudProviderId
from datadog_api_client.v2.model.cloud_inventory_cloud_provider_request_type import (
    CloudInventoryCloudProviderRequestType,
)
from datadog_api_client.v2.model.cloud_inventory_sync_config_aws_request_attributes import (
    CloudInventorySyncConfigAWSRequestAttributes,
)
from datadog_api_client.v2.model.cloud_inventory_sync_config_azure_request_attributes import (
    CloudInventorySyncConfigAzureRequestAttributes,
)
from datadog_api_client.v2.model.cloud_inventory_sync_config_gcp_request_attributes import (
    CloudInventorySyncConfigGCPRequestAttributes,
)
from datadog_api_client.v2.model.upsert_cloud_inventory_sync_config_request import UpsertCloudInventorySyncConfigRequest
from datadog_api_client.v2.model.upsert_cloud_inventory_sync_config_request_attributes import (
    UpsertCloudInventorySyncConfigRequestAttributes,
)
from datadog_api_client.v2.model.upsert_cloud_inventory_sync_config_request_data import (
    UpsertCloudInventorySyncConfigRequestData,
)

body = UpsertCloudInventorySyncConfigRequest(
    data=UpsertCloudInventorySyncConfigRequestData(
        attributes=UpsertCloudInventorySyncConfigRequestAttributes(
            aws=CloudInventorySyncConfigAWSRequestAttributes(
                aws_account_id="123456789012",
                destination_bucket_name="my-inventory-bucket",
                destination_bucket_region="us-east-1",
                destination_prefix="logs/",
            ),
            azure=CloudInventorySyncConfigAzureRequestAttributes(
                client_id="11111111-1111-1111-1111-111111111111",
                container="inventory-container",
                resource_group="my-resource-group",
                storage_account="mystorageaccount",
                subscription_id="33333333-3333-3333-3333-333333333333",
                tenant_id="22222222-2222-2222-2222-222222222222",
            ),
            gcp=CloudInventorySyncConfigGCPRequestAttributes(
                destination_bucket_name="my-inventory-reports",
                project_id="my-gcp-project",
                service_account_email="reader@my-gcp-project.iam.gserviceaccount.com",
                source_bucket_name="my-monitored-bucket",
            ),
        ),
        id=CloudInventoryCloudProviderId.AWS,
        type=CloudInventoryCloudProviderRequestType.CLOUD_PROVIDER,
    ),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = StorageManagementApi(api_client)
    response = api_instance.upsert_sync_config(body=body)

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
# Enable Storage Management for a bucket returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::StorageManagementAPI.new

body = DatadogAPIClient::V2::UpsertCloudInventorySyncConfigRequest.new({
  data: DatadogAPIClient::V2::UpsertCloudInventorySyncConfigRequestData.new({
    attributes: DatadogAPIClient::V2::UpsertCloudInventorySyncConfigRequestAttributes.new({
      aws: DatadogAPIClient::V2::CloudInventorySyncConfigAWSRequestAttributes.new({
        aws_account_id: "123456789012",
        destination_bucket_name: "my-inventory-bucket",
        destination_bucket_region: "us-east-1",
        destination_prefix: "logs/",
      }),
      azure: DatadogAPIClient::V2::CloudInventorySyncConfigAzureRequestAttributes.new({
        client_id: "11111111-1111-1111-1111-111111111111",
        container: "inventory-container",
        resource_group: "my-resource-group",
        storage_account: "mystorageaccount",
        subscription_id: "33333333-3333-3333-3333-333333333333",
        tenant_id: "22222222-2222-2222-2222-222222222222",
      }),
      gcp: DatadogAPIClient::V2::CloudInventorySyncConfigGCPRequestAttributes.new({
        destination_bucket_name: "my-inventory-reports",
        project_id: "my-gcp-project",
        service_account_email: "reader@my-gcp-project.iam.gserviceaccount.com",
        source_bucket_name: "my-monitored-bucket",
      }),
    }),
    id: DatadogAPIClient::V2::CloudInventoryCloudProviderId::AWS,
    type: DatadogAPIClient::V2::CloudInventoryCloudProviderRequestType::CLOUD_PROVIDER,
  }),
})
p api_instance.upsert_sync_config(body)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
// Enable Storage Management for a bucket returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)

func main() {
	body := datadogV2.UpsertCloudInventorySyncConfigRequest{
		Data: datadogV2.UpsertCloudInventorySyncConfigRequestData{
			Attributes: datadogV2.UpsertCloudInventorySyncConfigRequestAttributes{
				Aws: &datadogV2.CloudInventorySyncConfigAWSRequestAttributes{
					AwsAccountId:            "123456789012",
					DestinationBucketName:   "my-inventory-bucket",
					DestinationBucketRegion: "us-east-1",
					DestinationPrefix:       datadog.PtrString("logs/"),
				},
				Azure: &datadogV2.CloudInventorySyncConfigAzureRequestAttributes{
					ClientId:       "11111111-1111-1111-1111-111111111111",
					Container:      "inventory-container",
					ResourceGroup:  "my-resource-group",
					StorageAccount: "mystorageaccount",
					SubscriptionId: "33333333-3333-3333-3333-333333333333",
					TenantId:       "22222222-2222-2222-2222-222222222222",
				},
				Gcp: &datadogV2.CloudInventorySyncConfigGCPRequestAttributes{
					DestinationBucketName: "my-inventory-reports",
					ProjectId:             "my-gcp-project",
					ServiceAccountEmail:   "reader@my-gcp-project.iam.gserviceaccount.com",
					SourceBucketName:      "my-monitored-bucket",
				},
			},
			Id:   datadogV2.CLOUDINVENTORYCLOUDPROVIDERID_AWS,
			Type: datadogV2.CLOUDINVENTORYCLOUDPROVIDERREQUESTTYPE_CLOUD_PROVIDER,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewStorageManagementApi(apiClient)
	resp, r, err := api.UpsertSyncConfig(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `StorageManagementApi.UpsertSyncConfig`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `StorageManagementApi.UpsertSyncConfig`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Enable Storage Management for a bucket returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.StorageManagementApi;
import com.datadog.api.client.v2.model.CloudInventoryCloudProviderId;
import com.datadog.api.client.v2.model.CloudInventoryCloudProviderRequestType;
import com.datadog.api.client.v2.model.CloudInventorySyncConfigAWSRequestAttributes;
import com.datadog.api.client.v2.model.CloudInventorySyncConfigAzureRequestAttributes;
import com.datadog.api.client.v2.model.CloudInventorySyncConfigGCPRequestAttributes;
import com.datadog.api.client.v2.model.CloudInventorySyncConfigResponse;
import com.datadog.api.client.v2.model.UpsertCloudInventorySyncConfigRequest;
import com.datadog.api.client.v2.model.UpsertCloudInventorySyncConfigRequestAttributes;
import com.datadog.api.client.v2.model.UpsertCloudInventorySyncConfigRequestData;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    StorageManagementApi apiInstance = new StorageManagementApi(defaultClient);

    UpsertCloudInventorySyncConfigRequest body =
        new UpsertCloudInventorySyncConfigRequest()
            .data(
                new UpsertCloudInventorySyncConfigRequestData()
                    .attributes(
                        new UpsertCloudInventorySyncConfigRequestAttributes()
                            .aws(
                                new CloudInventorySyncConfigAWSRequestAttributes()
                                    .awsAccountId("123456789012")
                                    .destinationBucketName("my-inventory-bucket")
                                    .destinationBucketRegion("us-east-1")
                                    .destinationPrefix("logs/"))
                            .azure(
                                new CloudInventorySyncConfigAzureRequestAttributes()
                                    .clientId("11111111-1111-1111-1111-111111111111")
                                    .container("inventory-container")
                                    .resourceGroup("my-resource-group")
                                    .storageAccount("mystorageaccount")
                                    .subscriptionId("33333333-3333-3333-3333-333333333333")
                                    .tenantId("22222222-2222-2222-2222-222222222222"))
                            .gcp(
                                new CloudInventorySyncConfigGCPRequestAttributes()
                                    .destinationBucketName("my-inventory-reports")
                                    .projectId("my-gcp-project")
                                    .serviceAccountEmail(
                                        "reader@my-gcp-project.iam.gserviceaccount.com")
                                    .sourceBucketName("my-monitored-bucket")))
                    .id(CloudInventoryCloudProviderId.AWS)
                    .type(CloudInventoryCloudProviderRequestType.CLOUD_PROVIDER));

    try {
      CloudInventorySyncConfigResponse result = apiInstance.upsertSyncConfig(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling StorageManagementApi#upsertSyncConfig");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
// Enable Storage Management for a bucket returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_storage_management::StorageManagementAPI;
use datadog_api_client::datadogV2::model::CloudInventoryCloudProviderId;
use datadog_api_client::datadogV2::model::CloudInventoryCloudProviderRequestType;
use datadog_api_client::datadogV2::model::CloudInventorySyncConfigAWSRequestAttributes;
use datadog_api_client::datadogV2::model::CloudInventorySyncConfigAzureRequestAttributes;
use datadog_api_client::datadogV2::model::CloudInventorySyncConfigGCPRequestAttributes;
use datadog_api_client::datadogV2::model::UpsertCloudInventorySyncConfigRequest;
use datadog_api_client::datadogV2::model::UpsertCloudInventorySyncConfigRequestAttributes;
use datadog_api_client::datadogV2::model::UpsertCloudInventorySyncConfigRequestData;

#[tokio::main]
async fn main() {
    let body =
        UpsertCloudInventorySyncConfigRequest::new(UpsertCloudInventorySyncConfigRequestData::new(
            UpsertCloudInventorySyncConfigRequestAttributes::new()
                .aws(
                    CloudInventorySyncConfigAWSRequestAttributes::new(
                        "123456789012".to_string(),
                        "my-inventory-bucket".to_string(),
                        "us-east-1".to_string(),
                    )
                    .destination_prefix("logs/".to_string()),
                )
                .azure(CloudInventorySyncConfigAzureRequestAttributes::new(
                    "11111111-1111-1111-1111-111111111111".to_string(),
                    "inventory-container".to_string(),
                    "my-resource-group".to_string(),
                    "mystorageaccount".to_string(),
                    "33333333-3333-3333-3333-333333333333".to_string(),
                    "22222222-2222-2222-2222-222222222222".to_string(),
                ))
                .gcp(CloudInventorySyncConfigGCPRequestAttributes::new(
                    "my-inventory-reports".to_string(),
                    "my-gcp-project".to_string(),
                    "reader@my-gcp-project.iam.gserviceaccount.com".to_string(),
                    "my-monitored-bucket".to_string(),
                )),
            CloudInventoryCloudProviderId::AWS,
            CloudInventoryCloudProviderRequestType::CLOUD_PROVIDER,
        ));
    let configuration = datadog::Configuration::new();
    let api = StorageManagementAPI::with_config(configuration);
    let resp = api.upsert_sync_config(body).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}

Instructions

First install the library and its dependencies and then save the example to src/main.rs and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
/**
 * Enable Storage Management for a bucket returns "OK" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v2.StorageManagementApi(configuration);

const params: v2.StorageManagementApiUpsertSyncConfigRequest = {
  body: {
    data: {
      attributes: {
        aws: {
          awsAccountId: "123456789012",
          destinationBucketName: "my-inventory-bucket",
          destinationBucketRegion: "us-east-1",
          destinationPrefix: "logs/",
        },
        azure: {
          clientId: "11111111-1111-1111-1111-111111111111",
          container: "inventory-container",
          resourceGroup: "my-resource-group",
          storageAccount: "mystorageaccount",
          subscriptionId: "33333333-3333-3333-3333-333333333333",
          tenantId: "22222222-2222-2222-2222-222222222222",
        },
        gcp: {
          destinationBucketName: "my-inventory-reports",
          projectId: "my-gcp-project",
          serviceAccountEmail: "reader@my-gcp-project.iam.gserviceaccount.com",
          sourceBucketName: "my-monitored-bucket",
        },
      },
      id: "aws",
      type: "cloud_provider",
    },
  },
};

apiInstance
  .upsertSyncConfig(params)
  .then((data: v2.CloudInventorySyncConfigResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"