スタートアップ(英語)
コミュニティ(英語)
トレーニング(英語)
チュートリアル(英語)
ドキュメント
API、AI、ツール (英語)
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:s3="http://www.mulesoft.org/schema/mule/s3"
xmlns:redshift="http://www.mulesoft.org/schema/mule/redshift"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/redshift http://www.mulesoft.org/schema/mule/redshift/current/mule-redshift.xsd
http://www.mulesoft.org/schema/mule/s3 http://www.mulesoft.org/schema/mule/s3/current/mule-s3.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" basePath="/">
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<redshift:config name="Amazon_Redshift_Connector_Config" doc:name="Amazon Redshift Connector Config">
<redshift:basic-connection
clusterId="${redshift.cluster_id}"
database="${redshift.database}"
user="${redshift.user}"
password="${redshift.password}"
region="${redshift.region}"
port="${redshift.port}"
/>
</redshift:config>
<redshift:config name="Amazon_Redshift_Connector_Config_Fips" doc:name="Amazon Redshift Connector Config Fips">
<redshift:iam-connection
clusterId="${redshift.cluster_id}"
database="${redshift.database}"
user="${redshift.user}"
accessKey="${redshift.password}"
secretKey="${redshift.secret_key}" customStsEndpoint="${redshift.fips.sts}">
<redshift:role arn="${redshift.role_arn}" />
</redshift:iam-connection>
</redshift:config>
<s3:config name="Amazon_S3_Configuration" doc:name="Amazon S3 Configuration">
<s3:basic-connection accessKey="${s3.access_key}" secretKey="${s3.secret_key}" region="${s3.region}"/>
</s3:config>
<file:config name="File_Config" doc:name="File Config">
<file:connection workingDir="${mule.home}/apps/${app.name}/" />
</file:config>
<configuration-properties doc:name="Configuration properties" file="mule-artifact.properties" />
<flow name="Create-Redshift-Table-S3-Bucket-S3-Object-Flow">
<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/init"/>
<set-variable value="username-bucket" doc:name="Bucket Name" variableName="bucket" />
<redshift:execute-ddl doc:name="Execute DDL" config-ref="Amazon_Redshift_Connector_Config">
<redshift:sql ><![CDATA[CREATE TABLE username (Username VARCHAR(50), Identifier INTEGER, First_Name VARCHAR(50), Last_Name VARCHAR(50));]]></redshift:sql>
</redshift:execute-ddl>
<s3:create-bucket doc:name="Create bucket" config-ref="Amazon_S3_Configuration" bucketName="#[vars.bucket]"/>
<file:read doc:name="Read" config-ref="File_Config" path="username.csv"/>
<s3:create-object doc:name="Create object" config-ref="Amazon_S3_Configuration" bucketName="#[vars.bucket]" key="username.csv" contentType="text/csv"/>
<ee:transform doc:name="Transform Message">
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
success: true,
redshiftTable: "username",
s3bucket: vars.bucket,
s3object: "username.csv"
}]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
<flow name="Execute-Copy-Command-Flow">
<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/execute"/>
<set-variable value="#['s3://username-bucket/username.csv']" doc:name="Bucket Name" variableName="bucketNameEndpoint"/>
<set-variable value="${copy.access_key}" doc:name="Access Key" variableName="access_key"/>
<set-variable value="${copy.secret_key}" doc:name="Secret Key" variableName="secret_key"/>
<redshift:execute-script doc:name="Execute script" config-ref="Amazon_Redshift_Connector_Config">
<redshift:sql ><![CDATA[#["copy username from " ++ "'" ++ vars.bucketNameEndpoint ++ "'" ++ " access_key_id " ++ "'" ++ vars.access_key ++ "'" ++ " secret_access_key " ++ "'" ++ vars.secret_key ++ "'" ++ " delimiter ';' IGNOREHEADER 1 IGNOREBLANKLINES"]]]></redshift:sql>
</redshift:execute-script>
<ee:transform doc:name="Transform Message">
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
"success": true
}
]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
<flow name="Delete-Redshift-Table-S3-Bucket-Flow">
<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/deleteAll"/>
<set-variable value="username-bucket" doc:name="Set Variable" variableName="bucketDelete"/>
<redshift:execute-ddl doc:name="Execute DDL" config-ref="Amazon_Redshift_Connector_Config">
<redshift:sql ><![CDATA[DROP TABLE username;]]></redshift:sql>
</redshift:execute-ddl>
<s3:delete-bucket doc:name="Delete bucket" config-ref="Amazon_S3_Configuration" force="true" bucketName='#[vars.bucketDelete]'/>
<ee:transform doc:name="Transform Message">
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
"success": true
}]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
<flow name="redshiftFipsDemoFlow">
<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/redshift"/>
<redshift:select doc:name="Select" config-ref="Amazon_Redshift_Connector_Config_Fips">
<redshift:sql ><![CDATA[select * from <your-tableName>]]></redshift:sql>
</redshift:select>
<ee:transform doc:name="Transform Message">
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" doc:name="Logger" message="#[payload]"/>
</flow>
</mule>



