

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# 例: Amazon Connect Customer Profiles と Amazon S3 をプログラムで統合する
<a name="customerprofiles-s3-integration"></a>

Customer Profiles の [PutIntegration](https://docs.aws.amazon.com/customerprofiles/latest/APIReference/API_PutIntegration.html) API を使用して、S3、Salesforce、Marketo などの統合をプログラムで作成できます。

このトピックでは、現在サポートされている最小値である 15 分の同期間隔で S3 との統合を作成する方法を説明します。

## ステップ 1: JSON ファイルを作成する
<a name="step1-cpintegration"></a>

次の内容を含む JSON ファイルを作成します。

```
{
    "DomainName": "your-domain",
    "ObjectTypeName": "your-object-name", 
    "FlowDefinition": {
        "FlowName": "your-flow-name",
        "KmsArn": "the key ARN is the same as your domain's key",
        "Description": "Created by Customer Profiles",
        "TriggerConfig": {
            "TriggerType": "Scheduled",
            "TriggerProperties": {
                "Scheduled": {
                    "ScheduleExpression": "rate(15minutes)",
                    "DataPullMode": "Incremental",
                    "ScheduleStartTime": 1634244800.435,
                    "FirstExecutionFrom": 1594166400
                }
            }
        },
        "SourceFlowConfig": {
            "ConnectorType":"S3",
            "SourceConnectorProperties": {
                "S3": {
                    "BucketName": "your-bucket",
                    "BucketPrefix": "your-prefix"
                }
            }
        },
        "Tasks": [
            {"TaskType":"Filter","SourceFields":["colA","colB"],"ConnectorOperator":{"S3":"PROJECTION"}},
            {"ConnectorOperator":{"S3":"NO_OP"},"DestinationField":"colA","TaskProperties":{},"SourceFields":["colA"],"TaskType":"Map"},
            {"ConnectorOperator":{"S3":"NO_OP"},"DestinationField":"colB","TaskProperties":{},"SourceFields":["colB"],"TaskType":"Map"}
        ]
    }
}
```

JSON を独自の値でカスタマイズするには、以下のガイドラインに従います。
+ `FlowName`: STRING [a-zA-Z0-9][\$1w\$1@\$1.-]\$1 を使用できる。
+ `ScheduleStartTime`: 現在の `DateTime` \$1 5 分のエポックタイムを設定する
+ `FirstExecutionFrom`: S3 に移動し、ファイルの日付を見て、最も古い日付より前の日付を使用する。
+ `Tasks`: `TaskType` を定義する。`Sourcefields` フィールドには、その配列内の CSV にあるすべての列を指定する必要があります。次に、その配列内の各項目に対して、`ConnectorOperator` を指定する必要があります。次は、`colA` と `colB` の 2 つの列を持つ CSV ドキュメントの例です。

## ステップ 2: PutIntegration API を呼び出す
<a name="step2-cpintegration"></a>

値を使用して JSON ファイルを作成し、カスタマイズしたら、次の例に示すように [PutIntegration](https://docs.aws.amazon.com/customerprofiles/latest/APIReference/API_PutIntegration.html) API を呼び出します。

```
aws customer-profiles put-integration --cli-input-json file:///put_integration_s3_cli.json --region us-west-2                    
```

`PutIntegration` からの応答はフロー URI を返します。例: 

```
{
    "DomainName": "testDomain",
    "Uri": "arn:aws:appflow:us-west-2:9999999999999:flow/Customer_Profiles_testDomain_S3_Salesforce-Account_1634244122247",
    "ObjectTypeName": "your objec type",
    "CreatedAt": "2021-10-14T13:51:57.748000-07:00",
    "LastUpdatedAt": "2021-10-14T13:51:57.748000-07:00",
    "Tags": {}
}
```

## ステップ 3: Amazon AppFlow StartFlow API を呼び出す
<a name="step3-cpintegration"></a>

フロー URI を使用して Amazon AppFlow [StartFlow](https://docs.aws.amazon.com/appflow/1.0/APIReference/API_StartFlow.html) API を呼び出します。例: 

```
aws appflow start-flow —flow-name uri --region us-west-2
```