The CreateFormType API call is used to create a metadata form type using APIs or AWS CLI. However it asks for a parameter entry for model and expects a smithy model. The documentation covers a single entry in the meta data form, this article will provide you an example to add multiple fields to your create-form-type api call.
Here’s a step by step process to create a meta data form in DataZone using AWS CLI commands:
a) Identify your Amazon DataZone domains and projects details to create the metadata form. To be specific you would need the following required parameters: Domain Identifier, Owning Project Identifier
Both of these are available in your DataZone UI, or you can use APIs to get the details:
b) You have to use the CreateFormType API or create-form-type CLI command to create your Metadata Forms in your project using code.
Request Syntax requires:
{
"description": "string",
"model": { ... },
"name": "string",
"owningProjectIdentifier": "string",
"status": "string"
}
Here, often users face challenges in framing the “model” parameter. It is a required field. It describes the model of this Amazon DataZone metadata form type. This field expects the smithy model of the API.
Users who are unaware of the exact smity model structure, can use the below structure to frame the required fields for their Metadata form:
Here, I am creating a Metadata form for 3 fields:
The first two fields are of data type String and are required fields.
The last field is of data type Integer and I have marked it as optional.
The Description of the field is denoted by @documentation,
Required fields are marked with @required,
To have a default name as display name, you can use @amazon.datazone#displayname
To define Minimum and Maximum values you can use @range
structure MetadataForm {
@required
@amazon.datazone#displayname(defaultName: \"FieldString1\")
@documentation(\"fieldName1 description\")
fieldName1: String
@required
@amazon.datazone#displayname(defaultName: \"FieldString2\")
@documentation(\"fieldName2 description\")
fieldName2: String
@amazon.datazone#displayname(defaultName: \"FieldInteger\")
@documentation(\"fieldName3 description\")
@range(min: 2, max: 10)
fieldName3: Integer
}
CLI Command Example:
aws datazone create-form-type --description "Metadata Form Test from CLI" —domain-identifier dzd_5slvr036xp8g87 —model '{"smithy":"structure MetadataForm { @required \n @amazon.datazone#displayname(defaultName: \"FieldString1\") @documentation(\"fieldName1 description\") fieldName1: String \n @required @amazon.datazone#displayname(defaultName: \"FieldString2\") @documentation(\"fieldName2 description\") fieldName2: String \n @amazon.datazone#displayname(defaultName: \"FieldInteger\") @documentation(\"fieldName3 description\") @range(min: 2, max: 10) fieldName3: Integer }" }' —name "MetadataForm" —owning-project-identifier "c8gq7clw2ay0br" —status "ENABLED"
For every successful CreateFormType command, you will receive an output like below:

This is how my Metadata Form looks in DataZone UI:

This can be helpful if you prefer Infrastructure as a Code. You can enhance the structure as per your use-case and this post is to provide an overview of how the smithy model structure should look.
References:
[1] https://docs.aws.amazon.com/cli/latest/reference/datazone/create-form-type.html
[2] https://docs.aws.amazon.com/datazone/latest/APIReference/API_CreateAsset.html