CreateRuleCommand

Creates a rule in Amazon DataZone. A rule is a formal agreement that enforces specific requirements across user workflows (e.g., publishing assets to the catalog, requesting subscriptions, creating projects) within the Amazon DataZone data portal. These rules help maintain consistency, ensure compliance, and uphold governance standards in data management processes. For instance, a metadata enforcement rule can specify the required information for creating a subscription request or publishing a data asset to the catalog, ensuring alignment with organizational standards.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { DataZoneClient, CreateRuleCommand } from "@aws-sdk/client-datazone"; // ES Modules import
// const { DataZoneClient, CreateRuleCommand } = require("@aws-sdk/client-datazone"); // CommonJS import
const client = new DataZoneClient(config);
const input = { // CreateRuleInput
  domainIdentifier: "STRING_VALUE", // required
  name: "STRING_VALUE", // required
  target: { // RuleTarget Union: only one key present
    domainUnitTarget: { // DomainUnitTarget
      domainUnitId: "STRING_VALUE", // required
      includeChildDomainUnits: true || false,
    },
  },
  action: "CREATE_LISTING_CHANGE_SET" || "CREATE_SUBSCRIPTION_REQUEST", // required
  scope: { // RuleScope
    assetType: { // AssetTypesForRule
      selectionMode: "ALL" || "SPECIFIC", // required
      specificAssetTypes: [ // RuleAssetTypeList
        "STRING_VALUE",
      ],
    },
    dataProduct: true || false,
    project: { // ProjectsForRule
      selectionMode: "ALL" || "SPECIFIC", // required
      specificProjects: [ // RuleProjectIdentifierList
        "STRING_VALUE",
      ],
    },
  },
  detail: { // RuleDetail Union: only one key present
    metadataFormEnforcementDetail: { // MetadataFormEnforcementDetail
      requiredMetadataForms: [ // RequiredMetadataFormList
        { // MetadataFormReference
          typeIdentifier: "STRING_VALUE", // required
          typeRevision: "STRING_VALUE", // required
        },
      ],
    },
  },
  description: "STRING_VALUE",
  clientToken: "STRING_VALUE",
};
const command = new CreateRuleCommand(input);
const response = await client.send(command);
// { // CreateRuleOutput
//   identifier: "STRING_VALUE", // required
//   name: "STRING_VALUE", // required
//   ruleType: "METADATA_FORM_ENFORCEMENT", // required
//   target: { // RuleTarget Union: only one key present
//     domainUnitTarget: { // DomainUnitTarget
//       domainUnitId: "STRING_VALUE", // required
//       includeChildDomainUnits: true || false,
//     },
//   },
//   action: "CREATE_LISTING_CHANGE_SET" || "CREATE_SUBSCRIPTION_REQUEST", // required
//   scope: { // RuleScope
//     assetType: { // AssetTypesForRule
//       selectionMode: "ALL" || "SPECIFIC", // required
//       specificAssetTypes: [ // RuleAssetTypeList
//         "STRING_VALUE",
//       ],
//     },
//     dataProduct: true || false,
//     project: { // ProjectsForRule
//       selectionMode: "ALL" || "SPECIFIC", // required
//       specificProjects: [ // RuleProjectIdentifierList
//         "STRING_VALUE",
//       ],
//     },
//   },
//   detail: { // RuleDetail Union: only one key present
//     metadataFormEnforcementDetail: { // MetadataFormEnforcementDetail
//       requiredMetadataForms: [ // RequiredMetadataFormList
//         { // MetadataFormReference
//           typeIdentifier: "STRING_VALUE", // required
//           typeRevision: "STRING_VALUE", // required
//         },
//       ],
//     },
//   },
//   targetType: "DOMAIN_UNIT",
//   description: "STRING_VALUE",
//   createdAt: new Date("TIMESTAMP"), // required
//   createdBy: "STRING_VALUE", // required
// };

CreateRuleCommand Input

See CreateRuleCommandInput for more details

Parameter
Type
Description
action
Required
RuleAction | undefined

The action of the rule.

detail
Required
RuleDetail | undefined

The detail of the rule.

domainIdentifier
Required
string | undefined

The ID of the domain where the rule is created.

name
Required
string | undefined

The name of the rule.

scope
Required
RuleScope | undefined

The scope of the rule.

target
Required
RuleTarget | undefined

The target of the rule.

clientToken
string | undefined

A unique, case-sensitive identifier that is provided to ensure the idempotency of the request.

description
string | undefined

The description of the rule.

CreateRuleCommand Output

See CreateRuleCommandOutput for details

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
action
Required
RuleAction | undefined

The action of the rule.

createdAt
Required
Date | undefined

The timestamp at which the rule is created.

createdBy
Required
string | undefined

The user who creates the rule.

detail
Required
RuleDetail | undefined

The detail of the rule.

identifier
Required
string | undefined

The ID of the rule.

name
Required
string | undefined

The name of the rule.

ruleType
Required
RuleType | undefined

The type of the rule.

scope
Required
RuleScope | undefined

The scope of the rule.

target
Required
RuleTarget | undefined

The target of the rule.

description
string | undefined

The description of the rule.

targetType
RuleTargetType | undefined

The target type of the rule.

Throws

Name
Fault
Details
AccessDeniedException
client

You do not have sufficient access to perform this action.

ConflictException
client

There is a conflict while performing this action.

InternalServerException
server

The request has failed because of an unknown error, exception or failure.

ResourceNotFoundException
client

The specified resource cannot be found.

ServiceQuotaExceededException
client

The request has exceeded the specified service quota.

ThrottlingException
client

The request was denied due to request throttling.

ValidationException
client

The input fails to satisfy the constraints specified by the Amazon Web Services service.

UnauthorizedException
client

You do not have permission to perform this action.

DataZoneServiceException
Base exception class for all service exceptions from DataZone service.