so I've been working with Fivetran for a while and I've gotten used to hitting their API endpoints. But now, I've got to switch gears and work with AWS AppFlow, which is totally new territory for me.
Right now, I'm working on a React App and I'm struggling to figure out how to make it talk to AppFlow. I tried installing 'aws-sdk', but when I tried to import AWS from it, all I got was a nasty error message.
This is my aws-config.js
file inside my React application:
import AWS from 'aws-sdk';
AWS.config.update({
region: process.env.NX_REACT_APP_REGION,
credentials: {
accessKeyId: process.env.NX_REACT_APP_ACCESS,
secretAccessKey: process.env.NX_REACT_APP_SECRET,
},
});
export const appflow = new AWS.Appflow();
Then I'm importing it inside my component import {appflow} from '../../../../../aws-config';
but when I reload the page I get this error
TypeError aws_sdk__WEBPACK_IMPORTED_MODULE_0___default(...).Appflow is not a constructor
I've been searching around online trying to figure out how to make requests to AppFlow, but I gotta admit, I'm pretty stumped. Can anyone lend a hand? Any advice or guidance would be really appreciated.
Thanks in advance!
*** UPDATE ***
I could solve the problem by importing AppFlow
directly from aws-sdk as follow :
import * as Appflow from "aws-sdk/clients/Appflow";
import AWS from 'aws-sdk';
Here is my file for future reference:
import * as Appflow from "aws-sdk/clients/Appflow";
import AWS from 'aws-sdk';
console.log("HELLO FROM AWS FILE")
AWS.config.update({
region: process.env.NX_REACT_APP_REGION,
credentials: {
accessKeyId: process.env.NX_REACT_APP_ACCESS,
secretAccessKey: process.env.NX_REACT_APP_SECRET,
},
});
const amplitudeKey = process.env.NX_REACT_APP_AMPLITUDE_API_KEY;
const amplitudeSecret = process.env.NX_REACT_APP_AMPLITUDE_SECRET_KEY;
const appflow = new Appflow();
const createConnectorProfileParams = {
connectorProfileName: "connector-profile-test",
connectorType: "Amplitude",
connectionMode: "Public",
connectorProfileConfig: {
connectorProfileCredentials: {
Amplitude: {
apiKey: `${amplitudeKey}` ,
secretKey: `${amplitudeSecret}`
},
},
connectorProfileProperties: {
Amplitude: {}
},
}
}
appflow.createConnectorProfile(createConnectorProfileParams, (err, data) => {
if (err) console.log('Error creating flow:', err);
else console.log('Flow created successfully:', data);
});