Specifying resources with Amazon CloudFormation - Amazon Personalize
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Specifying resources with Amazon CloudFormation

Amazon Personalize is integrated with Amazon CloudFormation, a service that helps you to model and set up your Amazon resources so that you can spend less time creating and managing your resources and infrastructure. You create a template that describes all the Amazon resources that you can specify (such as Amazon Personalize dataset groups). Amazon CloudFormation then provisions and configures those resources for you.

When you use Amazon CloudFormation, you can reuse your template to set up your Amazon Personalize resources consistently and repeatedly. Describe your resources once, and then provision the same resources over and over in multiple Amazon Web Services accounts and Regions.

Amazon Personalize and Amazon CloudFormation templates

To provision and configure resources for Amazon Personalize and related services, you must understand Amazon CloudFormation templates. Templates are formatted text files in JSON or YAML. These templates describe the resources that you want to provision in your Amazon CloudFormation stacks. If you're unfamiliar with JSON or YAML, you can use Amazon CloudFormation Designer to help you get started with Amazon CloudFormation templates. For more information, see What is Amazon CloudFormation Designer? in the Amazon CloudFormation User Guide.

Amazon Personalize supports specifying datasets, dataset groups, dataset import jobs, schemas, and solutions in Amazon CloudFormation. For more information, see the Amazon Personalize resource type reference in the Amazon CloudFormation User Guide.

Example Amazon CloudFormation templates for Amazon Personalize resources

The following Amazon CloudFormation template examples show you how to specify different Amazon Personalize resources.

CreateDatasetGroup

JSON
{ "AWSTemplateFormatVersion":"2010-09-09", "Resources":{ "MyDatasetGroup": { "Type": "AWS::Personalize::DatasetGroup", "Properties": { "Name": "my-dataset-group-name" } } } }
YAML
AWSTemplateFormatVersion: 2010-09-09 Resources: MyDatasetGroup: Type: 'AWS::Personalize::DatasetGroup' Properties: Name: my-dataset-group-name

CreateDataset

JSON
{ "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "MyDataset": { "Type": "AWS::Personalize::Dataset", "Properties": { "Name": "my-dataset-name", "DatasetType": "Interactions", "DatasetGroupArn": "arn:aws:personalize:us-west-2:123456789012:dataset-group/dataset-group-name", "SchemaArn": "arn:aws:personalize:us-west-2:123456789012:schema/schema-name", "DatasetImportJob": { "JobName": "my-import-job-name", "DataSource": { "DataLocation": "s3://amzn-s3-demo-bucket/file-name.csv" }, "RoleArn": "arn:aws:iam::123456789012:role/personalize-role" } } } } }
YAML
AWSTemplateFormatVersion: 2010-09-09 Resources: MyDataset: Type: 'AWS::Personalize::Dataset' Properties: Name: my-dataset-name DatasetType: Interactions DatasetGroupArn: 'arn:aws:personalize:us-west-2:123456789012:dataset-group/dataset-group-name' SchemaArn: 'arn:aws:personalize:us-west-2:123456789012:schema/schema-name' DatasetImportJob: JobName: my-import-job-name DataSource: DataLocation: 's3://amzn-s3-demo-bucket/file-name.csv' RoleArn: 'arn:aws:iam::123456789012:role/personalize-role'

CreateSchema

JSON
{ "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "MySchema": { "Type": "AWS::Personalize::Schema", "Properties": { "Name": "my-schema-name", "Schema": "{\"type\": \"record\",\"name\": \"Interactions\", \"namespace\": \"com.amazonaws.personalize.schema\", \"fields\": [ { \"name\": \"USER_ID\", \"type\": \"string\" }, { \"name\": \"ITEM_ID\", \"type\": \"string\" }, { \"name\": \"TIMESTAMP\", \"type\": \"long\"}], \"version\": \"1.0\"}" } } } }
YAML
AWSTemplateFormatVersion: 2010-09-09 Resources: MySchema: Type: AWS::Personalize::Schema Properties: Name: "my-schema-name" Schema: >- {"type": "record","name": "Interactions", "namespace": "com.amazonaws.personalize.schema", "fields": [ { "name": "USER_ID", "type": "string" }, { "name": "ITEM_ID", "type": "string" }, { "name": "TIMESTAMP", "type": "long"}], "version": "1.0"}

CreateSolution

JSON
{ "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "MySolution": { "Type": "AWS::Personalize::Solution", "Properties": { "Name": "my-solution-name", "DatasetGroupArn": "arn:aws:personalize:us-west-2:123456789012:dataset-group/my-dataset-group-name", "RecipeArn": "arn:aws:personalize:::recipe/aws-user-personalization", "SolutionConfig": { "EventValueThreshold" : ".05" } } } } }
YAML
AWSTemplateFormatVersion: 2010-09-09 Resources: MySolution: Type: 'AWS::Personalize::Solution' Properties: Name: my-solution-name DatasetGroupArn: >- arn:aws:personalize:us-west-2:123456789012:dataset-group/my-dataset-group-name RecipeArn: 'arn:aws:personalize:::recipe/aws-user-personalization' SolutionConfig: EventValueThreshold: '.05'

Learn more about Amazon CloudFormation

To learn more about Amazon CloudFormation, see the following resources: