Dev Environment Setup for working with the Connect SDK
Author:
Fluent Commerce
Changed on:
28 Nov 2023
Key Points
- This article providfes you with templates to setup your local environment for developing with the Connect SDK
- Local development uses a Docker localstack to emulate AWS services.
Steps
Configuring secrets in your localstack
Use the template below to create secrets in localstack before starting the application. The SDK expects ALL secrets to be prefixed with "fc/connect/\/". See Fluent Connector Configuration | Credential / Secrets Configuration for details on required secrets.
1docker exec -d localstack awslocal secretsmanager create-secret --name fc/connect/<FC-CONNECTOR>/api/fluent/activeAccounts --secret-string "{\"accounts\":[{\"name\":\"<FLUENT-ACCOUNT>\", \"region\":\"<FC-ACCOUNT-REGION>\" , \"retailers\":[<FLUENT-RETAILER1>,<FLUENT-RETAILER2>]}]}" ;
2docker exec -d localstack awslocal secretsmanager create-secret --name fc/connect/<FC-CONNECTOR>/<FLUENT-ACCOUNT>/api/fluent-account/<FLUENT-RETAILER> --secret-string "{\"retailer\":\"<FLUENT-RETAILER>\", \"userName\":\"<FC-USERNAME>\", \"password\":\"<FC-PASSWORD>\"}";
Language: plain_text
Name: Example
Description:
[Warning: empty required content area]The property FC-CONNECTOR value must match the connector configuration name found at
`application-connector.yml`
`connector-name: <FC-CONNECTOR>`
AWS CLI Configuration (Optional)
This is required when sending events to the queues or managing secrets in localstack directly from your terminal window.
- Run the AWS configuration and set your localstack profile.
- The access key values can be anything but empty
- The region has to be us-east-1
`aws configure --profile localstack`
`export AWS_PROFILE=localstack`
Please note that localstack region is defaulted to "us-east-1".
IDE Setup
IntelliJ Setup
Create a run configuration setting the spring profiles and environment variables and selecting the correct pre-configured localstack AWS profile. The application runs precisely the same way as it would in production, which is achieved by the properties below.
- Active Profiles: connector,dev-aws
- profile is always required, and it can be followed by the environment the application runs on (dev, test, QA, or production).
`connector`
- is a handy profile for local development with AWS. It enables the SDK to auto-start the queue and use some pre-configured values for development.
`dev-aws`
- Environment Variables: SQS_BATCH=batch; SQS_EVENTS=events; SQS_NOTIFICATION=notification
- These variables give actual names to the queues, as these may vary per environment.
- AWS credential profile/region: Select the localstack profile and set the region to US-EAST-1.
- Ensures the region matches with localstack and allows Spring to do the correct wiring of the AWS libraries.
For the IntelliJ community version, pass the spring profile configuration as JVM parameters:
`-Dspring.profiles.active=connector,dev-aws`
Eclipse / STS Setup
Create a run configuration and set the spring profiles and the environment variables.